Repository navigation
test(e2e): steady the debounced-search and script-await tests - #49
Merged
Merged
Conversation
The debounced search test typed three keys 50 ms apart and expected one search, but on a loaded CI machine the typing took over a second, so the 400 ms debounce fired between keys. The page's clock is now paused while typing. The Suspense script-await test's Mount click has left the toggle off on CI, with the page hydrated and settled. It now uses setPressed, which presses again until the toggle sticks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Steadies the two e2e tests that have failed CI on and off since 8 October. Between them they caused 6 of the recent red runs on
mainand on PRs. Only test files change.The other recent red runs were real bugs, since fixed: the "registry is disposed" unit-test failures were fixed by #47, and the phone search-button test failed in all three browsers at once. Failures from before 6 October are in tests that have since been given a paused clock.
1. Cookbook › debounced search: quick key presses run one search
Failed twice in WebKit (run 38045417859, run 37867595813). The Cookbook example debounces a search box.
Atom.debounce(from Effect'seffect/reactivity) passes a value on only after it has stopped changing for 400 ms:The test types
schwith 50 ms between keys and expects one search:Bug: the test saw 2 searches (and once only 2 key presses counted). The trace shows typing the three keys took 1.34 s on the loaded CI machine instead of about 150 ms, so more than 400 ms passed between two keys and the debounce fired mid-word. The library behaved correctly; the test depended on wall-clock time.
Fix: pause the page's clock while typing, then let it run. Playwright's
page.clockfakes the page's timers, so a slow machine can't push the debounce past its delay. Several tests indemo.test.tsalready do this.To check the fix, I ran a copy that waits 600 ms between keys, longer than the debounce. The old test fails it ("Expected 1, Received 3"). The new one passes in Chromium and WebKit.
2. Suspense › useAtomResult waits in the script once, then current follows the atom
Failed four times, in WebKit and Firefox (38059263780, 38000309250, 38011590299, 37859559427). The Suspense page's "Awaiting in the script" example has a toggle button that mounts a
<Notes>component. That component awaitsuseAtomResultin its<script>inside a<svelte:boundary>:Bug: after
mount.click(), nothing happened for the next 5 s. The button stayedaria-pressed="false", the box still said "Not mounted.", and the pending snippet never appeared. The traces show:<html data-hydrated>1.6 s before the click;$effect.pending()at 0;I couldn't reproduce it locally. I tried 60 plain runs, 48 parallel runs, CPU throttled 4–12×, and clicks timed across a 300 ms window around the page's slowest await resolving. Every click mounted the component.
Fix: use the existing
setPressedhelper (e2e/toggle.ts) for the three mount and unmount clicks. It presses, waits up to 1 s foraria-pressedto change, and presses again if it didn't. The Async atoms test already uses it for the same symptom.Decisions
Tests
Where to look in the diff
apps/demo/e2e/cookbook.test.ts:debounced search: quick key presses run one searchapps/demo/e2e/features-async.test.ts:useAtomResult waits in the script once, then current follows the atom🤖 Generated with Claude Code