Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): react hook form tests & stories #2931

Merged
merged 14 commits into from May 4, 2024
Merged

Conversation

wingkwong
Copy link
Member

@wingkwong wingkwong commented May 2, 2024

Closes #

📝 Description

  • add tests & missing stories for react hook form components
  • input
  • checkbox
  • select
  • autocomplete
  • switch

⛳️ Current behavior (updates)

Please describe the current behavior that you are modifying

🚀 New behavior

Please describe the behavior or changes this PR adds

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • New Features

    • Enhanced form handling across various components (autocomplete, checkbox, input, select, switch) using React Hook Form.
    • Introduced new story templates and functions in story files for better user interface demonstrations.
  • Bug Fixes

    • Adjusted component exports and story implementations to streamline user experience and integration.
  • Documentation

    • Updated dependencies in package.json files to include React Hook Form for necessary components.
  • Tests

    • Added and updated tests to cover form behavior with React Hook Form integration across multiple components.

Copy link

linear bot commented May 2, 2024

Copy link

changeset-bot bot commented May 2, 2024

⚠️ No Changeset found

Latest commit: cae7fca

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2024 5:01am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2024 5:01am

Copy link
Contributor

coderabbitai bot commented May 2, 2024

Walkthrough

The updates across various components primarily involve integrating react-hook-form for enhanced form handling and testing. This includes adding the library to dependencies, importing useForm in test and story files, and adjusting tests and stories to accommodate form-related functionalities. These changes aim to standardize form handling and improve testing robustness across components like autocomplete, checkbox, input, select, and switch.

Changes

Files Change Summary
.../autocomplete/__tests__/autocomplete.test.tsx, .../checkbox/__tests__/checkbox.test.tsx, .../input/__tests__/input.test.tsx, .../select/__tests__/select.test.tsx, .../switch/__tests__/switch.test.tsx Added useForm from react-hook-form and updated tests for form handling.
.../autocomplete/package.json, .../select/package.json Added "react-hook-form": "^7.51.3" to dependencies.
.../autocomplete/stories/autocomplete.stories.tsx, .../select/stories/select.stories.tsx, .../switch/stories/switch.stories.tsx Modified stories to include useForm and updated function exports and names to align with form integration.

Recent Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between f28b1e9 and cae7fca.
Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
Files selected for processing (10)
  • packages/components/autocomplete/tests/autocomplete.test.tsx (2 hunks)
  • packages/components/autocomplete/package.json (1 hunks)
  • packages/components/autocomplete/stories/autocomplete.stories.tsx (5 hunks)
  • packages/components/checkbox/tests/checkbox.test.tsx (2 hunks)
  • packages/components/input/tests/input.test.tsx (2 hunks)
  • packages/components/select/tests/select.test.tsx (2 hunks)
  • packages/components/select/package.json (1 hunks)
  • packages/components/select/stories/select.stories.tsx (6 hunks)
  • packages/components/switch/tests/switch.test.tsx (3 hunks)
  • packages/components/switch/stories/switch.stories.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
  • packages/components/autocomplete/package.json
  • packages/components/select/package.json
Additional comments not posted (19)
packages/components/checkbox/__tests__/checkbox.test.tsx (2)

4-4: Ensure useForm is utilized effectively in the test suite.


133-202: The new test suite for React Hook Form integration is comprehensive, covering scenarios like default values and form submission behavior.

packages/components/switch/stories/switch.stories.tsx (1)

224-225: The new story WithReactHookForm effectively demonstrates the Switch component's usage with React Hook Form.

packages/components/input/__tests__/input.test.tsx (2)

4-4: Ensure useForm is utilized effectively in the test suite.


151-224: The new test suite for React Hook Form integration is comprehensive, covering scenarios like default values and form submission behavior.

packages/components/switch/__tests__/switch.test.tsx (2)

4-4: Ensure useForm is utilized effectively in the test suite.


204-273: The new test suite for React Hook Form integration is comprehensive, covering scenarios like default values and form submission behavior.

packages/components/autocomplete/__tests__/autocomplete.test.tsx (2)

4-4: Ensure useForm is utilized effectively in the test suite.


225-325: The new test suite for React Hook Form integration is comprehensive, covering scenarios like default values and form submission behavior.

packages/components/select/__tests__/select.test.tsx (2)

4-4: Ensure useForm is utilized effectively in the test suite.


402-491: The new test suite for React Hook Form integration is comprehensive, covering scenarios like default values and form submission behavior.

packages/components/select/stories/select.stories.tsx (4)

5-5: Integration of useForm from react-hook-form is correctly imported and used to enhance form handling capabilities in stories.


589-628: The WithReactHookFormTemplate function correctly demonstrates the integration of the Select component with React Hook Form, including handling default values and required fields. Ensure that the data-testid attributes align with your testing strategy.


676-684: The IsInvalid story configuration correctly sets up the Select component to demonstrate its behavior when an invalid selection is made. The errorMessage prop is used effectively to provide user feedback.


712-719: The WithDescription story configuration effectively uses the description prop to add descriptive text to the Select component, enhancing its accessibility and user understanding.

packages/components/autocomplete/stories/autocomplete.stories.tsx (4)

5-5: Integration of useForm from react-hook-form is correctly imported and used to enhance form handling capabilities in stories.


690-727: The WithReactHookFormTemplate function correctly demonstrates the integration of the Autocomplete component with React Hook Form, including handling default values and required fields. Ensure that the data-testid attributes align with your testing strategy.


816-825: The IsInvalid story configuration correctly sets up the Autocomplete component to demonstrate its behavior when an invalid selection is made. The errorMessage prop is used effectively to provide user feedback.


828-835: The WithDescription story configuration effectively uses the description prop to add descriptive text to the Autocomplete component, enhancing its accessibility and user understanding.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@wingkwong wingkwong changed the title feat(input): add Input with React Hook Form tests feat(test): react hook form tests May 2, 2024
@wingkwong wingkwong changed the title feat(test): react hook form tests feat(test): react hook form tests & stories May 4, 2024
@jrgarciadev jrgarciadev added this to the v2.3.7 milestone May 4, 2024
@jrgarciadev jrgarciadev merged commit 633f9d2 into canary May 4, 2024
8 checks passed
@jrgarciadev jrgarciadev deleted the feat/eng-779 branch May 4, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants