An open source design system that's fully customizable and agent ready
TypeScript
test(a11y): add Progressbar contract and bind ProgressBar and CircularProgress (#7919)
Cindy Zhang0c1a6e860cb0
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 9c64d57fa0..010db5af96 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -2032,6 +2032,55 @@ jobs:retention-days: 30if-no-files-found: warn+ # The progressbar contract's role and name, value and range, indeterminate+ # state, and value text are accessibility-tree facts that jsdom cannot+ # observe. Run the contract's own fixture proof and the ProgressBar and+ # CircularProgress bindings whenever either component, the binding+ # stories, or the contract changes. Its own --output directory; the JSON+ # report is the head-bound record, uploaded next.+ - name: Run Progressbar accessibility contract+ id: progressbar-contract+ if: ${{ !cancelled() && github.event_name == 'pull_request' }}+ env:+ BASE_SHA: ${{ github.event.pull_request.base.sha }}+ PLAYWRIGHT_JSON_OUTPUT_FILE: progressbar-contract/report.json+ run: |+ should_run=false+ # The helper comes from the base, since an older PR head lacks it.+ # Exit 1 means out of scope; 0 in scope; 2 unknown, so run.+ scope=2+ helper="$(mktemp)"+ if git fetch --quiet --no-tags --depth=1 origin "$BASE_SHA" \+ && git show "$BASE_SHA:.github/scripts/pr-scope-touches.sh" > "$helper"; then+ scope=0+ bash "$helper" "$BASE_SHA" \+ '^(internal/a11y-spec/src/patterns/progressbar\.|packages/core/src/ProgressBar/|packages/lab/src/CircularProgress/|apps/storybook/stories/ProgressbarA11y)' || scope=$?+ fi+ if [ "$scope" != 1 ]; then+ should_run=true+ fi+ echo "should_run=${should_run}" >> "$GITHUB_OUTPUT"+ if [ "$should_run" != true ]; then+ echo "ProgressBar, CircularProgress and the progressbar contract are not in PR scope; skipping progressbar evidence."+ exit 0+ fi+ pnpm exec playwright test \+ internal/a11y-spec/src/patterns/progressbar.chromium.spec.ts \+ packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.ts \+ packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.chromium.spec.ts \+ --project chromium \+ --reporter list,json \+ --output progressbar-contract-output++ - name: Upload Progressbar accessibility contract evidence+ if: ${{ !cancelled() && steps.progressbar-contract.outputs.should_run == 'true' }}+ uses: actions/upload-artifact@v7+ with:+ name: progressbar-contract-evidence-${{ needs.build-storybook.outputs.short_hash }}+ path: progressbar-contract/+ retention-days: 30+ if-no-files-found: warn+# A treeitem's computed name and description are accessibility-tree facts# jsdom approximates but a browser decides. Run the TreeList row-naming# evidence whenever TreeList, its focus hook, or the story changes.diff --git a/apps/storybook/stories/ProgressbarA11y.stories.tsx b/apps/storybook/stories/ProgressbarA11y.stories.tsxnew file mode 100644index 0000000000..7879cb94d8--- /dev/null+++ b/apps/storybook/stories/ProgressbarA11y.stories.tsx@@ -0,0 +1,64 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file ProgressbarA11y.stories.tsx+ * @input The ProgressBar and Lab CircularProgress binding states, rendered through each binding's own renderer so the jsdom and Chromium lanes see the same tree+ * @output One checked-in story per state for the Chromium accessibility lane; excluded from the visual matrix+ * @position Browser fixtures for PROGRESSBAR_PATTERN+ */++import type {Meta, StoryObj} from '@storybook/react';+import {renderProgressBarState} from '../../../packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.renders';+import {PROGRESSBAR_BINDING_STATES} from '../../../packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.states';+import {renderCircularProgressState} from '../../../packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.renders';+import {CIRCULAR_PROGRESS_BINDING_STATES} from '../../../packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.states';++const meta = {+ title: 'A11y/Progressbar',+ tags: ['no-visual'],+ parameters: {layout: 'padded'},+} satisfies Meta;++export default meta;+type Story = StoryObj<typeof meta>;++function progressBarStory(+ id: (typeof PROGRESSBAR_BINDING_STATES)[number]['id'],+): Story {+ const state = PROGRESSBAR_BINDING_STATES.find(+ candidate => candidate.id === id,+ );+ if (state == null) {+ throw new Error(`no ProgressBar binding state "${id}"`);+ }+ return {render: () => renderProgressBarState(state)};+}++function circularProgressStory(+ id: (typeof CIRCULAR_PROGRESS_BINDING_STATES)[number]['id'],+): Story {+ const state = CIRCULAR_PROGRESS_BINDING_STATES.find(+ candidate => candidate.id === id,+ );+ if (state == null) {+ throw new Error(`no CircularProgress binding state "${id}"`);+ }+ return {render: () => renderCircularProgressState(state)};+}++export const ProgressBarDeterminate = progressBarStory('determinate');+export const ProgressBarFormatted = progressBarStory('formatted');+export const ProgressBarComplete = progressBarStory('complete');+export const ProgressBarLabelHidden = progressBarStory('label-hidden');+export const ProgressBarIndeterminate = progressBarStory('indeterminate');+export const ProgressBarDisabled = progressBarStory('disabled');+export const ProgressBarTargetMarks = progressBarStory('target-marks');++export const CircularProgressDeterminate = circularProgressStory('determinate');+export const CircularProgressFormatted = circularProgressStory('formatted');+export const CircularProgressLabelVisible =+ circularProgressStory('label-visible');+export const CircularProgressIndeterminate =+ circularProgressStory('indeterminate');+export const CircularProgressCenterContent =+ circularProgressStory('center-content');diff --git a/internal/a11y-spec/README.md b/internal/a11y-spec/README.mdindex 35a8e6272c..7eb22364b6 100644--- a/internal/a11y-spec/README.md+++ b/internal/a11y-spec/README.md@@ -61,6 +61,7 @@ src/├── carousel.* non-rotating collection, slide, off-screen, and focus semantics├── tree-view.* a tree's roles, names, expanded state, one Tab stop, and arrow/Home/End/Enter-or-Space/typeahead movement├── slider.* a thumb's role, name, values, text, orientation, and arrow/Page/Home/End keys (RTL-mirrored arrows)+ ├── progressbar.* a progress indicator's role and name, value and range or indeterminate state, value text, and a subtree with nothing focusable├── accordion.* a group's header role and name, panel state, single-expansion collapse, page Tab order├── breadcrumb.* landmark, list-trail, current-page, and separator semantics├── combobox.* control identity, state, popup, and active-descendant semantics@@ -93,6 +94,7 @@ src/| `combobox` | WCAG 2.2 + [WAI-ARIA 1.2 Combobox](https://www.w3.org/TR/wai-aria-1.2/#combobox); APG as context | Selector trigger identity, state, popup, and active-descendant relationships || `landmark` | WCAG 2.2 semantics; [APG Landmark Regions](https://www.w3.org/WAI/ARIA/apg/patterns/landmarks/) as context | LayoutHeader, LayoutContent, LayoutFooter, and LayoutPanel caller-declared landmarks || `slider` | [APG Slider](https://www.w3.org/WAI/ARIA/apg/patterns/slider/) role, values, name, orientation and keys | Slider thumbs: role, name, now/min/max, value text, orientation, arrows (RTL-mirrored), Page, Home/End, disabled keeps value |+| `progressbar` | WCAG 2.2 4.1.2 and [WAI-ARIA 1.2 progressbar](https://www.w3.org/TR/wai-aria-1.2/#progressbar); no APG pattern exists | ProgressBar, Lab CircularProgress: progressbar role and name, now/min/max, indeterminate claims no value, value text, no focusable descendants (target marks sit beside the bar) || `treeview` | [APG Tree View](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/) structure and keyboard model | TreeList rows: tree/treeitem/group, aria-expanded, level/position, one Tab stop, Up/Down, Right/Left (RTL-mirrored), Home/End, Enter or Space, typeahead || `carousel` | [APG Carousel](https://www.w3.org/WAI/ARIA/apg/patterns/carousel/) and WCAG 2.2 semantics | Carousel container, slides, scroll area, and stable navigation-control focus || `alertdialog` | [APG Alert Dialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/) role, references, modality, focus, dismissal | AlertDialog: alertdialog role and name, aria-describedby to the message, modal, Cancel first (advisory), Escape closes, click beside inert (advisory); modal mechanics stay with the modal-dialog contract through Dialog |@@ -100,6 +102,16 @@ src/| `windowsplitter` | [APG Window Splitter](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/) role, values, name, relationship and keys | ResizeHandle: separator role/name, now/min/max, orientation, aria-controls to the pane, arrows, Enter collapse/restore, Home/End, disabled keeps position || `link` | WCAG 2.2 semantics; [APG Link](https://www.w3.org/WAI/ARIA/apg/patterns/link/) role and Enter mechanics | Link, including LinkProvider and `as` router components |+The `progressbar` contract owns what one rendered progress indicator exposes in+each state: the progressbar role and the operation's name (never a meter or a+status), its value inside its range, no value or value text while progress is+unknown, its formatted value text, and a subtree with nothing a keyboard can+land on, since a progressbar's descendants are presentational. Whether that+exposure survives progress and completion updates without moving focus stays+with the `status-message` contract; clamping, ring geometry, and the target+marks' own Tooltip triggers stay with the components. Spinner exposes a status,+not a progressbar, so it binds only to `status-message`.+The toggle-button contract owns the persistent-action extension of buttonsemantics: the pressed state must be exposed, reversible by pointer, Enter, andSpace, stable under an aborted press, and inert when unavailable. It also checksdiff --git a/internal/a11y-spec/src/index.ts b/internal/a11y-spec/src/index.tsindex 551faf4f42..8e1cab99df 100644--- a/internal/a11y-spec/src/index.ts+++ b/internal/a11y-spec/src/index.ts@@ -147,6 +147,10 @@ export {} from './patterns/landmark';export {SLIDER_PATTERN, type SliderStateFacts} from './patterns/slider';+export {+ PROGRESSBAR_PATTERN,+ type ProgressbarStateFacts,+} from './patterns/progressbar';export {TREE_VIEW_PATTERN, type TreeViewStateFacts} from './patterns/tree-view';export {CAROUSEL_PATTERN, type CarouselStateFacts} from './patterns/carousel';export {diff --git a/internal/a11y-spec/src/patterns/progressbar.chromium.spec.ts b/internal/a11y-spec/src/patterns/progressbar.chromium.spec.tsnew file mode 100644index 0000000000..33ea8da27f--- /dev/null+++ b/internal/a11y-spec/src/patterns/progressbar.chromium.spec.ts@@ -0,0 +1,96 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file progressbar.chromium.spec.ts+ * @input PROGRESSBAR_PATTERN and its fixtures in real Chromium+ * @output Proof that every expectation passes conforming fixtures and fails its mutation at the layers only a browser observes+ * @position Contract self-test, Chromium lane+ */++import {expect, test, type CDPSession, type Page} from '@playwright/test';+import {describeExpectation, requiredLayers} from '../contract';+import {checkAccessibilitySpec, type ExpectationResult} from '../check';+import {+ CHROMIUM_OBSERVES,+ createChromiumHarness,+ holdMotionStill,+} from '../harness/chromium';+import {PROGRESSBAR_PATTERN} from './progressbar';+import {+ PROGRESSBAR_MUTATIONS,+ CONFORMING_FIXTURES,+ SUBJECT_SELECTOR,+ fixture,+ type ProgressbarFixture,+} from './progressbar.fixtures';++function fixturePage(html: string): string {+ return `<!doctype html><html lang="en"><body>${html}</body></html>`;+}++async function results(+ page: Page,+ cdp: CDPSession,+ target: ProgressbarFixture,+ only?: readonly string[],+): Promise<readonly ExpectationResult[]> {+ const run = await checkAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'fixture',+ state: target.id,+ facts: target.facts,+ only,+ mount: async () => {+ await page.setContent(fixturePage(target.html));+ await holdMotionStill(page);+ return createChromiumHarness({+ page,+ cdp,+ subject: page.locator(SUBJECT_SELECTOR),+ related: {},+ });+ },+ });+ return run.results;+}++test.describe('progressbar contract — conforming fixtures', () => {+ for (const id of CONFORMING_FIXTURES) {+ test(`${id}: every applicable expectation passes`, async ({page}) => {+ const cdp = await page.context().newCDPSession(page);+ const observed = await results(page, cdp, fixture(id));+ expect(+ observed+ .filter(+ result =>+ result.status !== 'pass' && result.status !== 'not-applicable',+ )+ .map(result => `${result.expectation}: ${result.detail ?? ''}`),+ ).toEqual([]);+ });+ }+});++test.describe('progressbar contract — deliberately violating fixtures', () => {+ for (const expectation of PROGRESSBAR_PATTERN.expectations) {+ if (+ !requiredLayers(expectation).every(layer =>+ CHROMIUM_OBSERVES.includes(layer),+ )+ ) {+ continue;+ }+ for (const fixtureId of PROGRESSBAR_MUTATIONS[expectation.id] ?? []) {+ test(`${describeExpectation(expectation)} — fails against ${fixtureId}`, async ({+ page,+ }) => {+ const cdp = await page.context().newCDPSession(page);+ const [result] = await results(page, cdp, fixture(fixtureId), [+ expectation.id,+ ]);+ expect(result?.status, result?.detail ?? 'no result').toBe('fail');+ expect(result?.detail ?? '').not.toBe('');+ });+ }+ }+});diff --git a/internal/a11y-spec/src/patterns/progressbar.fixtures.ts b/internal/a11y-spec/src/patterns/progressbar.fixtures.tsnew file mode 100644index 0000000000..b18ecf4f55--- /dev/null+++ b/internal/a11y-spec/src/patterns/progressbar.fixtures.ts@@ -0,0 +1,227 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file progressbar.fixtures.ts+ * @input Plain HTML progress indicators, conforming and deliberately violating+ * @output PROGRESSBAR_FIXTURES, the subject selector, and the expectation → violating-fixture map+ * @position Contract self-test data for progressbar.jsdom.test.ts and progressbar.chromium.spec.ts+ */++import type {ProgressbarStateFacts} from './progressbar';++const SUBJECT_ATTRIBUTE = 'data-a11y-subject';+export const SUBJECT_SELECTOR = `[${SUBJECT_ATTRIBUTE}]`;++export interface ProgressbarFixture {+ readonly id: string;+ readonly summary: string;+ readonly facts: ProgressbarStateFacts;+ readonly html: string;+}++interface Bar {+ readonly role?: string;+ readonly label?: string | null;+ readonly value?: number | null;+ readonly min?: number;+ readonly max?: number;+ readonly valueText?: string | null;+ /** Markup placed inside the progress bar's subtree. */+ readonly inside?: string;+ /** Markup placed beside the progress bar, outside its subtree. */+ readonly beside?: string;+}++function bar({+ role = 'progressbar',+ label = 'Upload',+ value = 40,+ min = 0,+ max = 100,+ valueText = null,+ inside = '',+ beside = '',+}: Bar = {}): string {+ const values =+ value == null+ ? ''+ : ` aria-valuenow="${value}" aria-valuemin="${min}" aria-valuemax="${max}"`;+ const text = valueText == null ? '' : ` aria-valuetext="${valueText}"`;+ const name = label == null ? '' : ' aria-labelledby="label"';+ return `<div><span id="label">${label ?? ''}</span><div ${SUBJECT_ATTRIBUTE} role="${role}"${name}${values}${text} style="width:200px;height:8px;background:#ddd"><div style="width:40%;height:8px;background:#333"></div>${inside}</div>${beside}</div>`;+}++const facts = (+ overrides: Partial<ProgressbarStateFacts> = {},+): ProgressbarStateFacts => ({+ name: 'Upload',+ value: 40,+ min: 0,+ max: 100,+ valueText: null,+ ...overrides,+});++const MARK =+ '<span tabindex="0" style="display:inline-block;width:8px;height:8px">•</span>';++export const PROGRESSBAR_FIXTURES: readonly ProgressbarFixture[] = [+ {+ id: 'conforming-determinate',+ summary: 'a progress bar at 40 of 0–100',+ facts: facts(),+ html: bar(),+ },+ {+ id: 'conforming-formatted',+ summary: 'a progress bar that speaks its value as formatted text',+ facts: facts({value: 3, max: 5, valueText: '3 GB / 5 GB', name: 'Disk'}),+ html: bar({value: 3, max: 5, valueText: '3 GB / 5 GB', label: 'Disk'}),+ },+ {+ id: 'conforming-complete',+ summary: 'a progress bar at its maximum',+ facts: facts({value: 100, valueText: '100%'}),+ html: bar({value: 100, valueText: '100%'}),+ },+ {+ id: 'conforming-indeterminate',+ summary: 'a progress bar whose progress is unknown claims no value',+ facts: facts({value: null, name: 'Loading data'}),+ html: bar({value: null, label: 'Loading data'}),+ },+ {+ id: 'conforming-native-indeterminate',+ summary: 'a native progress element with no value',+ facts: facts({value: null, name: 'Loading data'}),+ html: `<div><label for="native">Loading data</label><progress ${SUBJECT_ATTRIBUTE} id="native"></progress></div>`,+ },+ {+ id: 'conforming-focusable-mark-beside',+ summary:+ 'a progress bar whose focusable target mark sits beside it, outside its subtree',+ facts: facts({value: 50, valueText: '50%'}),+ html: bar({value: 50, valueText: '50%', beside: MARK}),+ },+ {+ id: 'violating-meter',+ summary: 'progress exposed as a meter',+ facts: facts(),+ html: bar({role: 'meter'}),+ },+ {+ id: 'violating-status',+ summary: 'progress exposed as a status with no progress role',+ facts: facts(),+ html: bar({role: 'status'}),+ },+ {+ id: 'violating-unnamed',+ summary: 'a progress bar with no accessible name',+ facts: facts(),+ html: bar({label: null}),+ },+ {+ id: 'violating-wrong-name',+ summary: 'a progress bar named for a different operation',+ facts: facts({name: 'Download'}),+ html: bar(),+ },+ {+ id: 'violating-wrong-value',+ summary: 'a progress bar whose exposed value disagrees with its progress',+ facts: facts(),+ html: bar({value: 41}),+ },+ {+ id: 'violating-no-value',+ summary: 'a progress bar that knows its progress but exposes no value',+ facts: facts(),+ html: bar({value: null}),+ },+ {+ id: 'violating-wrong-range',+ summary: 'a progress bar whose exposed maximum disagrees with its range',+ facts: facts({max: 200}),+ html: bar(),+ },+ {+ id: 'violating-indeterminate-claims-zero',+ summary: 'an indeterminate progress bar that claims 0 of 100',+ facts: facts({value: null, name: 'Loading data'}),+ html: bar({value: 0, label: 'Loading data'}),+ },+ {+ id: 'violating-indeterminate-claims-text',+ summary: 'an indeterminate progress bar that speaks a percentage',+ facts: facts({value: null, name: 'Loading data'}),+ html: bar({value: null, valueText: '0%', label: 'Loading data'}),+ },+ {+ id: 'violating-valuetext-missing',+ summary: 'a formatted progress bar that exposes only the number',+ facts: facts({value: 3, max: 5, valueText: '3 GB / 5 GB', name: 'Disk'}),+ html: bar({value: 3, max: 5, label: 'Disk'}),+ },+ {+ id: 'violating-valuetext-stale',+ summary:+ 'a progress bar whose value text disagrees with its formatted value',+ facts: facts({value: 50, valueText: '50%'}),+ html: bar({value: 50, valueText: '40%'}),+ },+ {+ id: 'violating-focusable-mark-inside',+ summary:+ 'a focusable target mark inside the progress bar, where the platform hides it',+ facts: facts({value: 50, valueText: '50%'}),+ html: bar({value: 50, valueText: '50%', inside: MARK}),+ },+ {+ id: 'violating-button-inside',+ summary: 'a button rendered inside the progress bar',+ facts: facts(),+ html: bar({inside: '<button type="button">Cancel</button>'}),+ },+];++export function fixture(id: string): ProgressbarFixture {+ const found = PROGRESSBAR_FIXTURES.find(candidate => candidate.id === id);+ if (found == null) {+ throw new Error(`unknown progressbar fixture "${id}"`);+ }+ return found;+}++export const CONFORMING_FIXTURES: readonly string[] =+ PROGRESSBAR_FIXTURES.filter(candidate =>+ candidate.id.startsWith('conforming-'),+ ).map(candidate => candidate.id);++export const PROGRESSBAR_MUTATIONS: Readonly<+ Record<string, readonly string[]>+> = {+ 'progressbar.identity.role-and-name': [+ 'violating-meter',+ 'violating-status',+ 'violating-unnamed',+ 'violating-wrong-name',+ ],+ 'progressbar.determinate.value-and-range': [+ 'violating-wrong-value',+ 'violating-no-value',+ 'violating-wrong-range',+ ],+ 'progressbar.indeterminate.no-value-claimed': [+ 'violating-indeterminate-claims-zero',+ 'violating-indeterminate-claims-text',+ ],+ 'progressbar.value.text-exposed': [+ 'violating-valuetext-missing',+ 'violating-valuetext-stale',+ ],+ 'progressbar.subtree.no-focusable-descendants': [+ 'violating-focusable-mark-inside',+ 'violating-button-inside',+ ],+};diff --git a/internal/a11y-spec/src/patterns/progressbar.jsdom.test.ts b/internal/a11y-spec/src/patterns/progressbar.jsdom.test.tsnew file mode 100644index 0000000000..e907398b65--- /dev/null+++ b/internal/a11y-spec/src/patterns/progressbar.jsdom.test.ts@@ -0,0 +1,155 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+/** @vitest-environment jsdom */++/**+ * @file progressbar.jsdom.test.ts+ * @input PROGRESSBAR_PATTERN and its conforming and violating fixtures+ * @output Proof that the contract is complete, that every DOM-layer expectation passes conforming fixtures and fails its mutation, and that jsdom reports browser layers as unrun+ * @position Contract self-test, jsdom lane+ */++import {afterEach, describe, expect, it} from 'vitest';+import {+ citeSource,+ describeExpectation,+ requiredLayers,+ unansweredDimensions,+} from '../contract';+import {checkAccessibilitySpec, type ExpectationResult} from '../check';+import {JSDOM_OBSERVES, createJsdomHarness} from '../harness/jsdom';+import {PROGRESSBAR_PATTERN} from './progressbar';+import {+ PROGRESSBAR_MUTATIONS,+ CONFORMING_FIXTURES,+ SUBJECT_SELECTOR,+ fixture,+ type ProgressbarFixture,+} from './progressbar.fixtures';++const observableHere = PROGRESSBAR_PATTERN.expectations.filter(expectation =>+ requiredLayers(expectation).every(layer => JSDOM_OBSERVES.includes(layer)),+);++afterEach(() => document.body.replaceChildren());++async function resultsFor(target: ProgressbarFixture) {+ const container = document.createElement('div');+ document.body.append(container);+ const result = await checkAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'fixture',+ state: target.id,+ facts: target.facts,+ mount: async () => {+ container.innerHTML = target.html;+ const subject = container.querySelector(SUBJECT_SELECTOR);+ if (subject == null) {+ throw new Error(`fixture "${target.id}" is missing its subject`);+ }+ return createJsdomHarness({subject, related: {}});+ },+ unmount: () => {+ container.innerHTML = '';+ },+ });+ return result.results;+}++function resultFor(+ results: readonly ExpectationResult[],+ id: string,+): ExpectationResult {+ const found = results.find(result => result.expectation === id);+ if (found == null) {+ throw new Error(`no result for ${id}`);+ }+ return found;+}++describe('progressbar contract — completeness', () => {+ it('answers every completeness dimension', () => {+ expect(unansweredDimensions(PROGRESSBAR_PATTERN)).toEqual([]);+ });++ it('gives every expectation at least one deliberately violating fixture', () => {+ const missing = PROGRESSBAR_PATTERN.expectations+ .filter(+ expectation =>+ (PROGRESSBAR_MUTATIONS[expectation.id] ?? []).length === 0,+ )+ .map(expectation => expectation.id);+ expect(missing).toEqual([]);+ });++ it('has an expectation for every mutation it records', () => {+ const ids = new Set(+ PROGRESSBAR_PATTERN.expectations.map(expectation => expectation.id),+ );+ expect(+ Object.keys(PROGRESSBAR_MUTATIONS).filter(id => !ids.has(id)),+ ).toEqual([]);+ });++ it('names every fixture it records a mutation against', () => {+ for (const fixtures of Object.values(PROGRESSBAR_MUTATIONS)) {+ for (const id of fixtures) {+ expect(() => fixture(id)).not.toThrow();+ }+ }+ });+});++describe('progressbar contract — the jsdom harness stays within its evidence boundary', () => {+ it('runs DOM expectations and reports browser expectations as unrun', async () => {+ const results = await resultsFor(fixture('conforming-determinate'));+ expect(results.some(result => result.status === 'pass')).toBe(true);+ const above = results.filter(result => result.status === 'unrun');+ expect(above.length).toBeGreaterThan(0);+ for (const result of above) {+ expect(+ (result.missingLayers ?? []).some(+ layer => layer === 'real-browser' || layer === 'accessibility-tree',+ ),+ ).toBe(true);+ }+ });+});++describe.each(observableHere.map(expectation => [expectation.id] as const))(+ '%s',+ id => {+ const expectation = PROGRESSBAR_PATTERN.expectations.find(+ candidate => candidate.id === id,+ )!;++ it.each(CONFORMING_FIXTURES.map(name => [name] as const))(+ 'passes against %s (or does not apply to it)',+ async name => {+ const result = resultFor(await resultsFor(fixture(name)), id);+ expect(+ ['pass', 'not-applicable'],+ `${id} against ${name}: ${result.detail ?? ''}`,+ ).toContain(result.status);+ },+ );++ it.each((PROGRESSBAR_MUTATIONS[id] ?? []).map(name => [name] as const))(+ 'fails against %s, which removes its outcome',+ async name => {+ const result = resultFor(await resultsFor(fixture(name)), id);+ expect(result.status, `${id} against ${name}`).toBe('fail');+ expect(result.detail ?? '').not.toBe('');+ },+ );++ it('carries its id and primary source into every result description', async () => {+ const target = fixture(+ PROGRESSBAR_MUTATIONS[id]?.[0] ?? CONFORMING_FIXTURES[0]!,+ );+ const result = resultFor(await resultsFor(target), id);+ expect(result.description).toContain(id);+ expect(result.description).toContain(citeSource(expectation.sources[0]));+ expect(describeExpectation(expectation)).toBe(result.description);+ });+ },+);diff --git a/internal/a11y-spec/src/patterns/progressbar.ts b/internal/a11y-spec/src/patterns/progressbar.tsnew file mode 100644index 0000000000..59bb3e4c09--- /dev/null+++ b/internal/a11y-spec/src/patterns/progressbar.ts@@ -0,0 +1,450 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file progressbar.ts+ * @input WCAG 2.2 4.1.2 and the WAI-ARIA 1.2 progressbar role, value, value-text, and presentational-children requirements+ * @output PROGRESSBAR_PATTERN — the reusable contract one rendered progress indicator binds to, and the facts a binding declares for it+ * @position Pattern contract; bound by ProgressBar and Lab CircularProgress. The status-message contract keeps a progress update's exposure across transitions; this one owns each rendered state's identity.+ */++import {+ definePattern,+ type PatternContract,+ type WcagCriterion,+ type WebStandardRequirement,+} from '../contract';++const UNDERSTANDING = 'https://www.w3.org/WAI/WCAG22/Understanding';+const ARIA = 'https://www.w3.org/TR/wai-aria-1.2';++const WCAG_4_1_2: WcagCriterion = {+ standard: 'wcag',+ id: '4.1.2',+ name: 'Name, Role, Value',+ level: 'A',+ url: `${UNDERSTANDING}/name-role-value.html`,+};++const WCAG_1_3_1: WcagCriterion = {+ standard: 'wcag',+ id: '1.3.1',+ name: 'Info and Relationships',+ level: 'A',+ url: `${UNDERSTANDING}/info-and-relationships.html`,+};++const ARIA_PROGRESSBAR_NAME: WebStandardRequirement = {+ standard: 'web-standard',+ specification: 'WAI-ARIA 1.2 progressbar role',+ requirement:+ 'A progressbar is an element that displays the progress status for tasks that take a long time. Accessible Name Required: True.',+ url: `${ARIA}/#progressbar`,+};++const ARIA_PROGRESSBAR_VALUES: WebStandardRequirement = {+ standard: 'web-standard',+ specification: 'WAI-ARIA 1.2 progressbar role',+ requirement:+ 'The author SHOULD supply values for aria-valuenow, aria-valuemin, and aria-valuemax, unless the value is indeterminate, in which case the author SHOULD omit the aria-valuenow attribute.',+ url: `${ARIA}/#progressbar`,+};++const ARIA_VALUE_NOW: WebStandardRequirement = {+ standard: 'web-standard',+ specification: 'WAI-ARIA 1.2 aria-valuenow property',+ requirement:+ 'Authors MUST ensure aria-valuenow is greater than or equal to aria-valuemin and less than or equal to aria-valuemax.',+ url: `${ARIA}/#aria-valuenow`,+};++const ARIA_VALUE_TEXT: WebStandardRequirement = {+ standard: 'web-standard',+ specification: 'WAI-ARIA 1.2 aria-valuetext property',+ requirement:+ 'Defines the human-readable text alternative of aria-valuenow for a range widget.',+ url: `${ARIA}/#aria-valuetext`,+};++const ARIA_CHILDREN_PRESENTATIONAL: WebStandardRequirement = {+ standard: 'web-standard',+ specification:+ 'WAI-ARIA 1.2 progressbar role (Children Presentational: True)',+ requirement:+ 'The DOM descendants are presentational. User agents SHOULD NOT expose descendants of this element through the platform accessibility API.',+ url: `${ARIA}/#childrenArePresentational`,+};++/**+ * What a binding knows about one rendered progress indicator (the subject).+ * `value` is null while the amount of progress is unknown (indeterminate).+ * `valueText` is the formatted value the indicator speaks, or null when it+ * exposes the bare number.+ */+export interface ProgressbarStateFacts {+ /** The operation the indicator names. */+ readonly name: string;+ readonly value: number | null;+ readonly min: number;+ readonly max: number;+ readonly valueText: string | null;+}++/**+ * Elements a keyboard user can land on. Inside a progressbar's presentational+ * subtree any of these takes focus while the platform hides what it is.+ */+const FOCUSABLE_DESCENDANT = [+ 'a[href]',+ 'area[href]',+ 'button',+ 'input:not([type="hidden"])',+ 'select',+ 'textarea',+ 'iframe',+ 'summary',+ 'audio[controls]',+ 'video[controls]',+ '[contenteditable]:not([contenteditable="false"])',+ '[tabindex]:not([tabindex="-1"])',+]+ .map(selector => `:scope ${selector}`)+ .join(', ');++const ALWAYS = {+ condition: 'the binding designates a rendered progress indicator',+ test: () => true,+};++const DETERMINATE = {+ condition: 'the binding knows how much progress has been made',+ test: (facts: ProgressbarStateFacts) => facts.value != null,+};++export const PROGRESSBAR_PATTERN: PatternContract<ProgressbarStateFacts> =+ definePattern<ProgressbarStateFacts>({+ pattern: 'progressbar',+ url: `${ARIA}/#progressbar`,+ scope:+ "One rendered progress indicator's progressbar role and name, its value and range or its indeterminate state, its spoken value text, and a subtree that holds nothing a keyboard can land on. How the indicator stays exposed while progress updates belongs to the status-message contract.",+ expectations: [+ {+ id: 'progressbar.identity.role-and-name',+ outcome:+ 'The browser exposes the indicator as a progress bar named for its operation, so a user hears what is progressing rather than a meter, a status, or an unnamed graphic.',+ sources: [WCAG_4_1_2, ARIA_PROGRESSBAR_NAME],+ covers: ['4.1.2-name-role-value', '2.4.6-headings-and-labels'],+ appliesWhen: ALWAYS,+ evidenceLayer: 'accessibility-tree',+ enforcement: 'required',+ run: async ({subject, facts}) => {+ const {role, name} = await subject.computed();+ if (role !== 'progressbar') {+ throw new Error(+ role == null+ ? 'the browser exposes no role for this indicator, so assistive technology cannot tell it reports progress'+ : `the browser exposes this indicator as ${JSON.stringify(role)}, not as a progress bar`,+ );+ }+ if (name.trim() === '') {+ throw new Error(+ 'the browser computes no accessible name for this progress bar, so a user cannot tell which operation it reports',+ );+ }+ if (name.trim() !== facts.name.trim()) {+ throw new Error(+ `the browser names this progress bar ${JSON.stringify(name.trim())}, not the binding’s declared operation ${JSON.stringify(facts.name.trim())}`,+ );+ }+ },+ },+ {+ id: 'progressbar.determinate.value-and-range',+ outcome:+ 'A progress bar that knows its progress exposes its current value inside its range, so a user hears how far the operation has come.',+ sources: [WCAG_4_1_2, ARIA_PROGRESSBAR_VALUES, ARIA_VALUE_NOW],+ covers: ['4.1.2-name-role-value'],+ appliesWhen: DETERMINATE,+ evidenceLayer: 'accessibility-tree',+ enforcement: 'required',+ run: async ({subject, facts}) => {+ if (facts.value == null) {+ return;+ }+ if (facts.min > facts.max) {+ throw new Error(+ `the binding declares a reversed progress range ${facts.min}..${facts.max}`,+ );+ }+ const {rangeValue, rangeMin, rangeMax} = await subject.computed();+ if (+ rangeValue !== facts.value ||+ rangeMin !== facts.min ||+ rangeMax !== facts.max+ ) {+ throw new Error(+ `the browser exposes value=${String(rangeValue)}, min=${String(rangeMin)}, max=${String(rangeMax)} instead of ${facts.value} in ${facts.min}..${facts.max}`,+ );+ }+ if (rangeValue < rangeMin || rangeValue > rangeMax) {+ throw new Error(+ `the browser exposes progress ${rangeValue} outside its range ${rangeMin}..${rangeMax}`,+ );+ }+ },+ },+ {+ id: 'progressbar.indeterminate.no-value-claimed',+ outcome:+ 'A progress bar that does not know its progress claims no amount, so a user hears ongoing activity instead of a made-up percentage.',+ sources: [WCAG_4_1_2, ARIA_PROGRESSBAR_VALUES],+ covers: ['4.1.2-name-role-value'],+ appliesWhen: {+ condition:+ 'the binding does not know how much progress has been made',+ test: facts => facts.value == null,+ },+ evidenceLayer: 'accessibility-tree',+ enforcement: 'required',+ run: async ({subject}) => {+ const {rangeValue, valueText} = await subject.computed();+ if (rangeValue != null) {+ throw new Error(+ `the browser exposes progress value ${rangeValue} for an indicator whose progress is unknown`,+ );+ }+ if (valueText != null && valueText.trim() !== '') {+ throw new Error(+ `the browser exposes value text ${JSON.stringify(valueText)} for an indicator whose progress is unknown`,+ );+ }+ },+ },+ {+ id: 'progressbar.value.text-exposed',+ outcome:+ 'A formatted progress value is spoken as that text, matching what a sighted user reads, not as a bare number.',+ sources: [WCAG_4_1_2, ARIA_VALUE_TEXT],+ covers: ['4.1.2-name-role-value'],+ appliesWhen: {+ condition:+ 'the binding knows its progress and speaks it as formatted text',+ test: facts => facts.value != null && facts.valueText != null,+ },+ evidenceLayer: 'accessibility-tree',+ enforcement: 'required',+ run: async ({subject, facts}) => {+ const {valueText} = await subject.computed();+ if ((valueText ?? '').trim() !== (facts.valueText ?? '').trim()) {+ throw new Error(+ valueText == null || valueText.trim() === ''+ ? `the browser exposes no value text, not the binding’s formatted ${JSON.stringify(facts.valueText)}`+ : `the browser exposes value text ${JSON.stringify(valueText)}, not the binding’s formatted ${JSON.stringify(facts.valueText)}`,+ );+ }+ },+ },+ {+ id: 'progressbar.subtree.no-focusable-descendants',+ outcome:+ 'Nothing a keyboard can land on sits inside the progress bar, whose descendants the platform hides, so every focusable control keeps a role and a name.',+ sources: [WCAG_4_1_2, ARIA_CHILDREN_PRESENTATIONAL, WCAG_1_3_1],+ covers: ['4.1.2-name-role-value', '1.3.1-info-and-relationships'],+ appliesWhen: ALWAYS,+ evidenceLayer: 'dom',+ enforcement: 'required',+ run: async ({subject}) => {+ const count = await subject.descendantCount(FOCUSABLE_DESCENDANT);+ if (count > 0) {+ throw new Error(+ `${count} focusable ${count === 1 ? 'element sits' : 'elements sit'} inside the progress bar, whose descendants the platform hides, so a keyboard user can land on a control with no exposed role or name`,+ );+ }+ },+ },+ ],+ exemptions: {+ '1.1.1-non-text-content': {+ owner: 'the binding component',+ verifiedBy:+ "the component's own tests for decorative track and fill parts plus the repository axe audit",+ reason:+ 'The track, fill, and ring are drawn inside the presentational subtree; the progress bar itself carries the text alternative this contract checks.',+ },+ '1.3.1-info-and-relationships': {+ owner: 'the caller that loads a region of the page',+ verifiedBy:+ 'integration review of aria-busy on the loading region and aria-describedby from it to the progress bar',+ reason:+ "This contract proves the progress bar's subtree holds no hidden controls. Pointing a loading region at the progress bar and marking the region busy is the caller's composition.",+ coversRemainderOnly: true,+ },+ '1.3.2-meaningful-sequence': {+ owner: 'the binding component and composing page',+ verifiedBy:+ "the component's label-order tests and page-level reading-order review",+ reason:+ 'Where the label, value text, and indicator sit relative to surrounding content is layout and composition.',+ },+ '1.3.5-identify-input-purpose': {+ owner: 'not applicable',+ verifiedBy: 'none needed',+ reason:+ 'A progress bar is read-only and collects no information about the user.',+ },+ '1.4.1-use-of-color': {+ owner: 'the binding component and theme',+ verifiedBy:+ "the component's standalone completed-versus-remaining visual review",+ reason:+ 'Distinguishing completed from remaining progress without color is a paint result outside this semantic contract.',+ },+ '1.4.3-contrast-minimum': {+ owner: 'the binding component and theme',+ verifiedBy: 'the repository axe audit plus rendered contrast review',+ reason:+ 'Label and value-text contrast depend on resolved theme pixels.',+ },+ '1.4.11-non-text-contrast': {+ owner: 'the binding component and theme',+ verifiedBy:+ 'rendered review of fill, track, and mark contrast across shipped themes',+ reason:+ 'Fill and track contrast is a rendered-pixel outcome; this contract proves the programmatic value.',+ },+ '2.1.1-keyboard': {+ owner:+ 'not applicable to the progress bar; any composed control keeps its own pattern',+ verifiedBy:+ "the composed control's own contract, such as a target mark's Tooltip binding",+ reason:+ 'A progress bar is read-only, so it has no keyboard operation. A control rendered beside it, such as a target mark, is keyboard-operable under its own pattern.',+ },+ '2.1.2-no-keyboard-trap': {+ owner: 'the binding component and composing page',+ verifiedBy: 'page-level keyboard review',+ reason:+ 'A progress bar takes no focus and so cannot trap it; composed controls keep their own focus contracts.',+ },+ '2.4.2-page-titled': {+ owner: 'the page',+ verifiedBy: 'page-level review',+ reason: 'A progress bar rendered in isolation owns no document title.',+ },+ '2.4.3-focus-order': {+ owner: 'the composing page',+ verifiedBy: 'page-level focus-order review',+ reason:+ 'A progress bar is not a Tab stop; the order of controls around it is composition.',+ },+ '2.4.4-link-purpose': {+ owner: 'not applicable',+ verifiedBy: 'none needed',+ reason: 'A progress bar renders no link.',+ },+ '2.4.6-headings-and-labels': {+ owner: 'caller content',+ verifiedBy: 'content review of the operation label',+ reason:+ 'This contract proves the progress bar carries the declared name; whether that wording describes the operation is a content judgement.',+ coversRemainderOnly: true,+ },+ '2.4.7-focus-visible': {+ owner: 'any focusable control composed with the progress bar',+ verifiedBy: "that control's focus-indicator review",+ reason:+ 'A progress bar takes no focus, so it shows no focus indicator.',+ },+ '2.4.11-focus-not-obscured': {+ owner: 'the composing page',+ verifiedBy: 'page-level layout review',+ reason: 'A progress bar takes no focus to obscure.',+ },+ '2.5.2-pointer-cancellation': {+ owner: 'not applicable',+ verifiedBy: 'none needed',+ reason: 'A progress bar performs no pointer action.',+ },+ '2.5.3-label-in-name': {+ owner: 'the binding component',+ verifiedBy: "the component's visible-label tests",+ reason:+ 'A progress bar is not a speech-input target; this contract proves its name matches the declared operation.',+ },+ '2.5.8-target-size': {+ owner: 'any pointer target composed with the progress bar',+ verifiedBy:+ 'the repository target-size audit over rendered marks and controls',+ reason: 'A progress bar is not a pointer target.',+ },+ '3.1.1-language-of-page': {+ owner: 'the page',+ verifiedBy: 'page-level review',+ reason: 'A progress bar owns no document language.',+ },+ '3.2.2-on-input': {+ owner: 'not applicable',+ verifiedBy: 'none needed',+ reason: 'A progress bar takes no input.',+ },+ '3.2.4-consistent-identification': {+ owner: 'the design system',+ verifiedBy:+ 'this shared contract across ProgressBar and CircularProgress',+ reason:+ 'Consistency is a property of the set of progress indicators, not one rendered state.',+ },+ '3.3.1-error-identification': {+ owner: 'the caller that reports a failed operation',+ verifiedBy: 'the status-message contract and caller review',+ reason:+ 'A failed operation is reported by a status or error message, not by the progress bar.',+ },+ '3.3.2-labels-or-instructions': {+ owner: 'not applicable',+ verifiedBy: 'none needed',+ reason: 'A progress bar is not an input that needs instructions.',+ },+ '4.1.2-name-role-value': {+ owner: 'the status-message contract and the binding component',+ verifiedBy:+ "status-message.progress.* for exposure across progress and completion updates, and the component's clamping and disabled tests",+ reason:+ "This contract encodes each rendered state's role, name, value, range, indeterminate state, value text, and subtree. Keeping that exposure through updates, and how out-of-range input is clamped, belong to those owners.",+ coversRemainderOnly: true,+ },+ '4.1.3-status-messages': {+ owner: 'the status-message contract and spec:AST-009',+ verifiedBy:+ 'the status-message progress expectations and real-AT evidence under AST-009 when a change claims spoken output',+ reason:+ 'A progress update is a status message; this contract makes no announcement or update claim.',+ },+ 'apg-interaction': {+ owner: 'no APG widget pattern for progress bars',+ verifiedBy:+ 'the WAI-ARIA 1.2 progressbar, aria-valuenow, and aria-valuetext requirements this contract cites',+ reason:+ 'The APG publishes no progressbar pattern and no current Astryx record adopts an interaction model for this read-only role.',+ },+ 'forced-colors': {+ owner: 'the binding component and theme',+ verifiedBy: "the component's forced-colors review of fill and track",+ reason:+ 'Forced-colors output is a paint result outside the semantics this contract observes.',+ },+ 'reduced-motion': {+ owner: 'the binding component and theme',+ verifiedBy:+ "the component's reduced-motion tests for the indeterminate animation",+ reason:+ 'The indeterminate slide and spin are visual timing, not progressbar semantics.',+ },+ 'at-facing-strings': {+ owner: 'the binding component and caller content',+ verifiedBy:+ 'the repository i18n catalog check and review of the default value formatter',+ reason:+ 'The contract introduces no string; the label comes from the caller and the value text from the binding formatter.',+ },+ },+ });diff --git a/packages/core/src/ProgressBar/ProgressBar.test.tsx b/packages/core/src/ProgressBar/ProgressBar.test.tsxindex f626295ba3..232c12ae7c 100644--- a/packages/core/src/ProgressBar/ProgressBar.test.tsx+++ b/packages/core/src/ProgressBar/ProgressBar.test.tsx@@ -565,21 +565,6 @@ describe('ProgressBar', () => {expect(styleClasses(accentMarks[1])).toBe(styleClasses(errorMarks[1]));});- it('keeps tabbable target marks outside the progressbar subtree', () => {- const {container} = render(- <ProgressBar- value={50}- label="Progress"- marks={[{value: 80, label: 'Goal'}]}- />,- );- const progressbar = screen.getByRole('progressbar', {name: 'Progress'});- const mark = container.querySelector(MARK)!;- expect(mark).toHaveAttribute('tabindex', '0');- expect(progressbar.querySelector('[tabindex="0"]')).toBeNull();- expect(mark.closest('[role="progressbar"]')).toBeNull();- });-it('renders every mark as a focusable trigger (label is required, never decorative)', () => {const {container} = render(<ProgressBar@@ -637,7 +622,6 @@ describe('ProgressBar', () => {/>,);const progressbar = screen.getByRole('progressbar');- expect(progressbar.querySelector(MARK)).toBeNull();expect(progressbar.querySelector('[role="img"]')).toBeNull();expect(progressbar.querySelector('[aria-label]')).toBeNull();expect(container.querySelectorAll(MARK)).toHaveLength(1);@@ -655,9 +639,10 @@ describe('ProgressBar', () => {expect(progressbar.getAttribute('aria-valuetext')).toBe('50%');});- it('preserves the fill inside the progressbar when marks are rendered outside it', () => {- // Only the fill belongs to the semantic track; the focusable marks- // remain independently available outside its presentational subtree.+ it('keeps the fill as the progressbar child when marks are rendered', () => {+ // Only the fill belongs to the semantic track. That the focusable marks+ // stay outside its presentational subtree is the progressbar contract's+ // target-marks state (progressbar.subtree.no-focusable-descendants).const {container} = render(<ProgressBarvalue={50}@@ -669,8 +654,6 @@ describe('ProgressBar', () => {const fill = progressbar.firstElementChild as HTMLElement;expect(fill.style.width).toBe('50%');expect(fill.classList.contains('astryx-progress-bar-mark')).toBe(false);- const mark = container.querySelector<HTMLElement>(MARK)!;- expect(progressbar).not.toContainElement(mark);expect(container.querySelectorAll(MARK)).toHaveLength(1);});diff --git a/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.ts b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.tsnew file mode 100644index 0000000000..fce24c6287--- /dev/null+++ b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.ts@@ -0,0 +1,114 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file ProgressBar.a11y.chromium.spec.ts+ * @input Built ProgressBar stories and PROGRESSBAR_PATTERN in real Chromium+ * @output Browser evidence for every progressbar expectation across the binding's states, reconciled against the exact known failures+ * @position Chromium lane of the ProgressBar binding+ */++import {+ expect,+ test,+ type CDPSession,+ type Locator,+ type Page,+} from '@playwright/test';+import {+ PROGRESSBAR_PATTERN,+ blockingResults,+ checkAccessibilitySpec,+ formatFailures,+ neverExercised,+ summarize,+ unmatchedKnownFailures,+ type BindingResult,+} from '@astryxdesign/a11y-spec';+import {+ createChromiumHarness,+ holdMotionStill,+} from '@astryxdesign/a11y-spec/chromium';+import {+ DEFAULT_STORYBOOK_DIR,+ serveStorybook,+ type StaticServer,+} from '@astryxdesign/a11y-spec/storybook';+import {PROGRESSBAR_KNOWN_FAILURES} from './ProgressBar.a11y.known-failures';+import {+ PROGRESSBAR_BINDING_STATES,+ type ProgressBarBindingState,+} from './ProgressBar.a11y.states';++let storybook: StaticServer;++test.beforeAll(async () => {+ storybook = await serveStorybook(+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,+ );+});++test.afterAll(async () => {+ await storybook?.close();+});++function storyUrl(storyId: string): string {+ return `${storybook.origin}/iframe.html?id=${storyId}&viewMode=story`;+}++async function mountState(+ page: Page,+ state: ProgressBarBindingState,+): Promise<{subject: Locator; related: Record<string, Locator>}> {+ await page.goto(storyUrl(state.storyId), {waitUntil: 'load'});+ await holdMotionStill(page);+ const subject = page+ .locator('#storybook-root')+ .getByRole('progressbar', {name: state.facts.name});+ await subject.waitFor({state: 'attached'});+ return {subject, related: {}};+}++async function runState(+ page: Page,+ cdp: CDPSession,+ state: ProgressBarBindingState,+): Promise<BindingResult> {+ return checkAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'ProgressBar',+ state: state.id,+ facts: state.facts,+ knownFailures: PROGRESSBAR_KNOWN_FAILURES,+ mount: async () => {+ const {subject, related} = await mountState(page, state);+ return createChromiumHarness({page, cdp, subject, related});+ },+ });+}++test('every progressbar expectation is exercised by a ProgressBar state', async ({+ page,+}) => {+ const cdp = await page.context().newCDPSession(page);+ const results: BindingResult[] = [];+ for (const state of PROGRESSBAR_BINDING_STATES) {+ results.push(await runState(page, cdp, state));+ }+ expect(neverExercised(results)).toEqual([]);+ expect(unmatchedKnownFailures(PROGRESSBAR_KNOWN_FAILURES, results)).toEqual(+ [],+ );+});++for (const state of PROGRESSBAR_BINDING_STATES) {+ test(`ProgressBar [${state.id}] — ${state.summary}`, async ({page}) => {+ const cdp = await page.context().newCDPSession(page);+ const result = await runState(page, cdp, state);+ const report = summarize(PROGRESSBAR_PATTERN, [result]);+ // Required rows block (AST-020 FR9); advisory rows and exact known+ // failures report.+ expect(formatFailures(blockingResults([result]))).toBe('');+ expect(report.unrunLayers).toEqual([]);+ expect(report.counts.unexpectedPass).toBe(0);+ });+}diff --git a/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.known-failures.ts b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.known-failures.tsnew file mode 100644index 0000000000..717fa30e55--- /dev/null+++ b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.known-failures.ts@@ -0,0 +1,12 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file ProgressBar.a11y.known-failures.ts+ * @input The exact progressbar-contract failures the shipped ProgressBar produces today+ * @output PROGRESSBAR_KNOWN_FAILURES — records both lanes reconcile against, so a fix shows up as an unexpected pass and any other failure stays a failure+ * @position Known-failure ledger for the ProgressBar binding+ */++import type {KnownFailure} from '@astryxdesign/a11y-spec';++export const PROGRESSBAR_KNOWN_FAILURES: ReadonlyArray<KnownFailure> = [];diff --git a/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.renders.tsx b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.renders.tsxnew file mode 100644index 0000000000..5e20757bc1--- /dev/null+++ b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.renders.tsx@@ -0,0 +1,38 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @file ProgressBar.a11y.renders.tsx+ * @input One ProgressBar binding state+ * @output The React tree every lane renders for that state (the jsdom test directly, the story through Storybook)+ * @position Shared fixture for the ProgressBar binding+ */++import type {ReactElement} from 'react';+import {ProgressBar} from '../ProgressBar';+import {+ formatGigabytes,+ type ProgressBarBindingState,+} from './ProgressBar.a11y.states';++export function renderProgressBarState(+ state: ProgressBarBindingState,+): ReactElement {+ return (+ <ProgressBar+ style={{width: 320}}+ label={state.facts.name}+ // An indeterminate state still passes a value, so the proof shows the+ // bar withholds it rather than never having had one.+ value={state.facts.value ?? 50}+ max={state.facts.max}+ isLabelHidden={state.isLabelHidden}+ hasValueLabel={state.hasValueLabel}+ formatValueLabel={state.formatsValue ? formatGigabytes : undefined}+ isIndeterminate={state.isIndeterminate}+ isDisabled={state.isDisabled}+ marks={state.marks}+ />+ );+}diff --git a/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.states.ts b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.states.tsnew file mode 100644index 0000000000..15ee1c1ace--- /dev/null+++ b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.states.ts@@ -0,0 +1,123 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file ProgressBar.a11y.states.ts+ * @input ProgressBar's representative states and the facts PROGRESSBAR_PATTERN reads+ * @output PROGRESSBAR_BINDING_STATES and the explicit ownership exclusions for this binding+ * @position Binding inventory shared by the jsdom test, the Chromium spec, and the story+ */++import type {ProgressbarStateFacts} from '@astryxdesign/a11y-spec';+import type {ProgressBarMark} from '../ProgressBar';++export interface ProgressBarBindingState {+ readonly id: string;+ readonly summary: string;+ readonly storyId: string;+ readonly facts: ProgressbarStateFacts;+ /** Props beyond label/value/max that shape the state. */+ readonly isLabelHidden?: boolean;+ readonly hasValueLabel?: boolean;+ readonly formatsValue?: boolean;+ readonly isIndeterminate?: boolean;+ readonly isDisabled?: boolean;+ readonly marks?: ReadonlyArray<ProgressBarMark>;+}++function facts(+ overrides: Partial<ProgressbarStateFacts> = {},+): ProgressbarStateFacts {+ return {+ name: 'Upload',+ value: 40,+ min: 0,+ max: 100,+ valueText: '40%',+ ...overrides,+ };+}++const story = (id: string) => `a11y-progressbar--progress-bar-${id}`;++/** The custom formatter the `formatted` state passes, so its facts can quote the text. */+export const formatGigabytes = (value: number, max: number): string =>+ `${value} GB / ${max} GB`;++export const PROGRESSBAR_BINDING_STATES = [+ {+ id: 'determinate',+ summary: 'a ProgressBar at 40 of 0–100 speaking its default percentage',+ storyId: story('determinate'),+ facts: facts(),+ },+ {+ id: 'formatted',+ summary:+ 'a ProgressBar with a custom formatter and a visible value label: 3 of 5 speaks "3 GB / 5 GB"',+ storyId: story('formatted'),+ facts: facts({+ name: 'Disk',+ value: 3,+ max: 5,+ valueText: '3 GB / 5 GB',+ }),+ hasValueLabel: true,+ formatsValue: true,+ },+ {+ id: 'complete',+ summary: 'a ProgressBar at its maximum',+ storyId: story('complete'),+ facts: facts({value: 100, valueText: '100%'}),+ },+ {+ id: 'label-hidden',+ summary:+ 'a ProgressBar whose label is visually hidden keeps it as its name',+ storyId: story('label-hidden'),+ facts: facts({name: 'Storage used'}),+ isLabelHidden: true,+ },+ {+ id: 'indeterminate',+ summary:+ 'an indeterminate ProgressBar with hasValueLabel claims no value or text',+ storyId: story('indeterminate'),+ facts: facts({name: 'Loading data', value: null, valueText: null}),+ isIndeterminate: true,+ hasValueLabel: true,+ },+ {+ id: 'disabled',+ summary: 'a disabled ProgressBar keeps its role, name, and value',+ storyId: story('disabled'),+ facts: facts(),+ isDisabled: true,+ },+ {+ id: 'target-marks',+ summary:+ 'a ProgressBar with focusable target marks: the marks sit outside the progress bar and its value text stays the percentage',+ storyId: story('target-marks'),+ facts: facts({value: 50, valueText: '50%'}),+ marks: [+ {value: 25, label: 'Q1 target'},+ {value: 80, label: 'Goal'},+ ],+ },+] as const satisfies ReadonlyArray<ProgressBarBindingState>;++export const PROGRESSBAR_EXCLUSIONS = [+ {+ id: 'value-clamping',+ owner: 'ProgressBar.test.tsx clamping and non-finite value tests',+ reason:+ 'Clamping an out-of-range or non-finite value before it reaches aria-valuenow is component input handling; this binding proves the value the bar exposes once it is in range.',+ },+ {+ id: 'mark-trigger',+ owner: 'ProgressBar.test.tsx target-mark tests and the tooltip contract',+ reason:+ "A target mark's focusability and the Tooltip that names it are the mark's own trigger behavior; this binding proves only that marks stay outside the progress bar's presentational subtree.",+ },+] as const;diff --git a/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.test.tsx b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.test.tsxnew file mode 100644index 0000000000..0e6adb1634--- /dev/null+++ b/packages/core/src/ProgressBar/__tests__/ProgressBar.a11y.test.tsx@@ -0,0 +1,107 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+/** @vitest-environment jsdom */++/**+ * @file ProgressBar.a11y.test.tsx+ * @input PROGRESSBAR_PATTERN bound to ProgressBar's representative states+ * @output jsdom-lane proof of the DOM expectations and an honest "unrun" report for the browser layers+ * @position Binding test for the ProgressBar binding (the Chromium spec covers the rest)+ */++import {cleanup, render, screen} from '@testing-library/react';+import {describe, expect, it} from 'vitest';+import {+ PROGRESSBAR_PATTERN,+ checkAccessibilitySpec,+ createJsdomHarness,+ expectAccessibilitySpec,+ summarize,+ type BindingResult,+} from '@astryxdesign/a11y-spec';+import {PROGRESSBAR_KNOWN_FAILURES} from './ProgressBar.a11y.known-failures';+import {renderProgressBarState} from './ProgressBar.a11y.renders';+import {+ PROGRESSBAR_BINDING_STATES,+ PROGRESSBAR_EXCLUSIONS,+ type ProgressBarBindingState,+} from './ProgressBar.a11y.states';++function progressbar(state: ProgressBarBindingState): HTMLElement {+ return screen.getByRole('progressbar', {name: state.facts.name});+}++async function checkState(+ state: ProgressBarBindingState,+): Promise<BindingResult> {+ return checkAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'ProgressBar',+ state: state.id,+ facts: state.facts,+ knownFailures: PROGRESSBAR_KNOWN_FAILURES,+ mount: async () => {+ render(renderProgressBarState(state));+ return createJsdomHarness({subject: progressbar(state), related: {}});+ },+ unmount: cleanup,+ });+}++describe('ProgressBar — progressbar pattern, jsdom lane', () => {+ it.each(+ PROGRESSBAR_BINDING_STATES.map(+ state => [state.id, state.summary, state] as const,+ ),+ )('%s — %s', async (_id, _summary, state) => {+ await expectAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'ProgressBar',+ state: state.id,+ facts: state.facts,+ knownFailures: PROGRESSBAR_KNOWN_FAILURES,+ render: () => {+ render(renderProgressBarState(state));+ },+ subject: () => progressbar(state),+ related: () => ({}),+ cleanup,+ });+ });++ it('runs the DOM layer and reports the browser-owned outcomes as unrun', async () => {+ const results: BindingResult[] = [];+ for (const state of PROGRESSBAR_BINDING_STATES) {+ results.push(await checkState(state));+ }+ const report = summarize(PROGRESSBAR_PATTERN, results);+ expect(report.counts.pass).toBeGreaterThan(0);+ expect(report.unrunLayers).toEqual(['accessibility-tree']);+ expect(report.counts.unexpectedPass).toBe(0);+ });+});++describe('ProgressBar binding inventory', () => {+ it('gives every representative state a distinct checked-in story', () => {+ const stories = PROGRESSBAR_BINDING_STATES.map(state => state.storyId);+ expect(new Set(stories).size).toBe(stories.length);+ });++ it('keeps clamping and mark-trigger ownership explicit', () => {+ expect(PROGRESSBAR_EXCLUSIONS.map(exclusion => exclusion.id)).toEqual([+ 'value-clamping',+ 'mark-trigger',+ ]);+ for (const exclusion of PROGRESSBAR_EXCLUSIONS) {+ expect(exclusion.owner.length, exclusion.id).toBeGreaterThan(20);+ expect(exclusion.reason.length, exclusion.id).toBeGreaterThan(80);+ }+ });++ it('renders exactly one named progress bar for every state', () => {+ for (const state of PROGRESSBAR_BINDING_STATES) {+ render(renderProgressBarState(state));+ expect(progressbar(state), state.id).toBeTruthy();+ cleanup();+ }+ });+});diff --git a/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.chromium.spec.ts b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.chromium.spec.tsnew file mode 100644index 0000000000..c274917760--- /dev/null+++ b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.chromium.spec.ts@@ -0,0 +1,114 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file CircularProgress.a11y.chromium.spec.ts+ * @input Built CircularProgress stories and PROGRESSBAR_PATTERN in real Chromium+ * @output Browser evidence for every progressbar expectation across the binding's states, reconciled against the exact known failures+ * @position Chromium lane of the CircularProgress binding+ */++import {+ expect,+ test,+ type CDPSession,+ type Locator,+ type Page,+} from '@playwright/test';+import {+ PROGRESSBAR_PATTERN,+ blockingResults,+ checkAccessibilitySpec,+ formatFailures,+ neverExercised,+ summarize,+ unmatchedKnownFailures,+ type BindingResult,+} from '@astryxdesign/a11y-spec';+import {+ createChromiumHarness,+ holdMotionStill,+} from '@astryxdesign/a11y-spec/chromium';+import {+ DEFAULT_STORYBOOK_DIR,+ serveStorybook,+ type StaticServer,+} from '@astryxdesign/a11y-spec/storybook';+import {CIRCULAR_PROGRESS_KNOWN_FAILURES} from './CircularProgress.a11y.known-failures';+import {+ CIRCULAR_PROGRESS_BINDING_STATES,+ type CircularProgressBindingState,+} from './CircularProgress.a11y.states';++let storybook: StaticServer;++test.beforeAll(async () => {+ storybook = await serveStorybook(+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,+ );+});++test.afterAll(async () => {+ await storybook?.close();+});++function storyUrl(storyId: string): string {+ return `${storybook.origin}/iframe.html?id=${storyId}&viewMode=story`;+}++async function mountState(+ page: Page,+ state: CircularProgressBindingState,+): Promise<{subject: Locator; related: Record<string, Locator>}> {+ await page.goto(storyUrl(state.storyId), {waitUntil: 'load'});+ await holdMotionStill(page);+ const subject = page+ .locator('#storybook-root')+ .getByRole('progressbar', {name: state.facts.name});+ await subject.waitFor({state: 'attached'});+ return {subject, related: {}};+}++async function runState(+ page: Page,+ cdp: CDPSession,+ state: CircularProgressBindingState,+): Promise<BindingResult> {+ return checkAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'CircularProgress',+ state: state.id,+ facts: state.facts,+ knownFailures: CIRCULAR_PROGRESS_KNOWN_FAILURES,+ mount: async () => {+ const {subject, related} = await mountState(page, state);+ return createChromiumHarness({page, cdp, subject, related});+ },+ });+}++test('every progressbar expectation is exercised by a CircularProgress state', async ({+ page,+}) => {+ const cdp = await page.context().newCDPSession(page);+ const results: BindingResult[] = [];+ for (const state of CIRCULAR_PROGRESS_BINDING_STATES) {+ results.push(await runState(page, cdp, state));+ }+ expect(neverExercised(results)).toEqual([]);+ expect(+ unmatchedKnownFailures(CIRCULAR_PROGRESS_KNOWN_FAILURES, results),+ ).toEqual([]);+});++for (const state of CIRCULAR_PROGRESS_BINDING_STATES) {+ test(`CircularProgress [${state.id}] — ${state.summary}`, async ({page}) => {+ const cdp = await page.context().newCDPSession(page);+ const result = await runState(page, cdp, state);+ const report = summarize(PROGRESSBAR_PATTERN, [result]);+ // Required rows block (AST-020 FR9); advisory rows and exact known+ // failures report.+ expect(formatFailures(blockingResults([result]))).toBe('');+ expect(report.unrunLayers).toEqual([]);+ expect(report.counts.unexpectedPass).toBe(0);+ });+}diff --git a/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.known-failures.ts b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.known-failures.tsnew file mode 100644index 0000000000..6f946e3aa0--- /dev/null+++ b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.known-failures.ts@@ -0,0 +1,12 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file CircularProgress.a11y.known-failures.ts+ * @input The exact progressbar-contract failures the shipped CircularProgress produces today+ * @output CIRCULAR_PROGRESS_KNOWN_FAILURES — records both lanes reconcile against, so a fix shows up as an unexpected pass and any other failure stays a failure+ * @position Known-failure ledger for the CircularProgress binding+ */++import type {KnownFailure} from '@astryxdesign/a11y-spec';++export const CIRCULAR_PROGRESS_KNOWN_FAILURES: ReadonlyArray<KnownFailure> = [];diff --git a/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.renders.tsx b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.renders.tsxnew file mode 100644index 0000000000..957f220f6e--- /dev/null+++ b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.renders.tsx@@ -0,0 +1,41 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @file CircularProgress.a11y.renders.tsx+ * @input One CircularProgress binding state+ * @output The React tree every lane renders for that state (the jsdom test directly, the story through Storybook)+ * @position Shared fixture for the CircularProgress binding+ */++import type {ReactElement} from 'react';+import {CircularProgress} from '../CircularProgress';+import {+ formatSteps,+ type CircularProgressBindingState,+} from './CircularProgress.a11y.states';++export function renderCircularProgressState(+ state: CircularProgressBindingState,+): ReactElement {+ return (+ <div style={{padding: 24}}>+ <CircularProgress+ label={state.facts.name}+ // An indeterminate state still passes a value, so the proof shows the+ // ring withholds it rather than never having had one.+ value={state.facts.value ?? 50}+ max={state.facts.max}+ isLabelHidden={state.isLabelHidden}+ hasValueLabel={state.hasValueLabel}+ formatValueLabel={state.formatsValue ? formatSteps : undefined}+ isIndeterminate={state.isIndeterminate}+ isDisabled={state.isDisabled}>+ {state.centerLink != null ? (+ <a href="#upload-details">{state.centerLink}</a>+ ) : null}+ </CircularProgress>+ </div>+ );+}diff --git a/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.states.ts b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.states.tsnew file mode 100644index 0000000000..9362050488--- /dev/null+++ b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.states.ts@@ -0,0 +1,106 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file CircularProgress.a11y.states.ts+ * @input CircularProgress's representative states and the facts PROGRESSBAR_PATTERN reads+ * @output CIRCULAR_PROGRESS_BINDING_STATES and the explicit ownership exclusions for this binding+ * @position Binding inventory shared by the jsdom test, the Chromium spec, and the story+ */++import type {ProgressbarStateFacts} from '@astryxdesign/a11y-spec';++export interface CircularProgressBindingState {+ readonly id: string;+ readonly summary: string;+ readonly storyId: string;+ readonly facts: ProgressbarStateFacts;+ /** Props beyond label/value/max that shape the state. */+ readonly isLabelHidden?: boolean;+ readonly hasValueLabel?: boolean;+ readonly formatsValue?: boolean;+ readonly isIndeterminate?: boolean;+ readonly isDisabled?: boolean;+ /**+ * A focusable link rendered as the ring's center content, which must sit+ * beside the progress bar rather than inside its presentational subtree.+ */+ readonly centerLink?: string;+}++function facts(+ overrides: Partial<ProgressbarStateFacts> = {},+): ProgressbarStateFacts {+ return {+ name: 'Upload',+ value: 40,+ min: 0,+ max: 100,+ valueText: '40%',+ ...overrides,+ };+}++const story = (id: string) => `a11y-progressbar--circular-progress-${id}`;++/** The custom formatter the `formatted` state passes, so its facts can quote the text. */+export const formatSteps = (value: number, max: number): string =>+ `${value} of ${max}`;++export const CIRCULAR_PROGRESS_BINDING_STATES = [+ {+ id: 'determinate',+ summary:+ 'a CircularProgress at 40 of 0–100 with its default hidden label and percentage',+ storyId: story('determinate'),+ facts: facts(),+ },+ {+ id: 'formatted',+ summary:+ 'a CircularProgress with a custom formatter shown in the ring: 3 of 10 speaks "3 of 10"',+ storyId: story('formatted'),+ facts: facts({name: 'Steps', value: 3, max: 10, valueText: '3 of 10'}),+ hasValueLabel: true,+ formatsValue: true,+ },+ {+ id: 'label-visible',+ summary: 'a CircularProgress whose label is shown names the ring with it',+ storyId: story('label-visible'),+ facts: facts({name: 'Storage used'}),+ isLabelHidden: false,+ },+ {+ id: 'indeterminate',+ summary:+ 'an indeterminate CircularProgress with hasValueLabel claims no value or text',+ storyId: story('indeterminate'),+ facts: facts({name: 'Loading data', value: null, valueText: null}),+ isIndeterminate: true,+ hasValueLabel: true,+ },+ {+ id: 'center-content',+ summary:+ 'a disabled CircularProgress whose center content is a focusable link: the link sits beside the ring, not inside it',+ storyId: story('center-content'),+ facts: facts({value: 75, valueText: '75%'}),+ isDisabled: true,+ centerLink: 'Upload details',+ },+] as const satisfies ReadonlyArray<CircularProgressBindingState>;++export const CIRCULAR_PROGRESS_EXCLUSIONS = [+ {+ id: 'value-clamping',+ owner: 'CircularProgress.test.tsx clamping and non-finite value tests',+ reason:+ 'Clamping an out-of-range or non-finite value before it reaches aria-valuenow is component input handling; this binding proves the value the ring exposes once it is in range.',+ },+ {+ id: 'ring-geometry',+ owner: 'CircularProgress.test.tsx size and dash-offset tests',+ reason:+ 'Ring size, stroke, and the dash offset that draws the completed arc are paint geometry; this binding proves the programmatic value they illustrate.',+ },+] as const;diff --git a/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.test.tsx b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.test.tsxnew file mode 100644index 0000000000..7147113316--- /dev/null+++ b/packages/lab/src/CircularProgress/__tests__/CircularProgress.a11y.test.tsx@@ -0,0 +1,108 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+/** @vitest-environment jsdom */++/**+ * @file CircularProgress.a11y.test.tsx+ * @input PROGRESSBAR_PATTERN bound to CircularProgress's representative states+ * @output jsdom-lane proof of the DOM expectations and an honest "unrun" report for the browser layers+ * @position Binding test for the CircularProgress binding (the Chromium spec covers the rest)+ */++import {cleanup, render, screen} from '@testing-library/react';+import {describe, expect, it} from 'vitest';+import {+ PROGRESSBAR_PATTERN,+ checkAccessibilitySpec,+ createJsdomHarness,+ expectAccessibilitySpec,+ summarize,+ type BindingResult,+} from '@astryxdesign/a11y-spec';+import {CIRCULAR_PROGRESS_KNOWN_FAILURES} from './CircularProgress.a11y.known-failures';+import {renderCircularProgressState} from './CircularProgress.a11y.renders';+import {+ CIRCULAR_PROGRESS_BINDING_STATES,+ CIRCULAR_PROGRESS_EXCLUSIONS,+ type CircularProgressBindingState,+} from './CircularProgress.a11y.states';++function progressbar(state: CircularProgressBindingState): HTMLElement {+ return screen.getByRole('progressbar', {name: state.facts.name});+}++async function checkState(+ state: CircularProgressBindingState,+): Promise<BindingResult> {+ return checkAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'CircularProgress',+ state: state.id,+ facts: state.facts,+ knownFailures: CIRCULAR_PROGRESS_KNOWN_FAILURES,+ mount: async () => {+ render(renderCircularProgressState(state));+ return createJsdomHarness({subject: progressbar(state), related: {}});+ },+ unmount: cleanup,+ });+}++describe('CircularProgress — progressbar pattern, jsdom lane', () => {+ it.each(+ CIRCULAR_PROGRESS_BINDING_STATES.map(+ state => [state.id, state.summary, state] as const,+ ),+ )('%s — %s', async (_id, _summary, state) => {+ await expectAccessibilitySpec({+ spec: PROGRESSBAR_PATTERN,+ binding: 'CircularProgress',+ state: state.id,+ facts: state.facts,+ knownFailures: CIRCULAR_PROGRESS_KNOWN_FAILURES,+ render: () => {+ render(renderCircularProgressState(state));+ },+ subject: () => progressbar(state),+ related: () => ({}),+ cleanup,+ });+ });++ it('runs the DOM layer and reports the browser-owned outcomes as unrun', async () => {+ const results: BindingResult[] = [];+ for (const state of CIRCULAR_PROGRESS_BINDING_STATES) {+ results.push(await checkState(state));+ }+ const report = summarize(PROGRESSBAR_PATTERN, results);+ expect(report.counts.pass).toBeGreaterThan(0);+ expect(report.unrunLayers).toEqual(['accessibility-tree']);+ expect(report.counts.unexpectedPass).toBe(0);+ });+});++describe('CircularProgress binding inventory', () => {+ it('gives every representative state a distinct checked-in story', () => {+ const stories = CIRCULAR_PROGRESS_BINDING_STATES.map(+ state => state.storyId,+ );+ expect(new Set(stories).size).toBe(stories.length);+ });++ it('keeps clamping and ring-geometry ownership explicit', () => {+ expect(CIRCULAR_PROGRESS_EXCLUSIONS.map(exclusion => exclusion.id)).toEqual(+ ['value-clamping', 'ring-geometry'],+ );+ for (const exclusion of CIRCULAR_PROGRESS_EXCLUSIONS) {+ expect(exclusion.owner.length, exclusion.id).toBeGreaterThan(20);+ expect(exclusion.reason.length, exclusion.id).toBeGreaterThan(80);+ }+ });++ it('renders exactly one named progress bar for every state', () => {+ for (const state of CIRCULAR_PROGRESS_BINDING_STATES) {+ render(renderCircularProgressState(state));+ expect(progressbar(state), state.id).toBeTruthy();+ cleanup();+ }+ });+});