Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
260db45 to
edd8272
Compare
edd8272 to
9109269
Compare
| }, | ||
| }, | ||
| { | ||
| id: 'switch-aria-snapshot', |
There was a problem hiding this comment.
What's the purpose of a snapshot test? Does it check a specific property listed in WCAG? Or is it adhering to specific principles?
af61e49 to
c05d474
Compare
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsSwitch (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
c05d474 to
76ee59d
Compare
… both tiers) Adds internal, unpublished @astryxdesign/aria-spec: WAI-ARIA APG patterns encoded once as data-driven conformance contracts, bound to components. - types + AriaHarness (runtime seam), jsdom (Tier 1) and browser (Tier 2) adapters - runContract with priority tiers + expectedFailures (tracked, greppable gaps) - coverage matrix (pattern x component, 0-100 score) - switch pattern authored; Switch bound in both tiers (jsdom in `pnpm test`, browser via `pnpm test:aria-browser`) - proposed gated CI job documented in internal/aria-spec/CI.md (complements the existing axe audit with behavior + pattern conformance) Prototype for #4112.
CI wiring belongs in the PR description, not a committed doc.
Every expectation now carries a required `criteria` (WCAG SC or APG clause) and prefixes its test name with the citation via specLabel(), so results trace to a specific normative requirement. Adds a "Creating a new spec test" guide to the README: principles (trace-to-clause, broad vs pattern-specific layers, Level A scoping, encode-or-excuse), a WCAG 2.2 + APG completeness checklist, tier awareness, and a definition of done.
- add switch-disabled-state and switch-disabled-not-activatable expectations (a disabled switch must expose its state and must not toggle on activation) - add a disabled-Switch binding proving both; document pattern exemptions - skill: classify each checklist row by verification method (contract / lint / browser / manual) — not every requirement is a contract expectation
APG switch must toggle on AND back off; Space and click expectations now verify both transitions, not just off->on. Closes the last contract-encodable gap from the switch a11y review.
packages/core reached into internal/aria-spec/src by relative path and
resolved `@astryxdesign/aria-spec` through a Vitest alias only, so the
package existed for the test runner but not for TypeScript. Core's
typecheck therefore failed three ways at once: TS2307 on the bare
specifier, TS6059 on the relative import (internal/ is outside core's
rootDir), and a wave of TS7006 implicit-any where the unresolved import
poisoned the result types. The same any-typed values tripped
@typescript-eslint/promise-function-async ({allowAny: false}) five times
in Switch.aria.test.tsx, which is the lint job's failure too.
Wire it the way the repo wires a package instead:
- an exports map with a `types` condition, so consumers resolve
declarations (exempt from the rootDir rule) while the test runner still
loads `src/` — no build step on the `pnpm test` path;
- `./browser` as a second entry point, keeping the Tier 2 harness (and
its Browser Mode imports) out of the jsdom tier's module graph;
- its own tsconfig + tsconfig.build.json emitting declarations only,
built first by the root `pnpm build` so the typechecks that follow it
in CI see them;
- `@astryxdesign/aria-spec: workspace:*` declared by packages/core, and
the alias crutch dropped from both Vitest configs.
Also drops a `return await` outside try/catch that @typescript-eslint/
return-await only started seeing once the types resolved.
The browser harness called `page.elementLocator(el).ariaSnapshot()`, which does not exist: Vitest's in-browser Locator has no such method (TS2339, the last build-storybook error), and Vitest exposes the accessibility tree only through the `toMatchAriaSnapshot` matcher, which asserts rather than returning the tree. The tree is Playwright's, and Playwright lives in the Node process. Bridge to it with a browser command — the supported mechanism — and let the harness address its target by marking it in the DOM. The accessible name now comes from that same real tree instead of an aria-label/ textContent guess that reported a labelled `<input role="switch">` as nameless. Three fixes the tier needed before it could run at all, all found by actually running it (`pnpm test:aria-browser`, real Chromium): - the command must locate through the tester `iframe`, not the orchestrator page, or it waits forever for a selector that is not there; - `render` from vitest-browser-react 2.x is async, so setup has to await it (the old `void render(...)` raced every first query); - the binding passed no `teardown`, so mounts piled up and every role query hit a Playwright strict-mode violation from the second expectation on. Cleanup between expectations, as in the jsdom tier. Also pins React in the browser config: without dedupe/optimizeDeps the run loaded two React copies and every render threw "Cannot read properties of null (reading 'useId')". Tier 2 now passes end to end; the aria-snapshot expectation is a real pass in Chromium and stays a tracked gap in jsdom. The stale @ts-expect- error directives (TS2578) go with it, and the header no longer claims a CI job that does not exist.
76ee59d to
4250fc4
Compare
|
Closing this. Since July the rubric, the score ledger and Night Watch own per-component a11y coverage with screenshots, and on Switch — the reference binding — everything this contract asserts is already in await user.keyboard(' ');The two it can't do in jsdom are |
Prototype for #4112 — proving the ARIA-spec architecture end-to-end on one pattern (Switch) before authoring the rest.
What this is
An internal, unpublished
@astryxdesign/aria-specpackage that encodes WAI-ARIA APG patterns once as data-driven conformance contracts, then binds components to them — so "which APG patterns are covered, across which components?" is a coverage matrix, not assertions scattered across ~120 test files.The core idea: one contract, two tiers
Expectations are authored against an abstract
AriaHarness, so the same contract runs in:createJsdomHarness): Testing Library + user-event. Fast, runs in the existingpnpm test. Covers role/name/state/keyboard-logic.createBrowserHarness): Vitest Browser Mode + Playwright. Covers what jsdom can only fake — the real accessibility tree (toMatchAriaSnapshot), focus trapping,inert, top layer,:focus-visible.Fidelity-critical expectations (e.g.
switch-aria-snapshot) are a tracked gap in Tier 1 and pass in Tier 2 — the same contract, honest about what each runtime can prove.expectedFailures— adoption without a wall of redA binding declares known gaps by expectation id; each is an explicit, greppable line, not a missing test. A gap that later passes surfaces as
unexpected-passso stale entries get cleaned up. This is what lets the contract roll across all 122 components immediately.What's here
AriaHarnessseaminternal/aria-spec/src/types.tssrc/harness/*src/runner/runContract.tssrc/report/coverage.tssrc/patterns/switch.tspackages/core/src/Switch/Switch.aria*.test.tsxinternal/aria-spec/CI.mdVerified
uiproject:[100%] switch/Switch (6/8, jsdom) — 2 known-gapswitch-labelled,switch-1(Space),switch-click-toggles,switch-focusableas blocking failuresSwitch.test.tsx(40 tests) still green; browser test correctly excluded from the jsdom projectpnpm add -Dw @vitest/browser @vitest/browser-playwright vitest-browser-react && pnpm exec playwright install --with-deps chromiumon a runner that can fetch the binary (couldn't complete in the dev sandbox)Relationship to existing a11y CI
The existing
pr-a11yjob already runs axe (static rules) against Storybook. aria-spec complements it with behavior + pattern conformance (keyboard, focus, real aria tree) — axe cannot do any of that. The proposed Tier 2 job (inCI.md) is gated on component changes, Chromium-only, cached, and should gate the build only onblockerexpectations.Not in this PR (follow-ups from #4112)
vitest-axestructural pass wired into the runnerswitch-1,checkbox-42,menus-*) into contractsKept as a draft for architecture review before scaling to all patterns.