Skip to content

Stabilize system-test sign-in without reloading - #458

Merged
str1fe merged 14 commits into
mainfrom
t3code/fix-timer-system-test
Sep 21, 2026
Merged

str1fe merged 14 commits into
mainfrom
t3code/fix-timer-system-test

Conversation

@str1fe

@str1fe str1fe commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

System tests revisited the destination immediately after signing in to clear the success notice. Sign-in now waits for the rendered notice, dismisses it through its close button, and waits for its removal before continuing on the same page. This avoids an extra navigation during Turbo's login transition.

Changes Made

  • Use Capybara's normal waiting assertions for sign-in and the existing browser interactions; keep Rails system tests, Selenium, and the transactional fixtures.
  • Disable optional notification and password-manager prompts without asserting that a password bubble caused the original CI failures.
  • Save the browser console and current URL on failure, and upload screenshots and the Rails test log under an artifact name unique to each CI attempt.
  • Enable accessible-label lookup for icon buttons and update sign-out to use the account name shown by the current UI.

How to Test

  • bin/rails test:system --seed 8657: 8 tests, 50 assertions, no failures or errors locally, against the current main UI.
  • RuboCop passes for the changed test files.
  • CI: all 265 Rails tests, the production boot check, lint, and secret scanning passed.
  • All 8 browser tests passed in four consecutive CI attempts, each with a fresh browser and a different random seed (60453, 62232, 18198, 22295). No failures, errors, or skips.

str1fe and others added 4 commits September 21, 2026 14:56
The "user starts and stops the timer" test failed on main's CI while
passing in the previous run and in ten consecutive local runs. The CI
log shows it was the first test executed in the process and failed seven
seconds after Puma started, with the screenshot showing the page still
waiting on the PATCH round trip. Capybara's five second wait was too
short for the first request against a cold server.

Poll the database for the timer state with a longer deadline before
asserting the UI, so a slow response is not mistaken for a broken timer
and a real failure reports whether the request ever reached the server.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A screenshot alone cannot show whether a form submission reached the
server or what it responded with. Attach log/test.log to the same
artifact so CI failures in the browser tests can be diagnosed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Writes the console log, whether Turbo and Stimulus initialised, the
loaded scripts and the current URL next to the failure screenshot so the
CI artifact shows what the browser saw, not only what the server logged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
sign_in_as re-visited the current path as soon as the URL had changed.
Turbo pushes the URL before it renders the response, so on a slow CI
runner the second navigation raced the in-flight visit and the test
went on to type and click in the old document. Whatever it did there
was discarded when the new document landed, which showed up as three
different flaky failures: a Start click that never submitted, a user
menu that never opened, and a typed organization name that vanished.

Wait until Turbo has cleared aria-busy on the html and form elements
before navigating again.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@str1fe str1fe changed the title Make the timer system test tolerate a cold first request Fix flaky system tests: wait for Turbo before re-visiting after sign-in Sep 21, 2026
str1fe and others added 8 commits September 21, 2026 15:20
Waiting for Turbo to settle was not enough: CI still lost the typed
organization name in the onboarding test right after the re-visit.
Selenium can return from a navigation before the new document has
replaced the one on screen, so mark the current document before the
visit and wait until that marker is gone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Reruns replaced the previous attempt's artifact, which made a flaky
failure impossible to inspect afterwards. Include the attempt number in
the artifact name and add focus, visibility, service worker and
navigation timing to the browser state dump.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The stale-document marker only proved the new document had committed.
CI still lost a typed value: the page had loaded in 138 ms, no further
request was made, yet the field was empty. A navigation to the current
URL is a reload, and Selenium returns before the new document is
complete, so the test typed while the document was still parsing and
Chrome then restored the previous form state over it.

Wait for document.readyState to be complete and for Turbo to be
attached before handing the page back to the test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
One flake remains: the onboarding test types into a field on a fully
loaded page, no request follows, and the field is empty afterwards.
Record what happens in the page after the reload so the failure dump
shows where the keystrokes went.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The in-page trace from a failing CI run showed that the click after
sign-in never reached the document at all: no click, no focus event.
The page had loaded, Turbo and Stimulus were attached, and no request
followed. Google Chrome on the runner takes part in Google's field
trials, unlike the Chromium used locally, so run the browser with
--disable-field-trial-config to make it behave the same everywhere, and
wait for two rendered frames after the reload before sending input.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The previous trace showed that a WebDriver click never produced a click
event in the document. Capture pointer and mouse events on the window,
the active element, iframes, open dialogs, inert elements, viewport
metrics and what elementFromPoint returns for the first visible button.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The extended trace from CI showed that after the reload in sign_in_as,
Chrome silently discarded every WebDriver pointer event: no mousemove,
no pointerdown, no click reached the window, while the document itself
was complete, interactive and unobstructed. Probe the page with a mouse
move after reloading and reload again if the document does not see it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The input probe showed that after sign-in, Chrome kept discarding
WebDriver input across three consecutive reloads of the same tab, and
recovered only once the next test began. That points at browser UI
outside the page rather than at the document. Chrome offers to save the
password after every login form submission; disable the password
manager, notifications and other first-run prompts for the test browser.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@str1fe str1fe changed the title Fix flaky system tests: wait for Turbo before re-visiting after sign-in Fix flaky system tests on CI: Chrome dropped input after sign-in Sep 21, 2026
@str1fe str1fe changed the title Fix flaky system tests on CI: Chrome dropped input after sign-in Stabilize system-test sign-in without reloading Sep 21, 2026
@str1fe
str1fe merged commit bc72c43 into main Sep 21, 2026
16 checks passed
@str1fe
str1fe deleted the t3code/fix-timer-system-test branch September 21, 2026 21:27
str1fe added a commit that referenced this pull request Sep 21, 2026
…llbar

Picks up the system-test fix from #458 so CI runs against current main.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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