Repository navigation
Description
Summary and impact
apps/frontend/src/auth/AuthDialog.test.tsx › "resets a known account, reports unknown ones and returns to sign-in" fails intermittently at expect(back).toHaveFocus() (:248, "Return to sign in"; focus found on <body>) under the full parallel Vitest suite. A flaky required unit gate can block PRs or mask real regressions. If focus is really lost in a browser, it is also a keyboard-accessibility defect in the auth dialog (spec §6.8).
Delivery phase
Phase 1 — frontend with mocks (F2 auth dialog follow-up).
Steps to reproduce
In the workspace container (full suite, parallel workers):
docker compose -p lca-diff-auth51 exec -T workspace bash -lc 'cd apps/frontend && for i in $(seq 1 60); do npx vitest run > test-results/auth51/run-$i.log 2>&1 || { echo "fail on run $i"; break; }; done'(mkdir -p test-results/auth51 first.) The file alone (npx vitest run src/auth/AuthDialog.test.tsx) passes 13/13, so load is part of the trigger.
Expected behavior and authority
After the simulated reset is reported, focus moves to "Return to sign in" deterministically, in jsdom and in real browsers; the unit suite is deterministic (spec §6.8 keyboard accessibility and focus; §9.2 tiered CI; AGENTS.md correctness and quality gates).
Actual behavior
About 1 failure in 40–60 full runs: dbc5ff0 (1/60), main 1f82774 (run 19 of 40), and once in an extra instrumented full run during #26 QA at 95b58d2 (load ~4.1; #26 (comment)). Never seen with the file alone.
Leads (not conclusions): AuthDialog.tsx focuses returnRef in an effect when sentTo is set (:328), and other paths focus [data-initial-focus] (:595, :644) or emailRef; the test's findByText can resolve on the alert text before or after that effect, and the jsdom showModal stub in src/test/setup.ts focuses the dialog's first button.
Environment and version
Rootless workspace container; Node 24.22.3, Vitest 5.1.0, jsdom 31.0.1, React 19.3.1. Mock auth adapter.
Context and dependencies
Introduced with #13 (AuthDialog); found by QA on #16 (F-6). Scheduling dependency: starts after the #76/#87 PR merges, because the reproduction and the 60-run criterion depend on the unit suite's load profile, which #76 changes. Then branch from the new main.
Acceptance criteria
- AC1 Reproduce or characterize before fixing: record the failure count from the loop (up to 60 runs) at the starting
mainSHA, and a temporary, uncommitted focus trace (focusin/focusoutwith target and timestamp, plus the order of the reset state update and the focusing effect) from at least one failing run or a forced-timing variant. - AC2 Root cause stated with that evidence: test synchronization (focus is set correctly, but after the test reads it) or product behaviour (focus can land on
<body>or move away). - AC3 Fix without weakening: the test still requires focus on "Return to sign in" before it clicks it, and keeps every other assertion. A test-only fix (e.g. waiting for focus) is acceptable only if AC2 shows the product sets focus deterministically; if the product can lose focus, fix
src/auth/AuthDialog.tsxand add a regression test that fails on the pre-fix code (record the failure). - AC4 Browser evidence:
e2e/auth.spec.ts(existing or extended) asserts focus on "Return to sign in" after the simulated reset in Chromium and Firefox. - AC5 60 consecutive full
npx vitest runpasses in the container at the delivered SHA, starting at 1-min load ≤ 2.0 with no other container test suite running (record loads); noretry. - AC6 Gates: frozen
npm ci, format:check, lint, typecheck,test:unit, build,@smoke, and fulltest:e2eif product code changed; hostedqualitypasses.
Regression and verification plan
git -C /home/david/projects/LCA-diff fetch origin
git -C /home/david/projects/LCA-diff worktree add -b fix/51-authdialog-focus /tmp/lca-diff-auth51 origin/main
cd /tmp/lca-diff-auth51
ss -ltn | grep ':5225 ' && echo 'port 5225 busy - pick another and record it'
COMPOSE_PROJECT_NAME=lca-diff-auth51 FRONTEND_PORT=5225 ./dev up
COMPOSE_PROJECT_NAME=lca-diff-auth51 FRONTEND_PORT=5225 ./dev check
docker compose -p lca-diff-auth51 exec -T workspace bash -lc 'cd apps/frontend && npm ci --no-audit --no-fund && mkdir -p test-results/auth51'
# AC1/AC5 loop: see Steps to reproduce
docker compose -p lca-diff-auth51 exec -T workspace bash -lc 'cd apps/frontend && npm run format:check && npm run lint && npm run typecheck && npm run build && npm run test:e2e -- e2e/auth.spec.ts --reporter=list && npm run test:e2e -- --grep @smoke'
COMPOSE_PROJECT_NAME=lca-diff-auth51 ./dev downThe 60-run loop takes about 1.5–2 h; it counts toward the host's two-suite limit, so the coordinator schedules it when at most one other suite runs, and AC5's runs when none does.
Out of scope and follow-ups
Other flaky tests get their own issues. Auth contract or flow changes beyond focus handling. Real Firebase auth (I1).
Activity
DavidVFitzGerald commentedon Nov 15, 2026
QA occurrence during #26 re-verification at
95b58d2. In an extra, instrumented full parallel unit run (not one of the three gate runs; load about 4.1),src/auth/AuthDialog.test.tsx› "resets a known account, reports unknown ones and returns to sign-in" failed itstoHaveFocus()on "Return to sign in": focus was on<body>. Rerunning that file alone passed 13/13. It did not occur in the three consecutive gate runs, which were 405/405 each. Details: #26 (comment)🤖 Generated with Claude Code
DavidVFitzGerald commentedon Nov 15, 2026
PM: BLOCKED (groomed; waiting on a scheduling dependency)
AuthDialog.tsxand add a regression test shown to fail before the fix.e2e/auth.spec.ts(Chromium and Firefox).fix/51-authdialog-focusfrom the newmain. Worktree/tmp/lca-diff-auth51, projectlca-diff-auth51, port 5225 (free at grooming; recheck withss -ltn).App.tsxorApp.test.tsx, mergeorigin/mainafter F5: add independent indicator tree and selection (#27) #88 lands.Next action: when the #76/#87 PR merges, the coordinator comments "dependency met at
<main SHA>". The issue is then READY with no other change.🤖 Generated with Claude Code
DavidVFitzGerald commentedon Nov 16, 2026
Coordinator: dependency met at
eea972f(PR #94 merged), so this is now READY. The Engineer starts next.🤖 Generated with Claude Code