Skip to content

test: check composites against their WAI-ARIA patterns with checkPattern (#27) - #65

Merged
YaelAnaya merged 1 commit into
mainfrom
test/27-pattern-tests
Dec 5, 2026
Merged

YaelAnaya merged 1 commit into
mainfrom
test/27-pattern-tests

Conversation

@YaelAnaya

Copy link
Copy Markdown
Contributor

Summary

Checks 16 composites against their WAI-ARIA APG pattern with UI SDK's checkPattern (@ui-sdk/core/testing). It checks roles, names, states, id references and the pattern's keys, and requires that focus never falls to <body>. The components stay as they are, as ADR 0001 section 2 says.

Closes #27.

Status per component

Component Pattern Status
Accordion, Collapsible, Checkbox, Switch, Slider, Dialog, DropdownMenu, Combobox accordion, disclosure, checkbox, switch, slider, dialog, menu, combobox ✅ pass
ContextMenu menu ✅ passes with a focusable trigger (tabIndex={0}). The demos use non-focusable triggers, so keyboard users can't open them. Noted on #39
Tabs tabs Radix's roving-focus container takes Tab and forwards focus. A real Tab lands on the active tab (behaviour test)
RadioGroup radio-group As Tabs. Also, Radix checks a radio only while the arrow is held, and checkPattern presses and releases in one tick. The behaviour test proves a real key press checks it
ToggleGroup (single) radio-group As RadioGroup. A horizontal Radix ToggleGroup also ignores ↑/↓, which the APG radio group accepts
Select combobox Radix moves DOM focus into the listbox instead of using aria-activedescendant. A deviation of the primitive that ADR 0001 keeps
Command (inline) combobox No popup for Escape to close: the list is always shown. Escape belongs to CommandDialog
CodeBlock (tabs) tabs One panel is shared by all tabs and labelled only by the selected one: #35
DestructiveActionModal dialog Focus is lost on close: #64 (new)

Not applicable: menubar, toolbar and tree, since no component implements them. Standalone listbox, since Select and Command cover its use. Alertdialog, since none renders one; whether DestructiveActionModal should is a question on #39.

A real bug: #64

A Dialog opened without a DialogTrigger leaves focus on <body> when it closes. That includes DestructiveActionModal, which never has a trigger because the caller owns open, and dialogs opened from a menu.

How known problems are held

Each case lists its known problems as regexes, with a reason or an issue URL. The test fails on:

  • any other problem (a regression);
  • a known problem that stops occurring, which forces the list to be updated.

The table at the top of the file is the status of every component. It is stricter than test.fail, which would hide new problems behind an expected failure.

Verification

  • The checkPattern signature was checked against the installed .d.ts ((root: Element, pattern: Pattern) => Promise<void>, 15 patterns). The docs and the package agree.
  • Seeded defect: removing the CodeBlock tablist's aria-label fails with div[role=tablist]: has no accessible name; give it aria-label or aria-labelledby (APG tabs). The change was reverted.
  • No new jsdom stubs were needed in tests/setup.ts.
  • pnpm format:check ✓
  • pnpm lint ✓
  • pnpm test: 253 passed + 1 expected fail
  • pnpm docs:check ✓

Docs

  • DESIGN Verification gets a row.
  • CONTRIBUTING Tests gets a paragraph on pattern checks, the known-problem rule and it.fails for confirmed bugs.

Public API / dependency changes

None.

tests/components/patterns.test.tsx runs UI SDK's checkPattern
(@ui-sdk/core/testing, already an exact devDependency) over sixteen
composites in jsdom: roles, names, states, id references and the pattern's
keys, with focus never falling to <body>.

Passing: Accordion, Collapsible, Checkbox, Switch, Slider, Dialog,
DropdownMenu, ContextMenu (with a focusable trigger), Combobox.

Known problems are listed per case with their reason, and anything else
fails, as does a known problem that stops occurring:
- Radix primitives: the roving-focus container takes Tab (Tabs, RadioGroup,
  ToggleGroup); a radio is checked only while the arrow is held; a
  horizontal ToggleGroup ignores Up/Down; Select moves DOM focus into its
  listbox. Each is covered by a named behaviour test, or is a deviation of the
  primitive that ADR 0001 keeps.
- Inline Command has no popup for Escape to close.
- CodeBlock shares one panel between its tabs (#35).
- A Dialog without a DialogTrigger, DestructiveActionModal included, leaves
  focus on <body> when it closes: Radix returns focus only to a trigger.
  Filed as #64; a behaviour test in kit.test.tsx states the fix, as it.fails.

A seeded defect (CodeBlock's tablist without a name) fails with checkPattern's
own message. No jsdom stub was needed. DESIGN's verification table and
CONTRIBUTING's Tests section document the checks and the known-problem rule.
ContextMenu's focusable-trigger guidance and DestructiveActionModal's
alertdialog question went to #39.

Closes #27
@YaelAnaya YaelAnaya added area: testing Automated verification experimental Technology evaluation or experimental functionality 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 7742cc9 into main Dec 5, 2026
1 check passed
@YaelAnaya
YaelAnaya deleted the test/27-pattern-tests branch December 5, 2026 07:16
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 experimental Technology evaluation or experimental functionality type: testing Testing infrastructure and coverage

Projects

None yet

1 participant