-
Notifications
You must be signed in to change notification settings - Fork 0
IBX-10695: Add tests for RadioButton components #51
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive test coverage for RadioButton components using Storybook test stories. The changes focus on adding behavioral tests that verify user interactions and component state changes.
- Adds test stories for RadioButtonsListField component to verify selection behavior
- Enhances existing test stories for RadioButtonInput and RadioButtonField components with more detailed assertions
- Improves test descriptions and adds proper type annotations for better test reliability
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
RadioButtonsListField.test.stories.tsx | New test file covering radio button list selection and onChange behavior |
RadioButtonInput.test.stories.tsx | Enhanced test assertions and improved step descriptions |
RadioButtonField.test.stories.tsx | Added comprehensive test scenarios including label interaction and duplicate assertions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
}); | ||
|
||
await step('Radio Button handles blur event', async () => { | ||
await step('Click outside checkbox', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The step description mentions 'checkbox' but this is testing a radio button component. It should be 'Click outside radio button'.
await step('Click outside checkbox', async () => { | |
await step('Click outside radio button', async () => { |
Copilot uses AI. Check for mistakes.
await expect(args.onFocus).toHaveBeenCalledOnce(); | ||
await expect(args.onChange).toHaveBeenCalledOnce(); | ||
await expect(args.onChange).toHaveBeenLastCalledWith(true, expect.anything()); | ||
await expect(args.onInput).toHaveBeenCalledOnce(); | ||
await expect(args.onInput).toHaveBeenLastCalledWith(true, expect.anything()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertions expect onFocus, onChange, and onInput to be called only once each, but this is the second click on the radio button. Radio buttons typically don't trigger onChange/onInput events when clicked again if already selected, so these call counts should reflect the cumulative calls from both steps.
Copilot uses AI. Check for mistakes.
await expect(args.onChange).toHaveBeenCalledOnce(); | ||
await expect(args.onChange).toHaveBeenLastCalledWith(true, expect.anything()); | ||
await expect(args.onInput).toHaveBeenCalledOnce(); | ||
await expect(args.onInput).toHaveBeenLastCalledWith(true, expect.anything()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous issue, these assertions expect onChange and onInput to be called only once total, but this is the second interaction (clicking the label again). The call counts should reflect cumulative calls or be adjusted based on expected radio button behavior.
Copilot uses AI. Check for mistakes.
Description:
For QA:
Documentation: