Flaky tests: fix router navigate latest HTML - #80178
Merged
Merged
Conversation
|
Size Change: 0 B Total Size: 7.71 MB |
CoderAbhinav
added a commit
to CoderAbhinav/gutenberg
that referenced
this pull request
Jul 22, 2026
The test "should update the URL from the last navigation if only varies in the URL fragment" could release a navigation's response before both requests had reached the route handler. Both navigations target the same page path (they only differ in the URL fragment, which is stripped when building the cache key), so both fetches go through a single route handler and their resolvers are collected in a shared array. Asserting the pending navigations counter is `2` only guarantees both navigate actions have started; the actual fetches happen later (after a dynamic import). As a result, `resolvers.pop()` could release the first navigation's request instead of the last one's. That earlier navigation bails out because its destination is no longer the current one, so the title stays "Main" and the assertion for "Link 1" times out. Wait for both requests to reach the route handler before releasing any of them, mirroring the fix applied to the sibling test in WordPress#80178. Reported issues: - Fixes WordPress#80447
ntsekouras
approved these changes
Jul 30, 2026
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #78835.
This fixes a race in the router navigation E2E test. The test could call
resolveLink2()before Playwright entered the second route handler, leaving the resolver undefined and failing withresolveLink2 is not a function.How
The test now waits for both intercepted requests to reach their route handlers before releasing either response. It can then complete the second request first and the earlier request last, while checking that the earlier response does not replace the latest navigation's HTML.
Locally, the test failed 25 times in 40 runs without this change. With the change applied, all 40 runs passed.
Testing Instructions
npm run test:e2e -- test/e2e/specs/interactivity/router-navigate.spec.ts -g "should update the HTML only for the latest navigation" --repeat-each=40npm run test:e2e -- test/e2e/specs/interactivity/router-navigate.spec.tsI used Codex to help implement these changes. I guided the work, then tested and reviewed the result.