Repository navigation
Interactivity Router: Fix the flaky URL fragment navigate e2e test - #85473
Conversation
The test holds the router's page requests with page.route() and then releases the one of the latest navigation with resolvers.pop(). The fixture loads the router when a link is first clicked, so the request of the latest navigation can arrive after the test's checks pass. The test then released the stale request instead, the latest one was never released, and the title stayed "Main". Wait until both requests are held before releasing them, as #80178 does for the latest HTML test.
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.56 MB
🏁 Flaky testsSome 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. Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in
|
SantosGuillamot
left a comment
There was a problem hiding this comment.
LGTM 👍 I tested it locally and it seems to pass consistently.
…router-navigate-fragment-flaky
What?
Fixes the flaky e2e test
router-navigate.spec.ts› "should update the URL from the last navigation if only varies in the URL fragment".Why?
It fails most of the time locally. The test holds the router's page requests with
page.route()and then callsresolvers.pop()to release the request of the latest navigation. But the fixture only loads the router when a link is first clicked, so the requests start a few milliseconds after the clicks return. The checks before the release (navigations,statusandtitle) pass right away, because they change on click.So when the test calls
resolvers.pop(), often only the first request is held. The test releases that one instead, which belongs to the stale navigation and which the router correctly ignores. The latest request arrives just after, is held, and is never released, so the title stays "Main" and the test times out.It's the same race #80178 fixed for "should update the HTML only for the latest navigation".
How?
Before releasing anything, wait until both requests are held:
No check is removed or loosened: the test still releases the latest request first, and checks that only the latest navigation updates the title and the URL.
Testing Instructions
All runs pass. Without this change, the URL fragment test fails in most runs.
Use of AI Tools
Claude Code (Claude Opus): finding the cause from the Playwright traces, writing the change, running the tests, and drafting this description.