Skip to content

test(docs): wait for the popover's deferred toggle, not a fixed 10 ms - #113

Merged
alexgrozav merged 1 commit into
mainfrom
popover-toggle-wait-uxf-1041
Nov 24, 2026
Merged

alexgrozav merged 1 commit into
mainfrom
popover-toggle-wait-uxf-1041

Conversation

@alexgrozav

Copy link
Copy Markdown
Contributor

What changed

Three Popover tests waited a fixed 10 ms for the toggle that the test's stand-in for the Popover API defers, like Chrome does. The click and Escape stand-ins only call toggle() 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 the toggle fired. "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 unhandled TypeError.

The tests now wait with toggled(), which waits a task at a time until no deferred toggle is left, and afterEach clears any timer still pending. The Popover page shows the same Popover.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

  • The title follows Conventional Commits, as in feat(docs): add the focus guideline.
  • pnpm check-types passes.
  • Docs changes: the pages read well on pnpm dev. (Only the Popover.test.ts code block changed, and pnpm check-reference passes.)
  • Homepage changes: pnpm build, then pnpm lighthouse, still scores 100 in every category. (No homepage changes.)

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>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 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 deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://62f60f1d.opencomponents.dev, https://62f60f1d-opencomponents.uxfront.workers.dev d0d1e9c 2026-11-24T10:29:34.172Z Visit the dashboard ↗

@alexgrozav
alexgrozav marked this pull request as ready for review November 24, 2026 12:03
@alexgrozav
alexgrozav merged commit 55d7667 into main Nov 24, 2026
5 checks passed
@alexgrozav
alexgrozav deleted the popover-toggle-wait-uxf-1041 branch November 24, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant