Skip to content

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

Merged
luisherranz merged 2 commits into
trunkfrom
fix/interactivity-router-navigate-fragment-flaky
Oct 28, 2026
Merged

luisherranz merged 2 commits 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>
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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

📦 Bundle size

Size Change: 0 B

Total Size: 8.56 MB

e68b202 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.

Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 6,
+   "offset": 6,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
Undo restores the post selection when another synced entity is loaded in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 2,
+   "offset": 2,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
can be converted to a quote in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

@@ -1,9 +1,9 @@
  <!-- wp:quote -->
  <blockquote class="wp-block-quote"><!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>one</li>
+ <li>e</li>
  <!-- /wp:list-item -->

  <!-- wp:list-item -->
  <li>two</li>
  <!-- /wp:list-item --></ul>

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:436:52
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should cut and paste individual blocks with collapsed selection in /test/e2e/specs/editor/various/copy-cut-paste.spec.js, passed after 1 failed attempt.
Error: expect(string).toMatchSnapshot(expected) failed

  @@ -1,3 +1,3 @@
   <!-- wp:paragraph -->
  -<p>2Cut - collapsed selection</p>
  +<p>2</p>
   <!-- /wp:paragraph -->


    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/copy-cut-paste.spec.js:45:49
should gradually multi-select in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
-     "name": "core/column",
+     "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:1194:5
should indent and outdent multi-selected items with Tab in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 10
+ Received  + 10

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>one<!-- wp:list -->
- <ul class="wp-block-list"><!-- wp:list-item -->
- <li>two</li>
+ <li></li>
+ <!-- /wp:list-item --></ul>
- <!-- /wp:list-item -->
+ <!-- /wp:list -->

- <!-- wp:list-item -->
- <li>three</li>
- <!-- /wp:list-item --></ul>
+ <!-- wp:paragraph -->
+ <p>two</p>
+ <!-- /wp:paragraph -->
+
- <!-- /wp:list --></li>
- <!-- /wp:list-item --></ul>
+ <!-- wp:paragraph -->
+ <p>three</p>
- <!-- /wp:list -->
+ <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1118:52
should insert a line break on shift+enter in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>a<br></li>
+ <li><br></li>
  <!-- /wp:list-item --></ul>
  <!-- /wp:list -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1210:52
should leave nested list intact when deleting the parent item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  -  1
+ Received  + 19

@@ -1,19 +1,36 @@
  Array [
    Object {
+     "attributes": Object {
+       "content": "1",
+       "dropCap": false,
+     },
+     "innerBlocks": Array [],
+     "name": "core/paragraph",
+   },
+   Object {
+     "attributes": Object {
+       "ordered": false,
+       "values": "",
+     },
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "",
          },
          "innerBlocks": Array [
            Object {
+             "attributes": Object {
+               "ordered": false,
+               "values": "",
+             },
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
                    "content": "a",
                  },
+                 "innerBlocks": Array [],
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
            },
@@ -22,10 +39,11 @@
        },
        Object {
          "attributes": Object {
            "content": "3",
          },
+         "innerBlocks": Array [],
          "name": "core/list-item",
        },
      ],
      "name": "core/list",
    },
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:3017:38
should leave the rest of the list intact when merging into an empty list item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  -  0
+ Received  + 13

@@ -5,27 +5,40 @@
          "attributes": Object {
            "content": "1",
          },
          "innerBlocks": Array [
            Object {
+             "attributes": Object {
+               "ordered": false,
+               "values": "",
+             },
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
                    "content": "a",
                  },
+                 "innerBlocks": Array [],
                  "name": "core/list-item",
                },
                Object {
                  "attributes": Object {
                    "content": "b",
                  },
+                 "innerBlocks": Array [],
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
            },
          ],
+         "name": "core/list-item",
+       },
+       Object {
+         "attributes": Object {
+           "content": "",
+         },
+         "innerBlocks": Array [],
          "name": "core/list-item",
        },
      ],
      "name": "core/list",
    },
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:3118:38
should merge a following sibling list into the outermost list with Delete from a nested item (#77245) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

@@ -8,11 +8,11 @@
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
-                   "content": "b‸",
+                   "content": "b",
                  },
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
@@ -25,11 +25,11 @@
    },
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "‸1",
          },
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2854:41
should outdent list items when deleting an empty parent at the top in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 19
+ Received  +  1

- Array [
-   Object {
-     "innerBlocks": Array [
-       Object {
-         "attributes": Object {
-           "content": "a",
-         },
-         "name": "core/list-item",
-       },
-       Object {
-         "attributes": Object {
-           "content": "b",
-         },
-         "name": "core/list-item",
-       },
-     ],
-     "name": "core/list",
-   },
- ]
+ Array []

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:3074:41
should replace selected non-breaking spaces from the toolbar in /test/e2e/specs/editor/various/rich-text.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
      "attributes": Object {
-       "content": "one two three",
+       "content": "ne two three",
      },
      "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/rich-text.spec.js:1050:41
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":20,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8889/wp-content/uploads/2026/10/7c3e3493-ddb6-4405-b9d4-b137f514aa77.png" alt="" class="wp-image-20"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:363:49
three users concurrently edit a large post with diverse blocks in /test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts, passed after 1 failed attempt.
TimeoutError: locator.waitFor: Timeout 17500ms exceeded.
Call log:
  - waiting for getByRole('button', { name: /Collaborators list/ }) to be visible

    at map (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:193:7)
    at CollaborationUtils.waitForMutualDiscovery (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:188:10)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts:416:28

e68b202 Run

@SantosGuillamot SantosGuillamot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 I tested it locally and it seems to pass consistently.

@luisherranz
luisherranz merged commit 76d1db7 into trunk Oct 28, 2026
78 of 79 checks passed
@luisherranz
luisherranz deleted the fix/interactivity-router-navigate-fragment-flaky branch October 28, 2026 14:12
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 28, 2026
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.

2 participants