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

Components: Remove unnecessary act() from Button tests #47687

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Feb 2, 2023

What?

This PR cleans up a few unnecessary act() calls and improves some of the Button tests.

Why?

When preparing our tests to work with React 18 we did a bunch of those act() calls. It's time to clean them up where possible.

How?

  • We're using user.tab() instead of imperative element focus. Directly focusing an element is not something a user can do; they'd rather focus an element through clicking or tabbing. By using user.tab() we alter the tests to better resemble user behavior.
  • We're removing await act( () => Promise.resolve() ); calls - they no longer seem to be necessary.

Testing Instructions

Verify tests still pass: npm run test:unit packages/components/src/button/test/index.tsx

Testing Instructions for Keyboard

None

Screenshots or screencast

None

@tyxla tyxla added [Type] Code Quality Issues or PRs that relate to code quality [Package] Components /packages/components labels Feb 2, 2023
@tyxla tyxla requested a review from ajitbohra as a code owner February 2, 2023 12:49
@tyxla tyxla self-assigned this Feb 2, 2023
Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

Code changes LGTM 🚀 Much cleaner than before!

CI will confirm if indeed the unit tests keep working as expected ⏳

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

Flaky tests detected in 3ed0096.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4074617664
📝 Reported issues:

@tyxla tyxla merged commit f3905b2 into trunk Feb 2, 2023
@tyxla tyxla deleted the refactor/unnecessary-act-button-tests branch February 2, 2023 13:25
@github-actions github-actions bot added this to the Gutenberg 15.2 milestone Feb 2, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants