test(e2e): fix flaky url-routing session-click assertion#87
Merged
Conversation
"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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
e2e/url-routing.spec.ts› "clicking a session updates the URL to /session/:id" is flaky on CI (WebKit). It passes onmainby 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, thenfocusSurface()immediatelyreplaceStates/session/:id/s/:surfaceIdonce the first card becomes visible (the deep-linkable-URLs feature, #78). Observed sequence after a click:The assertion used a
$anchor, so it only matches the transient pre-focus URL.toHaveURLpolls; 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