Skip to content

Interactivity Router: Fix the flaky URL fragment navigate e2e test - #85473

Open
luisherranz wants to merge 1 commit into
trunkfrom
fix/interactivity-router-navigate-fragment-flaky
Open

luisherranz wants to merge 1 commit into
trunkfrom
fix/interactivity-router-navigate-fragment-flaky

Conversation

@luisherranz

Copy link
Copy Markdown
Member

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 calls resolvers.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, status and title) 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:

await expect.poll( () => resolvers.length ).toBe( 2 );

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

npm run test:e2e -- test/e2e/specs/interactivity/router-navigate.spec.ts --repeat-each=5 --retries=0

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.

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.
@luisherranz luisherranz self-assigned this Oct 23, 2026
@luisherranz luisherranz added [Type] Flaky Test Auto-generated flaky test report issue [Package] Interactivity /packages/interactivity labels Oct 23, 2026
@github-actions github-actions Bot removed the [Package] Interactivity /packages/interactivity label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: luisherranz <luisherranz@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: 0 B

Total Size: 9.06 MB

81cf75a Run

🏁 Flaky tests

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.

Regression: updating a specific option will only change its value and will not corrupt others in /test/e2e/specs/editor/various/core-settings.spec.js, passed after 1 failed attempt.
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
    "rewrite_rules",
-   "SERIALIZED DATA",
+   "",
  ]
    at forEach (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:46:26)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:43:35

81cf75a Run

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Flaky Test Auto-generated flaky test report issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant