test(webviews): U1 waits for conditions, not fixed times (114 waits)
Merged
TE
16d ago+428+428+012345678901234567890123456789-221-221-012345678901234567890123456789
Part of the fixed-wait sweep that followed the ratchet in #23365. This PR removes 114 fixed-time waits from 20 webview unit-test files, counted against current feat-cmux-next.
- Hover and dwell delays run on bun:test's fake timers. These cover the session hover card, the sidebar preview, the minimap turn preview, the URL chip grace, the settings backdrop and theme dwell, the scroll anchor settle, the warm New Tab post, and the prompt delivery deadlines. Each test checks that the behavior is absent one tick before its delay and present at it, so a slow runner can't change the result.
- Async results are awaited with bounded
untilloops. Each loop yields withsetTimeout 0and fails with a message naming what it waited for. This covers shell reads, sign-in polls, client reconnects and resyncs, pasted image chips, KaTeX and diagram rendering, the code-card handoff, changelog and settings host calls, and menu picks. - The settings claim-paint test counts calls and stream events in flight and waits until all are delivered, instead of waiting 300 ms.
- Left for a follow-up: the 3 reveal-frame waits in
transcript-switch-back.test.tsxwill move to the shared post-paint helper from #23374.
It also carries #23414 (the base-red marker fix), which drops out once that merges.
Verification: an independent subagent review said SHIP. Each changed file passed 3 runs of bun test, and bun run check passes, including check:fixed-waits (878 on the baseline).
Agent session: huge-blue
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Removes 114 fixed-time waits from 20 webview unit-test files, so a loaded runner that wakes a wait late can no longer change a test's result.
- Hover and dwell delays run on bun:test's fake timers; each test checks the behavior is absent one tick before its delay and present at it.
- Async results are awaited with bounded
untilloops that yield withsetTimeout 0and fail naming what they waited for. - The fixed-wait check now also counts waits inside helpers, block-body timer callbacks, and exported helpers, so a new wait anywhere raises the count.
- The settings claim-paint test counts calls and stream events in flight and waits until all are delivered.
- The 3 reveal-frame waits in
transcript-switch-back.test.tsxstay for a follow-up to the shared post-paint helper, and the baseline ratchet is lowered accordingly.