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

AlignmentMatrixControl: replace act() with userEvent #53703

Merged
merged 1 commit into from Aug 16, 2023

Conversation

brookewp
Copy link
Contributor

What?

Update test to utilize userEvent and remove act().

Why?

While working on #48222, I came across this test which was failing due to ...wrapped into act(...) errors.

How?

Removed act() and added userEvent.click. This moves the test closer to how a user would interact via click instead of setting the focus. I've added another assertion to check the element has focus after the click, instead.

Testing Instructions

Verify tests still pass: packages/components/src/alignment-matrix-control/test/index.tsx

@brookewp brookewp added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Aug 15, 2023
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.

Nice touch 👍 🚀 Thanks!

await act( () => getCell( alignment ).focus() );
await user.click( getCell( alignment ) );

expect( getCell( alignment ) ).toHaveFocus();
Copy link
Member

Choose a reason for hiding this comment

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

Replacing a .focus() with a .click() makes the intention a bit less clear, but the "have focus" assertion definitely helps clarify it, so thanks for adding that assertion 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for sharing! It's helpful to know it was a useful addition.

@brookewp brookewp merged commit 9b7ebda into trunk Aug 16, 2023
53 checks passed
@brookewp brookewp deleted the update/alignment-matrix-control-test branch August 16, 2023 18:31
@github-actions github-actions bot added this to the Gutenberg 16.6 milestone Aug 16, 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] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants