test(frontend): wait for the first poll tick before jumping the clock in the give-up test (#395) #541
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/395-poll-test-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes the flake that failed the merge run for #538 (run 947,
WikiDraftReview.test.jsx:491, "stops claiming the draft is generating once it has waited too long").Root cause, not a timing margin. The test jumps
Date.now()ten minutes ahead as soon asrenderReviewresolves. The poll's deadline is captured in a passive effect (startedAt = Date.now()inside the polluseEffect), and on a loaded runner that effect can flush afterrenderReviewhas resolved, becausefindByTextfires on the DOM mutation while passive effects are scheduled behind it. When that ordering happens, the deadline is set at the jumped time,Date.now() - startedAtis never over three minutes, and the give-up banner cannot appear no matter how long the test waits. PR #529 widened the final wait to 20 s, which could never close that gap.Fix. Wait for one real poll tick (the mock's call count rises) before moving the clock; that proves the interval and its deadline exist. Then the next tick sees the jump. Three consecutive local runs of the file pass; the comment in the test explains the ordering for the next reader.
Only the test file changes.
🤖 Generated with Claude Code