Repository navigation
test: check composites against their WAI-ARIA patterns with checkPattern (#27) - #65
Merged
Merged
Conversation
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
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
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
tabIndex={0}). The demos use non-focusable triggers, so keyboard users can't open them. Noted on #39checkPatternpresses and releases in one tick. The behaviour test proves a real key press checks itaria-activedescendant. A deviation of the primitive that ADR 0001 keepsNot 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
Dialogopened without aDialogTriggerleaves focus on<body>when it closes. That includesDestructiveActionModal, which never has a trigger because the caller ownsopen, and dialogs opened from a menu.preventDefaults its close autofocus and focuses onlytriggerRef.DialogContent. A behaviour test that states the correct outcome is inkit.test.tsxasit.fails, next to the issue link.How known problems are held
Each case lists its known problems as regexes, with a reason or an issue URL. The test fails on:
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
checkPatternsignature was checked against the installed.d.ts((root: Element, pattern: Pattern) => Promise<void>, 15 patterns). The docs and the package agree.aria-labelfails withdiv[role=tablist]: has no accessible name; give it aria-label or aria-labelledby (APG tabs).The change was reverted.tests/setup.ts.pnpm format:check✓pnpm lint✓pnpm test: 253 passed + 1 expected failpnpm docs:check✓Docs
it.failsfor confirmed bugs.Public API / dependency changes
None.