Stabilize system-test sign-in without reloading - #458
Merged
Merged
Conversation
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>
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
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>
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.
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
How to Test
bin/rails test:system --seed 8657: 8 tests, 50 assertions, no failures or errors locally, against the current main UI.