From e5c88989f1115795f26aea394f174a1325f673ec Mon Sep 17 00:00:00 2001 From: Ben Vinegar <2153+benvinegar@users.noreply.github.com> Date: Sat, 20 Jun 2026 17:08:51 -0400 Subject: [PATCH] test(e2e): fix flaky url-routing session-click assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "clicking a session updates the URL to /session/:id" asserted the URL with a `$` anchor, but selecting a session pushes /session/:id and then focusSurface immediately replaceState's /session/:id/s/:surfaceId once the first card is visible. The `$`-anchored match only matches the transient pre-focus URL, so on a loaded CI/WebKit runner toHaveURL polls only after the suffix lands and times out on every retry (passes locally where the click wins the race). Match the session segment with a `(\b|/)` boundary instead — the same pattern the sibling back/forward test already uses. Co-Authored-By: Claude Opus 4.8 (1M context) --- .changeset/url-routing-flaky-fix.md | 2 ++ e2e/url-routing.spec.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/url-routing-flaky-fix.md diff --git a/.changeset/url-routing-flaky-fix.md b/.changeset/url-routing-flaky-fix.md new file mode 100644 index 0000000..a845151 --- /dev/null +++ b/.changeset/url-routing-flaky-fix.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/e2e/url-routing.spec.ts b/e2e/url-routing.spec.ts index a3751bd..8ea44d2 100644 --- a/e2e/url-routing.spec.ts +++ b/e2e/url-routing.spec.ts @@ -6,13 +6,16 @@ test("clicking a session updates the URL to /session/:id", async ({ page, server await page.goto(server.url); await expect(page.locator("#sessionList .sess")).toHaveCount(2); - // click the second session row + // click the second session row. Selecting a session pushes /session/:id, then + // focusSurface immediately replaceState's /session/:id/s/:surfaceId once the + // first card is visible — so match the session segment with a boundary, not a + // `$`, or this races the deep-link suffix (see the back/forward test below). await page.locator(`#sessionList .sess[data-id="${s2.sessionId}"]`).click(); - await expect(page).toHaveURL(new RegExp(`/session/${s2.sessionId}$`)); + await expect(page).toHaveURL(new RegExp(`/session/${s2.sessionId}(\\b|/)`)); // click the first session row await page.locator(`#sessionList .sess[data-id="${s1.sessionId}"]`).click(); - await expect(page).toHaveURL(new RegExp(`/session/${s1.sessionId}$`)); + await expect(page).toHaveURL(new RegExp(`/session/${s1.sessionId}(\\b|/)`)); }); test("navigating to /session/:id selects that session", async ({ page, server }) => {