Fix flaky New Tab style switch web test
webviews/test/new-tab-style-switch.test.tsx:68 ("offers its five styles as radios", fieldAsked 1 vs 0) failed about 1 run in 3 on feat-cmux-next and turned PR web gates red. It came in with #20336.
The race was in the test. After a click, the style switch asks for the location field on the next animation frame. The test checks that nothing was asked yet once the click's act() returns. JSDOM's requestAnimationFrame is a real 16 ms timer, so when that act() took longer than a frame on a loaded runner, the frame had already fired and the count was 1.
The test now queues frames and runs them itself. It checks 0 after the click and 1 after one frame, and nothing depends on timing. No retries were added, and the component is unchanged.
Local runs of the focused file (bun test test/new-tab-style-switch.test.tsx):
- base: 2 of 30 failed with
Expected: 0, Received: 1 - this branch: 0 of 40 failed
bun run check passes.
The Swift NewTabStyleSwitchTests red is owned separately and not touched here.
Changelog
none
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Fixes the flaky New Tab style switch web test so PR web gates stop failing intermittently.
- The test now queues
requestAnimationFramecallbacks and runs them only when the test asks, instead of relying on JSDOM's 16 ms frame timer. - The test still checks that no field is asked after the click and one more after one frame, but no longer depends on timing.