Skip to content

test: real-browser component tests with Playwright on the docs site (#25) - #59

Merged
YaelAnaya merged 1 commit into
mainfrom
test/25-playwright-browser-tests
Dec 5, 2026
Merged

YaelAnaya merged 1 commit into
mainfrom
test/25-playwright-browser-tests

Conversation

@YaelAnaya

Copy link
Copy Markdown
Contributor

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/test 1.65.2, an exact devDependency. It uses Chromium build 1255.
  • Fixture pages: the site now builds /test/<component>/<story>/ for every demo, which adds 343 pages. Each renders one demo alone, through a DemoHost island that imports all demos, inside the normal Base layout so the stylesheet, theme script and Toaster are there. The docs pages keep their per-demo islands.
  • playwright.config.ts: webServer builds the package, generates the API and builds the site, then serves it with astro preview on port 4329. Outside CI it reuses a running server, so reruns are fast. Traces and screenshots are kept on failure, and test-results/ and playwright-report/ are gitignored.
  • tests/browser/fixture.ts: openDemo() waits for hydration, which Astro signals by removing ssr from the islands, so no test acts on dead SSR markup.
  • pnpm test:browser. Wiring it into CI and verify is [16] QA-05 · Extend verification commands and CI with the new suites #29.

What it covers (19 tests)

Spec Behaviour
overlays.spec.ts Dialog, Sheet (all four sides) and Drawer: focus moves in, Tab stays in for 12 presses, Escape closes, focus returns to the trigger. Dialog also closes on an outside click
menus.spec.ts DropdownMenu: keyboard open, arrows, Escape returns focus, and after an outside click the trigger reopens it on the next press (no exit animation, DESIGN Motion). ContextMenu on right-click. Select keyboard pick. Combobox filtering by typing. Popover focus in and out. Tooltip on keyboard focus and Escape. HoverCard on hover. Every surface checked to sit inside the viewport
layout.spec.ts Table and ScrollArea scroll inside themselves at 375 px, while the page doesn't scroll sideways. Sidebar is a panel on desktop and a Sheet on a phone. Reduced motion: the dialog's animation-duration is above 0.01 s with no preference and below 0.001 s under reduce

Selectors are by role and accessible name. data-slot is 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.

Both are also live proof that the specs fail on a real defect, which the issue wanted shown with a seeded change.

Stability

  • One race found and fixed properly: a key sent before Radix Select focused its option was lost. The test now waits for that focus, not for time. Afterwards the Select test passed 40/40.
  • 10 consecutive full runs: all passed.
  • --repeat-each=10 in parallel: 170/170. The test.fail cases count as expected failures.
  • A single run takes about 10 s once the site is built.

Docs

  • CONTRIBUTING gets a Scripts row and a Tests paragraph on writing browser tests: fixtures, selectors, state-based waits, the test.fail + issue convention, and the playwright install chromium first step.
  • AGENTS.md gets a commands row.
  • DESIGN gets a Verification row.
  • The component development skill's step 12 now includes pnpm test:browser.

Testing evidence

  • pnpm format:check ✓
  • pnpm lint (typechecks playwright.config.ts and the specs) ✓
  • pnpm test: 235 ✓
  • pnpm docs:check ✓, 405 pages
  • pnpm test:browser: 17 passed + 2 expected failures, exit 0

Not in this PR

Public API / dependency changes

No change to the package. One devDependency (@playwright/test).

@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
@YaelAnaya YaelAnaya added area: testing Automated verification area: accessibility Accessibility and interaction semantics type: testing Testing infrastructure and coverage labels Dec 5, 2026
@YaelAnaya YaelAnaya self-assigned this Dec 5, 2026
@YaelAnaya
YaelAnaya merged commit 758b9f8 into main Dec 5, 2026
1 check passed
@YaelAnaya
YaelAnaya deleted the test/25-playwright-browser-tests branch December 5, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: accessibility Accessibility and interaction semantics area: testing Automated verification type: testing Testing infrastructure and coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[12] QA-03 · Real-browser component tests with Playwright on the Astro catalog

1 participant