-
Notifications
You must be signed in to change notification settings - Fork 84
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
refactor(radio-button, radio-button-group): convert enzyme tests to RTL #6848
Conversation
</RadioButtonGroup> | ||
); | ||
|
||
const fieldset = screen.getByRole("group", { name: "Radio Group Legend" }); |
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.
praise: great job checking the ARIA roles! Your method of targeting elements mirrors how an assistive technology user would inspect the page 👍🏼
"Uncontrolled behaviour in `Radio Button` is deprecated and support will soon be removed. Please make sure all your inputs are controlled." | ||
); | ||
expect(loggerSpy).toHaveBeenCalledTimes(1); | ||
}); |
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.
suggestion: restoring the logger's original behavior should prevent the console from being accidentally masked in other tests:
}); | |
loggerSpy.mockRestore(); | |
}); |
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.
Really good job - just some very minor comments to add to those of @Parsium
src/components/radio-button/radio-button-group/radio-button-group.test.tsx
Outdated
Show resolved
Hide resolved
src/components/radio-button/radio-button-group/radio-button-group.test.tsx
Show resolved
Hide resolved
src/components/radio-button/radio-button-group/radio-button-group.test.tsx
Outdated
Show resolved
Hide resolved
<RadioButton value="radio1" label="Radio Button 1" onFocus={onFocus} /> | ||
); | ||
|
||
await user.tab(); |
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.
suggestion (non-blocking): I'd prefer in these focus/blur tests to explicitly fetch a particular element to call .focus()
(and then tab/click as necessary for the rest of the test) - this ensures we're focusing/blurring the correct thing and avoids any future test flakiness if we later introduce other tab stops etc
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 focus method seems to call the actual HTML focus() method but this isn't getting flagged by the linter (issue raised here). I do agree that using tab() might be a bit flakey, though I think using click() should be fine.
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.
hmm, I wasn't aware there was any recommendation against using .focus()
on an HTML element, I thought this was what you needed to do to ensure a particular element was focused at the start of a test (I agree that once into the actual sequence of steps you're testing you should do "user things" like click/tab). I've done it myself in plenty of RTL tests recently and never been suggested not to 😂
e9b1840
to
911654b
Compare
🎉 This PR is included in version 141.0.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Proposed behaviour
Convert tests to RTL
Current behaviour
Tests are in enzyme
Checklist
d.ts
file added or updated if requiredQA
Additional context
Testing instructions