Skip to content

Fix intermittent login navigation race in feature specs - #2847

Open
mroderick wants to merge 1 commit into
masterfrom
fix/login-auth-navigation-race
Open

Fix intermittent login navigation race in feature specs#2847
mroderick wants to merge 1 commit into
masterfrom
fix/login-auth-navigation-race

Conversation

@mroderick

Copy link
Copy Markdown
Collaborator

Fixes an intermittent feature-spec failure where a request issued straight after login(member) resolved to the OAuth chain's landing page instead of the requested path.

Observed in #2846's CI run (34213281043): accepting_terms_and_conditions_spec.rb expected /dashboard after visit dashboard_path but got / - the page the auth redirect chain lands on. The run was not deterministic: the same job passed on re-run and the full suite passed four times locally with CI's seed (8255).

Root cause: LoginHelpers#login returns once visit '/auth/codebar' has committed navigation, but the OAuth redirect chain can still be in flight. A visit issued immediately after can race it and land on the chain's destination instead of the requested path.

Fix: login() now waits for #navbarDropdownMenuLinkMember - the member nav toggle, rendered only once the session is established - before returning. The wait resolves as soon as the chain settles, so it adds no measurable time to passing runs.

Details:

Why this fix point

login() is the shared helper for all feature specs, so fixing it there covers the whole flake class rather than only the spec that happened to fail. Verified: the targeted spec passes 5/5 runs with CI's seed, and the full suite passes with the change (1308 examples, 0 failures). RuboCop clean.

login() returned once the OAuth redirect chain had committed
navigation, but a request issued straight after could still race the
chain and resolve to its landing page instead. That surfaced as an
intermittent failure in accepting_terms_and_conditions_spec, where
visiting /dashboard right after login landed on /.

Wait for the member nav, which is only rendered once the session is
established, before returning from login().
@mroderick
mroderick marked this pull request as ready for review September 8, 2026 10:57
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