Repository navigation
test: real-browser component tests with Playwright on the docs site (#25) - #59
Merged
Merged
Conversation
@playwright/test 1.65.2 (exact, Chromium 1255) drives fixture pages the docs site now builds, /test/<component>/<story>/, each rendering one demo alone through a DemoHost island, from the real package. playwright.config.ts builds the package and the site and serves it with astro preview (reusing a running server outside CI); pnpm test:browser runs it. 19 specs cover what jsdom cannot: Dialog, Sheet and Drawer moving focus in, trapping Tab, closing on Escape and outside click and returning focus; DropdownMenu, ContextMenu, Select, Combobox, Popover, Tooltip and HoverCard opened by keyboard and pointer, kept inside the viewport and handing focus back (and a menu reopening on the next press, with no exit animation); Table and ScrollArea scrolling inside themselves at 375px; the Sidebar becoming a Sheet below 768px; animations collapsing under reduced motion. Role and name selectors, data-slot only where there is no role, and waits on state, never on time. The suite found two real defects, each now an issue, with its test kept and marked test.fail() until it is fixed: a Drawer leaves focus on its trigger (#57), and on a phone the first Escape closes an invisible tooltip instead of the Sidebar's Sheet (#58). Stable: 10 consecutive full runs, and every test repeated 10 times in parallel (170/170), after replacing one race (a key sent before Radix Select focuses its option) with a wait on that focus. Documented in CONTRIBUTING (scripts, how to write browser tests), AGENTS.md, DESIGN's verification table and the component development skill. Closes #25
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.
Summary
Adds a real-browser test suite (Playwright, Chromium). It runs against the docs site the repo already builds, so there is no new docs or test framework.
Closes #25.
How it works
@playwright/test1.65.2, an exact devDependency. It uses Chromium build 1255./test/<component>/<story>/for every demo, which adds 343 pages. Each renders one demo alone, through aDemoHostisland that imports all demos, inside the normalBaselayout so the stylesheet, theme script and Toaster are there. The docs pages keep their per-demo islands.playwright.config.ts:webServerbuilds the package, generates the API and builds the site, then serves it withastro previewon port 4329. Outside CI it reuses a running server, so reruns are fast. Traces and screenshots are kept on failure, andtest-results/andplaywright-report/are gitignored.tests/browser/fixture.ts:openDemo()waits for hydration, which Astro signals by removingssrfrom the islands, so no test acts on dead SSR markup.pnpm test:browser. Wiring it into CI andverifyis [16] QA-05 · Extend verification commands and CI with the new suites #29.What it covers (19 tests)
overlays.spec.tsmenus.spec.tslayout.spec.tsanimation-durationis above 0.01 s with no preference and below 0.001 s underreduceSelectors are by role and accessible name.
data-slotis used only where there is no role (overlay, scroll container, hover card). Every wait is on a state (toBeFocused,toBeVisible,toHaveCount), never on time.Real defects found
The suite caught two bugs that jsdom can't see. Each is filed, and its test stays in the suite, marked
test.fail()with the issue URL. It will turn red the day the bug is fixed, which forces removing the marker.autoFocusis off and the wrapper doesn't set it.hiddenon mobile. The first Escape closes that tooltip and only the second closes the Sheet. Traced from the open layers before and after each Escape.Both are also live proof that the specs fail on a real defect, which the issue wanted shown with a seeded change.
Stability
--repeat-each=10in parallel: 170/170. Thetest.failcases count as expected failures.Docs
test.fail+ issue convention, and theplaywright install chromiumfirst step.pnpm test:browser.Testing evidence
pnpm format:check✓pnpm lint(typechecksplaywright.config.tsand the specs) ✓pnpm test: 235 ✓pnpm docs:check✓, 405 pagespnpm test:browser: 17 passed + 2 expected failures, exit 0Not in this PR
Public API / dependency changes
No change to the package. One devDependency (
@playwright/test).