Skip to content

test: wait for the rename page before typing so the locations example stops flaking - #421

Merged
plainprogrammer merged 2 commits into
mainfrom
092-locations-rename-flake
Nov 14, 2026
Merged

plainprogrammer merged 2 commits into
mainfrom
092-locations-rename-flake

Conversation

@plainprogrammer

Copy link
Copy Markdown
Owner

Closes #417

A test-only fix for the flaky example "adds with the keyboard, renames and removes through the pages" (spec/system/locations_spec.rb:7). No app code changes, and no spec (routed as a direct fix with the coordinator).

Cause

The example clicked "Rename Blue binder" and at once filled in "Name". The Locations page it is leaving has a field labelled "Name" too (the add form), so when the visit to the rename page hadn't rendered yet, the text went into the add form; the rename page then arrived holding "Blue binder" and Save renamed the location to its own name. With the rename page's fetch held back 400 ms, fill_in ran at 75 ms on /locations (h1 "Locations") and the rename page rendered at 433 ms; with no delay the page renders 31 ms after the click and fill_in starts 30 ms later, so a slow response loses. Not a product bug: a person can't click and type in that time, and no app code is in the path. The event log and the reproducer are in the issue comment.

Change

  • spec/system/locations_spec.rb: expect(page).to have_css("h1", text: "Rename location") between the click and the fill_in, something only the rename page has. No sleep.
  • The other system specs were scanned for a click followed at once (or after one statement that isn't an expectation) by a fill or click of a label the page being left also has. None shares the race (each is named in the commit body): the second control only exists on the new page, page 1 of the bulk pager has no "Previous", the click opens an in-page menu or dialog, or the example runs on rack_test.
  • .claude/memory/turbo-back-navigation-quirks.md records the race; a lesson records how to measure a rare race.

Evidence

Provoked with a temporary spec of the rename steps (kept out of the suite) that holds back the rename page's fetch:

Delay on the rename page's fetch Before After
40 ms 8 of 30 failed (27%) 0 of 30
400 ms 10 of 10 failed 0 of 10

The example alone, no delay, on this machine:

Runs Failures
Before 60 0
After 200 0

What the counts show: with the delay, the failure is the issue's exact text and the wait removes it. What they don't show: that the natural rate is zero. The unfixed example also passed 60 of 60, so the clean loop of the real example can't tell the two apart; 0 of 60 bounds the natural rate under about 5% and 0 of 200 under about 1.5%, both at 95% confidence, no more. The whole locations_spec.rb: 5 examples, 0 failures. bin/ci checks green. The pre-push hook ran the full bin/ci at 22d411da (5047 examples) and passed.

Implementation review

Opus 5.5, read-only: SPEC-ALIGNED, no code change. It confirmed the heading can only come from the rename page (the Locations page's one h1 is "Locations"; the layouts have none), found no other step of the example with the race, and corrected three details of the commit body (fixed before the push): "Done" is a link to a new page (still safe, "End sitting" only exists there), only one of the two deck_proxy_replacements examples is rack_test, and the list of safe specs wasn't exhaustive. The statistics were checked and not overclaimed.

🤖 Generated with Claude Code

plainprogrammer and others added 2 commits November 13, 2026 19:43
… stops flaking

The example clicked "Rename Blue binder" and at once filled in "Name". The Locations page it is leaving has a field
labelled "Name" too (the add form), so when the visit to the rename page hadn't rendered yet, the text went into the
add form; the rename page then arrived holding "Blue binder" and Save renamed the location to its own name.

Cause, confirmed from an event timeline (Turbo's visit/render/load events and the fetch, logged in the window, with the
rename page's fetch held back 400 ms): fill_in ran at 75-107 ms while location.pathname was /locations and the h1 was
"Locations"; the rename page rendered at 433 ms. With no delay the page renders 31 ms after the click and fill_in starts
30 ms later, so the margin on a quick machine is one Selenium round trip and a slow response loses it. A person can't
click and type within that time, and no app code is involved (the field is the same on both pages by design).

Proof, a temporary spec of the example's rename steps with the fetch of the rename page held back (not committed; its
code is in the issue):

  delay 40 ms:  before 8 of 30 runs failed; after 0 of 30
  delay 400 ms: before 10 of 10 failed;     after 0 of 10

The example alone, no delay, on this machine: 0 of 60 before the change and 0 of 200 after it. That doesn't show the
natural rate is gone: 0 of 60 already says it is under about 5%, and 0 of 200 says under about 1.5%, both at 95%
confidence, no more.

The other system specs were scanned for a click followed at once (or after one statement that isn't an expectation) by a
fill or a click of a label the page being left also has; none shares the race: the second control only exists on the new
page (bulk_move, select_touch_floor "Select all"; collection_import_preview "Export file"; deck_proxies "Card name",
"Finish"; scanner_sitting "End sitting"; admin_jobs "Discard MTG::Art::BuildJob"; collection_location_filter "Remove 3
items"; deck_proxy_replacements' scripted example, whose field label has the lot's place and count), the page 1 of the
bulk pager has no "Previous" (bulk_mode), the click opens an in-page menu or dialog (narrow_bulk_pages,
collection_export, scanner_page, scanner_art), or the example runs on rack_test, where a click is synchronous
(deck_proxy_replacements' second example, deck_additions). Reviewed by Opus 5.5, read-only: SPEC-ALIGNED.

Closes #417

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@plainprogrammer
plainprogrammer marked this pull request as ready for review November 14, 2026 02:10
@plainprogrammer plainprogrammer self-assigned this Nov 14, 2026
@plainprogrammer
plainprogrammer merged commit 725e477 into main Nov 14, 2026
9 checks passed
@plainprogrammer
plainprogrammer deleted the 092-locations-rename-flake branch November 14, 2026 02:12
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.

Flaky: locations_spec renames a location to its own name when the rename page hasn't rendered (AC-1.3)

1 participant