Conversation
|
Size Change: 0 B Total Size: 7.75 MB ℹ️ View Unchanged
|
|
Flaky tests detected in c88fb89. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24755989036
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| await waitFor( () => | ||
| expect( screen.getByRole( 'menu' ) ).toHaveFocus() | ||
| ); | ||
| await waitForFocusedMenu(); |
There was a problem hiding this comment.
I wondered if we actually needed to be awaiting these, or if we can expect it to be synchronous once the menu is open. Your PR description mentions "Leaves the synchronous assertions in place for stable in-menu navigation where focus is already inside the same menu context". Is it not referring to this?
There was a problem hiding this comment.
I tried trimming that one further by making the defaultOpen focus assertion synchronous, but it immediately failed locally on the same expectation, so I restored the waitFor.
| await waitFor( () => { | ||
| expect( outerButton ).toHaveFocus(); | ||
| expect( screen.queryByRole( 'menu' ) ).not.toBeInTheDocument(); | ||
| } ); |
There was a problem hiding this comment.
Minor:
- Do we need to be awaiting both of these things (i.e. is each independently flakey) or can we await only the focus change and then break out the remaining assertion.
- Related point: I wonder if we can reuse the utility for detecting the outer button, so we'd have something like:
| await waitFor( () => { | |
| expect( outerButton ).toHaveFocus(); | |
| expect( screen.queryByRole( 'menu' ) ).not.toBeInTheDocument(); | |
| } ); | |
| await waitForFocusedButton( 'Button outside of dropdown' ); | |
| expect( screen.queryByRole( 'menu' ) ).not.toBeInTheDocument(); |
There was a problem hiding this comment.
Trimmed the changeset down further so it generally only addresses the historically-known failures (listed in the PR description). Passed on 10 test runs, so good enough as a first try. We can expand if needed.
What?
This updates
packages/components/src/menu/test/index.tsxto stabilize focus assertions across theMenutest file, by adding shared async focus helpers and uses them for the focus transitions that were failing intermittently in CI.Why?
The common pattern in recent unit test failures on CI is that focus sometimes lands on an intermediate element first, then settles on the expected target a moment later.
That showed up in recent logs as:
Submenu item 1, but focus was still on the submenurole="menu"container.Taken together, those runs suggest a broader focus-settling race in this test file rather than a single isolated flaky assertion.
How?
Testing Instructions
npm run test:unit -- packages/components/src/menu/test/index.tsx --runInBand.packages/components/src/menu/test/index.tsxpasses.npm run test:unit -- packages/components/src/menu/test/index.tsx --runInBand.