Skip to content

test(e2e): fix flaky url-routing session-click assertion#87

Merged
benvinegar merged 1 commit into
mainfrom
fix/url-routing-flaky-assertion
Jun 20, 2026
Merged

test(e2e): fix flaky url-routing session-click assertion#87
benvinegar merged 1 commit into
mainfrom
fix/url-routing-flaky-assertion

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Problem

e2e/url-routing.spec.ts › "clicking a session updates the URL to /session/:id" is flaky on CI (WebKit). It passes on main by luck and fails on unrelated PRs (e.g. #81, a README-only change) that simply trigger a fresh CI run.

Root cause

Selecting a session pushStates /session/:id, then focusSurface() immediately replaceStates /session/:id/s/:surfaceId once the first card becomes visible (the deep-linkable-URLs feature, #78). Observed sequence after a click:

/session/<id>            <-- transient, matches the test's /…$/
/session/<id>/s/<sid>    <-- where it settles

The assertion used a $ anchor, so it only matches the transient pre-focus URL. toHaveURL polls; on a loaded CI/WebKit runner the first poll lands after the suffix is appended, so it never matches and times out on every retry. Locally (idle, fast) the click wins the race, so it passes — the classic flaky signature. Confirmed by instrumenting the live URL after a click.

Fix

Match the session segment with a (\b|/) boundary instead of $, so the assertion tolerates the deep-link suffix — exactly the pattern the sibling "browser back/forward" test in the same file already uses. The match still requires the exact session id in the path, so it doesn't pass vacuously.

Validation

npx playwright test e2e/url-routing.spec.ts — 14 passed (chromium + webkit), including 20× repeat-each on the previously-flaky test. Empty changeset included (test-only).

🤖 Generated with Claude Code

"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) <noreply@anthropic.com>
@benvinegar benvinegar merged commit a6aca7b into main Jun 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant