fix(test): stabilize flaky file-browser follow test - #81
Conversation
There was a problem hiding this comment.
Pull request overview
This PR stabilizes a flaky integration test for IntegratedFileBrowser directory-following behavior by ensuring the test waits for the follow navigation to commit before performing a Home navigation, and by strengthening assertions to confirm the Home click triggers a distinct load.
Changes:
- Wait for the follow directory (
/srv/app) to render in the breadcrumb before clicking Home to prevent a no-op navigation race. - Replace a “called with” assertion with an explicit call-count assertion to ensure the Home action triggers its own
/homeload (in addition to the mount safety-net load).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
GOODBOY008
left a comment
There was a problem hiding this comment.
Review: verified against the linked CI failure (run 31673056116)
Reproduced the failure on main @ 9a5ec2f. The linked run failed on windows-latest with TestingLibraryElementError: Unable to find an element with the title: /home. in IntegratedFileBrowser terminal directory following > returns to the same terminal directory after manual navigation on the next prompt (5234ms) — despite the timeout: 5000 / 15000 band-aids already on main (#83/#84). Confirms the flake is event ordering, not slowness.
Root cause checked against the component code (integrated-file-browser.tsx):
navigateToearly-returns onpath === currentPath(line 708) — clicking Home whilecurrentPathis still the initial/homeis a silent no-op.- The follow load commits
setCurrentPath('/srv/app')only after its invoke resolves (lines 632–634) — that's the race window. - The mount safety-net load (
/home) satisfies a baretoHaveBeenCalledWith('/home'), masking the no-op. Analysis is accurate.
Fix verified empirically (same 0–30ms jitter on the /srv/app invoke as described in the PR body):
- base
9a5ec2f+ jitter: 20/25 pass, 5 failures with the exact CI error signature. - PR head + jitter: 25/25 pass.
- Full suite on PR head: 565/565 pass.
Merge check: 3-way merge-tree of main + PR head is conflict-free. The merged result keeps both the ordering fix and main's generous timeouts (they coexist — the PR predates those commits, so nothing is silently dropped). The count assertions are deterministic: exactly one mount /home load (main load effect skips on mount via prevConnectionIdRef) + one from the Home navigation.
Non-blocking: the branch is 3 commits behind main (#82/#83/#84). The merge is clean, but a rebase would let CI validate against the latest main before merging.
The "returns to the same terminal directory after manual navigation on
the next prompt" test flaked intermittently on Windows and macOS CI at
findByTitle('/home'): the follow load of /srv/app and the mount
safety-net load of /home race, and if the follow's setCurrentPath had
not committed when the test clicked Home, navigateTo('/home') no-ops on
the initial '/home' state. The waitFor for the /home call then passes
spuriously via the mount's safety-net call, and the pending follow load
lands on /srv/app — so findByTitle('/home') times out.
Reproduced locally with a 0-30ms jitter on the follow invoke: 14/30
failures on the original test, 0/30 with this fix.
- Wait for the follow to fully commit (breadcrumb renders /srv/app)
before clicking Home, so the navigation can't no-op.
- Require the Home click to trigger its own load (2 /home calls: mount
safety-net + navigation) instead of a bare "called with".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5b5f5a2 to
897733b
Compare
Problem
The
returns to the same terminal directory after manual navigation on the next prompttest inintegrated-file-browser-keyboard.test.tsxflakes intermittently on Windows and macOS CI (3 observed failures) atfindByTitle('/home')— the same file has a documented history of timing flakes (prior fix infc2ff27).Root cause
On mount, two loads race:
/home(initialcommittedPathRef), and/srv/app(fromterminalWorkingDirectory).If the follow's
setCurrentPath('/srv/app')hasn't committed when the test clicks Home:navigateTo('/home')no-ops —currentPathis still the initial/home, andnavigateToearly-returns onpath === currentPath.waitFor('/home' called)passes spuriously via the mount's safety-net call (it only checks "called with", not count)./srv/app, sofindByTitle('/home')times out.This window is microtask-tight, which is why it only manifests under CI CPU contention.
Fix
findByTitle('/srv/app')) before clicking Home — so the navigation can't no-op./homecalls: mount safety-net + navigation) instead of a bare "called with", which the mount call alone satisfies.Verification
tscclean.🤖 Generated with Claude Code