Skip to content

Commit cd6cc0c

Browse files
committed
Poll for self-driven snow frames instead of a fixed sleep
1 parent 13f05f2 commit cd6cc0c

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

src/tui/landing.test.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,24 @@ describe("landing screen", () => {
274274
await settle(h)
275275
const before = markRows(h).join("\n")
276276

277-
// Real wall-clock wait, no renderOnce in between: only the mount's
278-
// own idle-repaint timer can be advancing the snow here. `flush`
279-
// waits on the renderer's own scheduler settling rather than
280-
// forcing frames, so it does not manufacture the motion itself.
281-
await new Promise((resolve) => setTimeout(resolve, 3_000))
282-
283-
await h.flush()
284-
const after = markRows(h).join("\n")
277+
// Poll until the product's own idle-repaint timer moves the snow, or
278+
// until a deadline. A single fixed sleep-then-check races the timer
279+
// under CI load (CL-5766): when the interval is delayed past the
280+
// sleep, `flush` finds nothing scheduled and the capture is still
281+
// the mount frame. Polling keeps the property intact — nothing here
282+
// calls `paintLanding`/`renderMark`/`renderOnce`, so a frozen timer
283+
// still fails — while early exit drops the average suite cost below
284+
// the old fixed 3s wait.
285+
const deadline = performance.now() + 5_000
286+
let after = before
287+
while (performance.now() < deadline) {
288+
// Drain any render the product already scheduled; do not force one.
289+
await h.flush()
290+
after = markRows(h).join("\n")
291+
if (after !== before) break
292+
// Yield so the mount-scoped interval can fire; not a frame pump.
293+
await new Promise((resolve) => setTimeout(resolve, 50))
294+
}
285295

286296
expect(after).not.toBe(before)
287297

0 commit comments

Comments
 (0)