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

Update tests from fireEvent to userEvent #44952

Merged

Conversation

brookewp
Copy link
Contributor

@brookewp brookewp commented Oct 13, 2022

What?

Migrate fireEvent usages to @testing-library/user-event.

In this case, I decided to start by looking at instances of fireEvent.click as the PR would be too large if all instances of fireEvent were included.

And hopefully, by addressing these by method it will be helpful for others trying to migrate from fireEvent and learn about which methods to move to.

Why?

The user-event library provides a more realistic simulation of how a user interacts with the DOM and is the preferred method according to Testing Library docs and our own docs:

https://github.com/WordPress/gutenberg/blob/trunk/docs/contributors/code/testing-overview.md#user-interaction

How?

Testing Instructions

Make sure all tests pass by running npm run test:unit [file-name] for the following:

npm run test:unit packages/components/src/custom-select-control/test/index.js
npm run test:unit packages/components/src/item-group/test/index.js
npm run test:unit packages/components/src/slot-fill/test/slot.js

@brookewp brookewp force-pushed the update/fireEvent-click-to-userEvent branch from 3f549e6 to 47dc182 Compare October 24, 2022 22:25
@brookewp brookewp force-pushed the update/fireEvent-click-to-userEvent branch 2 times, most recently from 79ed874 to 3e2c244 Compare November 3, 2022 01:01
@brookewp brookewp self-assigned this Nov 9, 2022
@brookewp brookewp force-pushed the update/fireEvent-click-to-userEvent branch from 3e2c244 to 97799d9 Compare November 22, 2022 05:48
@brookewp brookewp force-pushed the update/fireEvent-click-to-userEvent branch from 84a2a78 to 275e335 Compare March 28, 2023 11:07
@brookewp brookewp changed the title [WIP] Update tests from fireEvent to userEvent: fireEvent.click Update tests from fireEvent to userEvent Mar 28, 2023
@brookewp brookewp force-pushed the update/fireEvent-click-to-userEvent branch from 275e335 to 639ac6b Compare March 29, 2023 10:55
@WordPress WordPress deleted a comment from tyxla Mar 29, 2023
@WordPress WordPress deleted a comment from tyxla Mar 29, 2023
@brookewp brookewp force-pushed the update/fireEvent-click-to-userEvent branch from 639ac6b to d08a953 Compare March 29, 2023 11:00
@brookewp brookewp marked this pull request as ready for review March 29, 2023 13:37
@brookewp brookewp requested a review from ajitbohra as a code owner March 29, 2023 13:37
@brookewp
Copy link
Contributor Author

Just to note, I removed changes/comments that were no longer relevant due to the React 18 migration and improvements of tests.

@brookewp brookewp requested review from tyxla and flootr March 29, 2023 13:54
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

There is a console.warn warning in the console, but that's expected and it is present in trunk as well, likely occurring because we're using @wordpress/warning for that warning.

🚀

@brookewp brookewp merged commit 5f9510c into WordPress:trunk Mar 29, 2023
@github-actions github-actions bot added this to the Gutenberg 15.5 milestone Mar 29, 2023
@ryanwelcher ryanwelcher added [Type] Enhancement A suggestion for improvement. [Type] Code Quality Issues or PRs that relate to code quality [Package] Components /packages/components labels Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants