Repository navigation
test(docs): wait for the popover's deferred toggle, not a fixed 10 ms - #113
Merged
Merged
Conversation
The click and Escape stand-ins call toggle() in a microtask, after the 10 ms timer is set, so a slow run could end the wait before the deferred toggle fired. The tests now wait until no deferred toggle is left, and afterEach clears any timer still pending, so none fires on the next test's unmounted popover. Co-authored-by: multica-agent <github@multica.ai>
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://popover-toggle-wait-uxf-1041.opencomponents.dev, https://popover-toggle-wait-uxf-1041-opencomponents.uxfront.workers.dev (commit d0d1e9c)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
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.
What changed
Three Popover tests waited a fixed 10 ms for the
togglethat the test's stand-in for the Popover API defers, like Chrome does. The click and Escape stand-ins only calltoggle()in a microtask, which runs after that 10 ms timer is set, so on a slow run, like the first one after a clean install, the wait ended before thetogglefired. "collapses the last trigger when another one opens it again before the browser says it closed" then failed, and its leftover timer fired in the next test, on a popover that test had unmounted, as an unhandledTypeError.The tests now wait with
toggled(), which waits a task at a time until no deferredtoggleis left, andafterEachclears any timer still pending. The Popover page shows the samePopover.test.ts. No change to the component. A 15 ms stall added to the click and Escape stand-ins makes the old test fail with both errors, and the new one pass.Checklist
feat(docs): add the focus guideline.pnpm check-typespasses.pnpm dev. (Only thePopover.test.tscode block changed, andpnpm check-referencepasses.)pnpm build, thenpnpm lighthouse, still scores 100 in every category. (No homepage changes.)