Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(a11y): Alert Dialog contract and AlertDialog binding (#7488)

Cindy Zhange212fdb51b42
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index feef65e993..6042670f19 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1817,6 +1817,54 @@ jobs:
retention-days: 30
if-no-files-found: warn
+ # The alert-dialog contract's role, name, modality, initial focus, Escape
+ # and click-beside outcomes are accessibility-tree and real-browser facts
+ # that jsdom cannot observe. Run the contract's own fixture proof and the
+ # AlertDialog binding whenever AlertDialog, Dialog, the harness, the
+ # binding's stories, or the contract changes. Its own --output
+ # directory; the JSON report is the head-bound record, uploaded next.
+ - name: Run Alert Dialog accessibility contract
+ id: alert-dialog-contract
+ if: ${{ !cancelled() && github.event_name == 'pull_request' }}
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ PLAYWRIGHT_JSON_OUTPUT_FILE: alert-dialog-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/alert-dialog|internal/a11y-spec/src/harness|packages/core/src/AlertDialog/|packages/core/src/Dialog/|apps/storybook/stories/AlertDialogA11y)' || scope=$?
+ fi
+ if [ "$scope" != 1 ]; then
+ should_run=true
+ fi
+ echo "should_run=${should_run}" >> "$GITHUB_OUTPUT"
+ if [ "$should_run" != true ]; then
+ echo "AlertDialog and the alert-dialog contract are not in PR scope; skipping alert-dialog evidence."
+ exit 0
+ fi
+ pnpm exec playwright test \
+ internal/a11y-spec/src/patterns/alert-dialog.chromium.spec.ts \
+ packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts \
+ --project chromium \
+ --reporter list,json \
+ --output alert-dialog-contract-output
+
+ - name: Upload Alert Dialog accessibility contract evidence
+ if: ${{ !cancelled() && steps.alert-dialog-contract.outputs.should_run == 'true' }}
+ uses: actions/upload-artifact@v7
+ with:
+ name: alert-dialog-contract-evidence-${{ needs.build-storybook.outputs.short_hash }}
+ path: alert-dialog-contract/
+ retention-days: 30
+ if-no-files-found: warn
+
# The link contract's role, name, Tab, Enter, and pointer-release outcomes
# are accessibility-tree and real-browser facts that jsdom cannot observe.
# Run the contract's own fixture proof and the Link binding whenever Link
diff --git a/apps/storybook/stories/AlertDialogA11y.stories.tsx b/apps/storybook/stories/AlertDialogA11y.stories.tsx
new file mode 100644
index 0000000000..ce2019669b
--- /dev/null
+++ b/apps/storybook/stories/AlertDialogA11y.stories.tsx
@@ -0,0 +1,36 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file AlertDialogA11y.stories.tsx
+ * @input The AlertDialog binding states, rendered through the 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 component:AlertDialog AR1 (ALERT_DIALOG_PATTERN)
+ */
+
+import type {Meta, StoryObj} from '@storybook/react';
+import {renderAlertDialogState} from '../../../packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.renders';
+import {ALERT_DIALOG_BINDING_STATES} from '../../../packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.states';
+
+const meta = {
+ title: 'A11y/AlertDialog',
+ tags: ['no-visual'],
+ parameters: {layout: 'padded'},
+} satisfies Meta;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+function storyFor(
+ id: (typeof ALERT_DIALOG_BINDING_STATES)[number]['id'],
+): Story {
+ const state = ALERT_DIALOG_BINDING_STATES.find(
+ candidate => candidate.id === id,
+ );
+ if (state == null) {
+ throw new Error(`no AlertDialog binding state "${id}"`);
+ }
+ return {render: () => renderAlertDialogState(state)};
+}
+
+export const ModalConfirm = storyFor('modal-confirm');
+export const ModalActionLoading = storyFor('modal-action-loading');
diff --git a/internal/a11y-spec/README.md b/internal/a11y-spec/README.md
index 1fcde17d05..8ad85d6106 100644
--- a/internal/a11y-spec/README.md
+++ b/internal/a11y-spec/README.md
@@ -51,6 +51,7 @@ src/
├── listbox.* listbox, group, and option semantics
├── spinbutton.* numeric role, value, bounds, state, and arrow stepping
├── disclosure.* standalone disclosure state/content semantics
+ ├── alert-dialog.* a confirmation surface's alertdialog role, title/message references, modality, initial focus, Escape and click-beside dismissal
├── 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)
@@ -62,27 +63,28 @@ src/
## The patterns
-| Pattern | Adopted from | Bound by |
-| ---------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `radio-group` | [APG radio group](https://www.w3.org/WAI/ARIA/apg/patterns/radio/) | RadioList, SegmentedControl; role/state portions of DropdownMenu radio items |
-| `checkbox` | [APG checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/) | CheckboxInput, CheckboxListItem, DropdownMenuCheckboxItem, SelectableCard |
-| `switch` | [APG switch](https://www.w3.org/WAI/ARIA/apg/patterns/switch/) | Switch |
-| `button` | [APG button](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | Button, IconButton, ClickableCard, SideNavCollapseButton, ChatSendButton |
-| `toggle-button` | Toggle-button semantics in the [APG button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | ToggleButton, including standalone and grouped states |
-| `text-input` | Native HTML controls and [WAI-ARIA textbox](https://www.w3.org/TR/wai-aria-1.2/#textbox) | TextInput, TextArea |
-| `modal-dialog` | [APG dialog (modal)](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/) | Dialog |
-| `status-message` | [WCAG 2.2 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html) | Toast, FieldStatus, Spinner, ChatSystemMessage, ChatTypingIndicator, ProgressBar |
-| `tabs` | [APG Tabs](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) | Explicit `role="tablist"` TabList, Tab, and caller-authored tabpanels |
-| `listbox` | [WAI-ARIA 1.2 Listbox](https://www.w3.org/TR/wai-aria-1.2/#listbox) and WCAG 2.2 semantics | Selector and MultiSelector popup listbox, group, and option parts |
-| `spinbutton` | WCAG 2.2 semantics and [APG Spinbutton](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/) | NumberInput |
-| `disclosure` | [APG Disclosure](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) | Standalone Collapsible triggers and their controlled content |
-| `accordion` | [APG Accordion](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) required parts | CollapsibleGroup headers: button role and name, expanded state, controlled panel, Enter/Space, single-expansion sibling collapse, page Tab order, no arrow-key movement (single-expansion collapse, grouped Tab order, no arrow movement are advisory until `component:CollapsibleGroup` AR4 is current) |
-| `breadcrumb` | WCAG 2.2 semantics; [APG Breadcrumb](https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/) as context | Breadcrumbs landmarks, list trails, current-page state, and separators |
-| `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 |
-| `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 |
-| `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 |
+| Pattern | Adopted from | Bound by |
+| ---------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `radio-group` | [APG radio group](https://www.w3.org/WAI/ARIA/apg/patterns/radio/) | RadioList, SegmentedControl; role/state portions of DropdownMenu radio items |
+| `checkbox` | [APG checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/) | CheckboxInput, CheckboxListItem, DropdownMenuCheckboxItem, SelectableCard |
+| `switch` | [APG switch](https://www.w3.org/WAI/ARIA/apg/patterns/switch/) | Switch |
+| `button` | [APG button](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | Button, IconButton, ClickableCard, SideNavCollapseButton, ChatSendButton |
+| `toggle-button` | Toggle-button semantics in the [APG button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/) | ToggleButton, including standalone and grouped states |
+| `text-input` | Native HTML controls and [WAI-ARIA textbox](https://www.w3.org/TR/wai-aria-1.2/#textbox) | TextInput, TextArea |
+| `modal-dialog` | [APG dialog (modal)](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/) | Dialog |
+| `status-message` | [WCAG 2.2 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html) | Toast, FieldStatus, Spinner, ChatSystemMessage, ChatTypingIndicator, ProgressBar |
+| `tabs` | [APG Tabs](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) | Explicit `role="tablist"` TabList, Tab, and caller-authored tabpanels |
+| `listbox` | [WAI-ARIA 1.2 Listbox](https://www.w3.org/TR/wai-aria-1.2/#listbox) and WCAG 2.2 semantics | Selector and MultiSelector popup listbox, group, and option parts |
+| `spinbutton` | WCAG 2.2 semantics and [APG Spinbutton](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/) | NumberInput |
+| `disclosure` | [APG Disclosure](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) | Standalone Collapsible triggers and their controlled content |
+| `accordion` | [APG Accordion](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) required parts | CollapsibleGroup headers: button role and name, expanded state, controlled panel, Enter/Space, single-expansion sibling collapse, page Tab order, no arrow-key movement (single-expansion collapse, grouped Tab order, no arrow movement are advisory until `component:CollapsibleGroup` AR4 is current) |
+| `breadcrumb` | WCAG 2.2 semantics; [APG Breadcrumb](https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/) as context | Breadcrumbs landmarks, list trails, current-page state, and separators |
+| `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 |
+| `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 |
+| `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 toggle-button contract owns the persistent-action extension of button
semantics: the pressed state must be exposed, reversible by pointer, Enter, and
diff --git a/internal/a11y-spec/src/check.test.ts b/internal/a11y-spec/src/check.test.ts
index 6e718cf946..63430ba1b0 100644
--- a/internal/a11y-spec/src/check.test.ts
+++ b/internal/a11y-spec/src/check.test.ts
@@ -50,6 +50,7 @@ function harness(observes: readonly EvidenceLayer[]): Harness {
references: async () => true,
click: async () => {},
abortedPress: async () => {},
+ clickBeside: async () => {},
typeText: async () => {},
clearText: async () => {},
press: async () => {},
diff --git a/internal/a11y-spec/src/harness.ts b/internal/a11y-spec/src/harness.ts
index 4ee8cb56ec..cd0a99d4cd 100644
--- a/internal/a11y-spec/src/harness.ts
+++ b/internal/a11y-spec/src/harness.ts
@@ -146,7 +146,8 @@ export type Key =
| 'Home'
| 'End'
| 'PageUp'
- | 'PageDown';
+ | 'PageDown'
+ | 'Escape';
/**
* A mounted binding, observed at whatever layers this runtime can honestly see.
@@ -194,6 +195,13 @@ export interface Harness {
* press, slide off, let go.
*/
abortedPress(subject: Subject): Promise<void>;
+ /**
+ * Real-browser layer: click just outside the subject's box, the way a
+ * person clicks the dimmed page beside a modal surface. What that click
+ * lands on (a backdrop, an inert page) is the subject's own business; the
+ * harness only puts the pointer there.
+ */
+ clickBeside(subject: Subject): Promise<void>;
/** Real-browser layer: type text into the focused subject. */
typeText(subject: Subject, text: string): Promise<void>;
/** Real-browser layer: select and delete all text from the subject. */
diff --git a/internal/a11y-spec/src/harness/chromium.ts b/internal/a11y-spec/src/harness/chromium.ts
index ef934c17e0..af7ad3b068 100644
--- a/internal/a11y-spec/src/harness/chromium.ts
+++ b/internal/a11y-spec/src/harness/chromium.ts
@@ -89,6 +89,7 @@ const KEYS: Record<Key, string> = {
End: 'End',
PageUp: 'PageUp',
PageDown: 'PageDown',
+ Escape: 'Escape',
};
interface AxValue {
@@ -1094,6 +1095,42 @@ export function createChromiumHarness(
throw error;
}
},
+ clickBeside: async targetSubject => {
+ const target = pointerTargets.get(targetSubject);
+ if (target == null) {
+ throw new Error(
+ 'the Chromium harness was asked to click beside a subject it did not create',
+ );
+ }
+ const box = await target.boundingBox();
+ if (box == null) {
+ throw new Error('the subject has no box to click beside');
+ }
+ const viewport = page.viewportSize() ?? {width: 1280, height: 720};
+ // A point outside the box but inside the viewport: above-left when
+ // there is room, else below-right.
+ const x =
+ box.x >= 8
+ ? box.x - 4
+ : Math.min(viewport.width - 2, box.x + box.width + 4);
+ const y =
+ box.y >= 8
+ ? box.y - 4
+ : Math.min(viewport.height - 2, box.y + box.height + 4);
+ const inside =
+ x >= box.x &&
+ x <= box.x + box.width &&
+ y >= box.y &&
+ y <= box.y + box.height;
+ if (inside) {
+ // A subject that fills the viewport leaves no point beside it; a
+ // click on the subject itself would prove nothing about dismissal.
+ throw new Error(
+ 'the subject fills the viewport, so there is no point beside it to click',
+ );
+ }
+ await page.mouse.click(x, y);
+ },
abortedPress: async () => {
const box = await pointerLocator.boundingBox();
if (box == null) {
diff --git a/internal/a11y-spec/src/harness/jsdom.ts b/internal/a11y-spec/src/harness/jsdom.ts
index 36ec989f8c..7da7ed9fd9 100644
--- a/internal/a11y-spec/src/harness/jsdom.ts
+++ b/internal/a11y-spec/src/harness/jsdom.ts
@@ -194,6 +194,8 @@ export function createJsdomHarness(options: JsdomHarnessOptions): Harness {
unobservable('real-browser', 'a real pointer activation'),
abortedPress: async () =>
unobservable('real-browser', 'a real pointer press'),
+ clickBeside: async () =>
+ unobservable('real-browser', 'a real pointer click beside the subject'),
typeText: async () =>
unobservable('real-browser', 'real keyboard text entry'),
clearText: async () =>
diff --git a/internal/a11y-spec/src/index.ts b/internal/a11y-spec/src/index.ts
index 4c58483056..424a4d7f68 100644
--- a/internal/a11y-spec/src/index.ts
+++ b/internal/a11y-spec/src/index.ts
@@ -147,6 +147,10 @@ export {
ACCORDION_PATTERN,
type AccordionStateFacts,
} from './patterns/accordion';
+export {
+ ALERT_DIALOG_PATTERN,
+ type AlertDialogStateFacts,
+} from './patterns/alert-dialog';
export {
LINK_PATTERN,
type LinkCurrentToken,
diff --git a/internal/a11y-spec/src/patterns/alert-dialog.chromium.spec.ts b/internal/a11y-spec/src/patterns/alert-dialog.chromium.spec.ts
new file mode 100644
index 0000000000..18c0a8e734
--- /dev/null
+++ b/internal/a11y-spec/src/patterns/alert-dialog.chromium.spec.ts
@@ -0,0 +1,106 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file alert-dialog.chromium.spec.ts
+ * @input ALERT_DIALOG_PATTERN and its fixtures in real Chromium (an invoker opens the native dialog; the fixture script implements Escape and the click-beside rule)
+ * @output Proof that every expectation passes the conforming fixture 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 {ALERT_DIALOG_PATTERN} from './alert-dialog';
+import {
+ ALERT_DIALOG_MUTATIONS,
+ CONFORMING_FIXTURES,
+ INVOKER_SELECTOR,
+ RELATION_SELECTORS,
+ SUBJECT_SELECTOR,
+ fixture,
+ type AlertDialogFixture,
+} from './alert-dialog.fixtures';
+
+function fixturePage(html: string): string {
+ return `<!doctype html><html lang="en"><body>${html}</body></html>`;
+}
+
+async function results(
+ page: Page,
+ cdp: CDPSession,
+ target: AlertDialogFixture,
+ only?: readonly string[],
+): Promise<readonly ExpectationResult[]> {
+ const run = await checkAccessibilitySpec({
+ spec: ALERT_DIALOG_PATTERN,
+ binding: 'fixture',
+ state: target.id,
+ facts: target.facts,
+ only,
+ mount: async () => {
+ await page.setContent(fixturePage(target.html));
+ await holdMotionStill(page);
+ // The surface opens the way a person reaches it: through its invoker.
+ await page.locator(INVOKER_SELECTOR).click();
+ await page.locator(SUBJECT_SELECTOR).waitFor({state: 'visible'});
+ return createChromiumHarness({
+ page,
+ cdp,
+ subject: page.locator(SUBJECT_SELECTOR),
+ related: Object.fromEntries(
+ Object.entries(RELATION_SELECTORS).map(([name, selector]) => [
+ name,
+ page.locator(selector),
+ ]),
+ ),
+ });
+ },
+ });
+ return run.results;
+}
+
+test.describe('alert-dialog 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('alert-dialog contract — deliberately violating fixtures', () => {
+ for (const expectation of ALERT_DIALOG_PATTERN.expectations) {
+ if (
+ !requiredLayers(expectation).every(layer =>
+ CHROMIUM_OBSERVES.includes(layer),
+ )
+ ) {
+ continue;
+ }
+ for (const fixtureId of ALERT_DIALOG_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/alert-dialog.fixtures.ts b/internal/a11y-spec/src/patterns/alert-dialog.fixtures.ts
new file mode 100644
index 0000000000..8b12fee776
--- /dev/null
+++ b/internal/a11y-spec/src/patterns/alert-dialog.fixtures.ts
@@ -0,0 +1,169 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file alert-dialog.fixtures.ts
+ * @input Plain HTML confirmation surfaces (a native dialog an invoker opens with showModal(); one script implements Escape and the click-beside rule; the DOM lane never runs it), conforming and deliberately violating
+ * @output ALERT_DIALOG_FIXTURES, the subject and relation selectors, and the expectation → violating-fixture map
+ * @position Contract self-test data for alert-dialog.jsdom.test.ts and alert-dialog.chromium.spec.ts
+ */
+
+import type {AlertDialogStateFacts} from './alert-dialog';
+
+const SUBJECT_ATTRIBUTE = 'data-a11y-subject';
+export const SUBJECT_SELECTOR = `[${SUBJECT_ATTRIBUTE}]`;
+export const RELATION_SELECTORS = {
+ message: '[data-a11y-relation~="message"]',
+ cancel: '[data-a11y-relation~="cancel"]',
+} as const;
+export const INVOKER_SELECTOR = '[data-a11y-relation~="invoker"]';
+
+export interface AlertDialogFixture {
+ readonly id: string;
+ readonly summary: string;
+ readonly facts: AlertDialogStateFacts;
+ readonly html: string;
+}
+
+const SCRIPT = `<script>
+(() => {
+ const surface = document.querySelector('[${SUBJECT_ATTRIBUTE}]');
+ const invoker = document.querySelector('${INVOKER_SELECTOR}');
+ invoker.addEventListener('click', () => {
+ if (window.__alertNonModal) surface.show(); else surface.showModal();
+ const first = surface.querySelector(window.__alertFocusesAction ? '[data-a11y-relation~="action"]' : '[data-a11y-relation~="cancel"]');
+ if (first) first.focus();
+ });
+ // The browser's own close request (Escape) is answered by the fixture's
+ // rule, like a component would.
+ surface.addEventListener('cancel', e => {
+ e.preventDefault();
+ if (!window.__alertIgnoresEscape) surface.close();
+ });
+ // A click on the backdrop targets the dialog element itself.
+ surface.addEventListener('click', e => {
+ if (e.target === surface && window.__alertClosesOnBackdrop) surface.close();
+ });
+ surface.querySelector('[data-a11y-relation~="cancel"]').addEventListener('click', () => surface.close());
+})();
+</script>`;
+
+function surface({
+ role = 'alertdialog' as string | null,
+ labelledBy = 'title' as string | null,
+ describedBy = 'message' as string | null,
+ message = 'This permanently deletes the report and its 12 comments.',
+}: {
+ role?: string | null;
+ labelledBy?: string | null;
+ describedBy?: string | null;
+ message?: string;
+} = {}): string {
+ return `<button type="button" data-a11y-relation="invoker">Delete report</button><dialog ${SUBJECT_ATTRIBUTE}${role == null ? '' : ` role="${role}"`}${labelledBy == null ? '' : ` aria-labelledby="${labelledBy}"`}${describedBy == null ? '' : ` aria-describedby="${describedBy}"`}><h2 id="title">Delete this report?</h2><p id="message" data-a11y-relation="message">${message}</p><div><button type="button" data-a11y-relation="cancel">Cancel</button><button type="button" data-a11y-relation="action">Delete</button></div></dialog>${SCRIPT}`;
+}
+
+const facts = (
+ overrides: Partial<AlertDialogStateFacts> = {},
+): AlertDialogStateFacts => ({
+ modal: true,
+ dismissesOnEscape: true,
+ dismissesOnBackdrop: false,
+ ...overrides,
+});
+
+const flag = (name: string, html: string) =>
+ html.replace('<script>', `<script>window.${name} = true;</script><script>`);
+
+export const ALERT_DIALOG_FIXTURES: readonly AlertDialogFixture[] = [
+ {
+ id: 'conforming-confirm',
+ summary:
+ 'a modal confirmation named by its title, described by its message, opening on Cancel, Escape closes, a click beside it does nothing',
+ facts: facts(),
+ html: surface(),
+ },
+ {
+ id: 'violating-role-dialog',
+ summary: 'a confirmation exposed as a plain dialog',
+ facts: facts(),
+ html: surface({role: null}),
+ },
+ {
+ id: 'violating-no-name',
+ summary: 'a confirmation with no accessible name',
+ facts: facts(),
+ html: surface({labelledBy: null}),
+ },
+ {
+ id: 'violating-no-description',
+ summary: 'a confirmation with no aria-describedby',
+ facts: facts(),
+ html: surface({describedBy: null}),
+ },
+ {
+ id: 'violating-description-dangling',
+ summary:
+ 'a confirmation whose aria-describedby names an element that is not the message',
+ facts: facts(),
+ html: surface({describedBy: 'title'}),
+ },
+ {
+ id: 'violating-empty-message',
+ summary: 'a confirmation whose referenced message is empty',
+ facts: facts(),
+ html: surface({message: ''}),
+ },
+ {
+ id: 'violating-nonmodal',
+ summary: 'a confirmation presented without modality',
+ facts: facts(),
+ html: flag('__alertNonModal', surface()),
+ },
+ {
+ id: 'violating-focus-on-action',
+ summary: 'a confirmation that opens with focus on the destructive action',
+ facts: facts(),
+ html: flag('__alertFocusesAction', surface()),
+ },
+ {
+ id: 'violating-escape-ignored',
+ summary:
+ 'a confirmation that swallows Escape although it is meant to close',
+ facts: facts(),
+ html: flag('__alertIgnoresEscape', surface()),
+ },
+ {
+ id: 'violating-backdrop-closes',
+ summary: 'a confirmation that a click beside it dismisses',
+ facts: facts(),
+ html: flag('__alertClosesOnBackdrop', surface()),
+ },
+];
+
+export function fixture(id: string): AlertDialogFixture {
+ const found = ALERT_DIALOG_FIXTURES.find(candidate => candidate.id === id);
+ if (found == null) {
+ throw new Error(`unknown alert-dialog fixture "${id}"`);
+ }
+ return found;
+}
+
+export const CONFORMING_FIXTURES: readonly string[] =
+ ALERT_DIALOG_FIXTURES.filter(candidate =>
+ candidate.id.startsWith('conforming-'),
+ ).map(candidate => candidate.id);
+
+export const ALERT_DIALOG_MUTATIONS: Readonly<
+ Record<string, readonly string[]>
+> = {
+ 'alertdialog.role.exposed': ['violating-role-dialog'],
+ 'alertdialog.name.exposed': ['violating-no-name'],
+ 'alertdialog.description.references-message': [
+ 'violating-no-description',
+ 'violating-description-dangling',
+ 'violating-empty-message',
+ ],
+ 'alertdialog.modal.exposed': ['violating-nonmodal'],
+ 'alertdialog.focus.least-destructive-first': ['violating-focus-on-action'],
+ 'alertdialog.keys.escape': ['violating-escape-ignored'],
+ 'alertdialog.dismissal.click-beside-is-inert': ['violating-backdrop-closes'],
+};
diff --git a/internal/a11y-spec/src/patterns/alert-dialog.jsdom.test.ts b/internal/a11y-spec/src/patterns/alert-dialog.jsdom.test.ts
new file mode 100644
index 0000000000..fda427bcbc
--- /dev/null
+++ b/internal/a11y-spec/src/patterns/alert-dialog.jsdom.test.ts
@@ -0,0 +1,163 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+/** @vitest-environment jsdom */
+
+/**
+ * @file alert-dialog.jsdom.test.ts
+ * @input ALERT_DIALOG_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 {ALERT_DIALOG_PATTERN} from './alert-dialog';
+import {
+ ALERT_DIALOG_MUTATIONS,
+ CONFORMING_FIXTURES,
+ RELATION_SELECTORS,
+ SUBJECT_SELECTOR,
+ fixture,
+ type AlertDialogFixture,
+} from './alert-dialog.fixtures';
+
+const observableHere = ALERT_DIALOG_PATTERN.expectations.filter(expectation =>
+ requiredLayers(expectation).every(layer => JSDOM_OBSERVES.includes(layer)),
+);
+
+afterEach(() => document.body.replaceChildren());
+
+async function resultsFor(target: AlertDialogFixture) {
+ const container = document.createElement('div');
+ document.body.append(container);
+ const result = await checkAccessibilitySpec({
+ spec: ALERT_DIALOG_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`);
+ }
+ const related: Record<string, Element> = {};
+ for (const [name, selector] of Object.entries(RELATION_SELECTORS)) {
+ const element = container.querySelector(selector);
+ if (element != null) {
+ related[name] = element;
+ }
+ }
+ 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('alert-dialog contract — completeness', () => {
+ it('answers every completeness dimension', () => {
+ expect(unansweredDimensions(ALERT_DIALOG_PATTERN)).toEqual([]);
+ });
+
+ it('gives every expectation at least one deliberately violating fixture', () => {
+ const missing = ALERT_DIALOG_PATTERN.expectations
+ .filter(
+ expectation =>
+ (ALERT_DIALOG_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(
+ ALERT_DIALOG_PATTERN.expectations.map(expectation => expectation.id),
+ );
+ expect(
+ Object.keys(ALERT_DIALOG_MUTATIONS).filter(id => !ids.has(id)),
+ ).toEqual([]);
+ });
+
+ it('names every fixture it records a mutation against', () => {
+ for (const fixtures of Object.values(ALERT_DIALOG_MUTATIONS)) {
+ for (const id of fixtures) {
+ expect(() => fixture(id)).not.toThrow();
+ }
+ }
+ });
+});
+
+describe('alert-dialog 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-confirm'));
+ 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 = ALERT_DIALOG_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((ALERT_DIALOG_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(
+ ALERT_DIALOG_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/alert-dialog.ts b/internal/a11y-spec/src/patterns/alert-dialog.ts
new file mode 100644
index 0000000000..c49be45c63
--- /dev/null
+++ b/internal/a11y-spec/src/patterns/alert-dialog.ts
@@ -0,0 +1,457 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file alert-dialog.ts
+ * @input WCAG 2.2 A/AA success criteria and the APG Alert Dialog pattern's role, name, description, modality, focus, and dismissal requirements
+ * @output ALERT_DIALOG_PATTERN — the reusable contract a confirmation surface binds to when it adopts the pattern (AlertDialog under component:AlertDialog AR1, `spec:AST-020/FR15`)
+ * @position Pattern contract; bound by AlertDialog. Modal mechanics (top layer, inert page, focus restoration) stay with the modal-dialog contract the composed Dialog binds
+ */
+
+import {
+ definePattern,
+ type ApgRequirement,
+ type PatternContract,
+ type WcagCriterion,
+} from '../contract';
+
+const APG_URL = 'https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/';
+const APG_DIALOG_URL = 'https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/';
+const UNDERSTANDING = 'https://www.w3.org/WAI/WCAG22/Understanding';
+
+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 WCAG_2_1_1: WcagCriterion = {
+ standard: 'wcag',
+ id: '2.1.1',
+ name: 'Keyboard',
+ level: 'A',
+ url: `${UNDERSTANDING}/keyboard.html`,
+};
+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 apgReq = (requirement: string, anchor: string): ApgRequirement => ({
+ standard: 'apg',
+ pattern: 'alertdialog',
+ requirement,
+ url: `${APG_URL}#${anchor}`,
+});
+// The Alert Dialog page defers keyboard behaviour to the Dialog (Modal)
+// pattern; its focus note and Escape row are quoted from that page.
+const apgDialogReq = (requirement: string, anchor: string): ApgRequirement => ({
+ standard: 'apg',
+ pattern: 'dialog-modal',
+ requirement,
+ url: `${APG_DIALOG_URL}#${anchor}`,
+});
+const A = 'wai-ariaroles,states,andproperties';
+const K = 'keyboardinteraction';
+const APG_ROLE = apgReq(
+ 'The element that contains all elements of the dialog, including the alert message and any dialog buttons, has role alertdialog.',
+ A,
+);
+const APG_NAME = apgReq(
+ 'The element with role alertdialog has either a value for aria-labelledby that refers to the element containing the title of the dialog if the dialog has a visible label, or a value for aria-label if the dialog does not have a visible label.',
+ A,
+);
+const APG_DESCRIPTION = apgReq(
+ 'The element with role alertdialog has a value set for aria-describedby that refers to the element containing the alert message.',
+ A,
+);
+const APG_MODAL = apgReq(
+ "An alert dialog is a modal dialog that interrupts the user's workflow to communicate an important message and acquire a response.",
+ 'about-this-pattern',
+);
+const APG_FOCUS = apgDialogReq(
+ 'When a dialog opens, focus moves to an element contained in the dialog. Generally, focus is initially set on the first focusable element. However, the most appropriate focus placement will depend on the nature and size of the content. [...] it may be advisable to set focus on the least destructive action.',
+ K,
+);
+const APG_ESCAPE = apgDialogReq('Escape: Closes the dialog.', K);
+
+/**
+ * What a binding knows about one alert dialog (the subject). The binding also
+ * designates two related subjects: `message`, the element the surface is
+ * described by, and `cancel`, the least destructive action.
+ */
+export interface AlertDialogStateFacts {
+ /** Whether the surface is presented as a modal dialog (an inline preview is not). */
+ readonly modal: boolean;
+ /** Whether Escape is meant to close it. */
+ readonly dismissesOnEscape: boolean;
+ /** Whether a click beside it (on the dimmed page) is meant to close it. */
+ readonly dismissesOnBackdrop: boolean;
+}
+
+const MODAL_ONLY = {
+ condition: 'the binding presents the surface as a modal alert dialog',
+ test: (facts: AlertDialogStateFacts) => facts.modal,
+};
+
+export const ALERT_DIALOG_PATTERN: PatternContract<AlertDialogStateFacts> =
+ definePattern<AlertDialogStateFacts>({
+ pattern: 'alertdialog',
+ url: APG_URL,
+ scope:
+ "A confirmation surface's alertdialog role, its title and message references, its modality, where focus lands when it opens, and whether Escape and a click beside it dismiss it. Top-layer, inert-page and focus-restoration mechanics belong to the modal-dialog contract the composed Dialog binds.",
+ expectations: [
+ {
+ id: 'alertdialog.role.exposed',
+ outcome:
+ 'The browser exposes the surface as an alert dialog, so a screen reader announces it as an interruption that needs an answer.',
+ sources: [WCAG_4_1_2, APG_ROLE],
+ covers: ['4.1.2-name-role-value', 'apg-interaction'],
+ appliesWhen: MODAL_ONLY,
+ evidenceLayer: 'accessibility-tree',
+ enforcement: 'required',
+ run: async ({subject}) => {
+ const {role} = await subject.computed();
+ if (role !== 'alertdialog') {
+ throw new Error(
+ role == null
+ ? 'the browser exposes no role for this surface'
+ : `the browser reports this surface as "${role}", not as an alert dialog`,
+ );
+ }
+ },
+ },
+ {
+ id: 'alertdialog.name.exposed',
+ outcome:
+ 'The surface is named by its title, so a user hears what they are being asked.',
+ sources: [WCAG_4_1_2, APG_NAME],
+ covers: [
+ '4.1.2-name-role-value',
+ '2.4.6-headings-and-labels',
+ 'apg-interaction',
+ ],
+ appliesWhen: MODAL_ONLY,
+ evidenceLayer: 'accessibility-tree',
+ enforcement: 'required',
+ run: async ({subject}) => {
+ const {name} = await subject.computed();
+ if (!name || name.trim() === '') {
+ throw new Error(
+ 'the browser computes no accessible name for this surface',
+ );
+ }
+ },
+ },
+ {
+ id: 'alertdialog.description.references-message',
+ outcome:
+ 'The surface is described by its message, so a screen reader reads the consequence with the title.',
+ sources: [WCAG_1_3_1, APG_DESCRIPTION],
+ covers: ['1.3.1-info-and-relationships', 'apg-interaction'],
+ appliesWhen: MODAL_ONLY,
+ evidenceLayer: 'dom',
+ enforcement: 'required',
+ run: async ({harness, subject}) => {
+ const describedBy = await subject.attribute('aria-describedby');
+ if (describedBy == null || describedBy.trim() === '') {
+ throw new Error('the surface carries no aria-describedby');
+ }
+ const message = await harness.related('message');
+ if (
+ !(await harness.references(subject, 'aria-describedby', message))
+ ) {
+ throw new Error(
+ `aria-describedby points at "${describedBy}", not at the message the binding designates`,
+ );
+ }
+ const text = (await message.textContent()).trim();
+ if (text === '') {
+ throw new Error('the referenced message is empty');
+ }
+ },
+ },
+ {
+ id: 'alertdialog.modal.exposed',
+ outcome:
+ 'The surface is modal, so the page behind it is out of reach until the user answers.',
+ sources: [WCAG_4_1_2, APG_MODAL],
+ covers: ['4.1.2-name-role-value', 'apg-interaction'],
+ appliesWhen: MODAL_ONLY,
+ evidenceLayer: 'real-browser',
+ enforcement: 'required',
+ run: async ({subject}) => {
+ if (!(await subject.isModal())) {
+ throw new Error(
+ 'the surface is not an active modal in the top layer',
+ );
+ }
+ },
+ },
+ {
+ id: 'alertdialog.focus.least-destructive-first',
+ outcome:
+ 'Focus opens on the least destructive action, so Enter never confirms the irreversible step by accident.',
+ sources: [APG_FOCUS],
+ wcagOutcome:
+ 'Supports WCAG 2.2 2.4.3 by putting focus on the safe choice first; the APG guides which control, so this row is advisory until the binding record is current (AST-020 FR9).',
+ covers: ['2.4.3-focus-order', 'apg-interaction'],
+ appliesWhen: MODAL_ONLY,
+ evidenceLayer: 'real-browser',
+ enforcement: 'advisory',
+ advisoryBecause:
+ "Which control takes initial focus is APG guidance, adopted by the binding's draft record; required once that record is current (AST-020 FR9).",
+ run: async ({harness}) => {
+ const cancel = await harness.related('cancel');
+ if (!(await cancel.isFocused())) {
+ throw new Error(
+ 'the least destructive action does not hold focus when the surface opens',
+ );
+ }
+ },
+ },
+ {
+ id: 'alertdialog.keys.escape',
+ outcome:
+ 'Escape closes the surface when the binding allows it, so a keyboard user can back out without finding Cancel.',
+ sources: [WCAG_2_1_1, APG_ESCAPE],
+ covers: ['2.1.1-keyboard', 'apg-interaction'],
+ appliesWhen: {
+ condition: 'the surface is modal and Escape is meant to close it',
+ test: facts => facts.modal && facts.dismissesOnEscape,
+ },
+ evidenceLayer: 'real-browser',
+ alsoNeeds: ['dom'],
+ enforcement: 'required',
+ run: async ({harness, subject}) => {
+ const cancel = await harness.related('cancel');
+ await cancel.focus();
+ await harness.press('Escape');
+ if (await subject.isVisible()) {
+ throw new Error('Escape left the surface open');
+ }
+ },
+ },
+ {
+ id: 'alertdialog.dismissal.click-beside-is-inert',
+ outcome:
+ 'A click on the dimmed page beside the surface does not dismiss it, so an accidental click never discards the decision.',
+ sources: [APG_MODAL],
+ wcagOutcome:
+ "Keeps the question on screen until the user answers it, so a stray click cannot discard an irreversible choice unanswered (APG Alert Dialog: a modal that interrupts the workflow to acquire a response). No WCAG success criterion maps to it — 3.2.2 covers changing a control's setting, which a click beside the dialog is not; the binding record states the rule, so this row is advisory until it is current (AST-020 FR9).",
+ covers: ['apg-interaction'],
+ appliesWhen: {
+ condition:
+ 'the surface is modal and a click beside it is not meant to close it',
+ test: facts => facts.modal && !facts.dismissesOnBackdrop,
+ },
+ evidenceLayer: 'real-browser',
+ alsoNeeds: ['dom'],
+ enforcement: 'advisory',
+ advisoryBecause:
+ "The no-backdrop-dismissal rule is the binding record's, not an APG requirement; required once that record is current (AST-020 FR9).",
+ run: async ({harness, subject}) => {
+ await harness.clickBeside(subject);
+ if (!(await subject.isVisible())) {
+ throw new Error('a click beside the surface dismissed it');
+ }
+ },
+ },
+ ],
+ exemptions: {
+ '1.1.1-non-text-content': {
+ owner: 'the binding component',
+ verifiedBy:
+ "the component's decorative-icon tests and the repository axe audit, `pnpm a11y:audit`",
+ reason:
+ "This contract owns the surface's semantics and dismissal. Any icon the binding paints beside the title is decorative composition.",
+ },
+ '1.3.1-info-and-relationships': {
+ owner: 'the binding component',
+ verifiedBy: "the component's title and description association tests",
+ reason:
+ 'This contract proves the surface is described by its message; the title relationship is proven through the computed name.',
+ coversRemainderOnly: true,
+ },
+ '1.3.2-meaningful-sequence': {
+ owner: 'the binding component',
+ verifiedBy: "the component's anatomy order tests",
+ reason:
+ "Title, message, then buttons is the binding's anatomy, proven by its own tests; the button order is a layout rule of the binding record.",
+ },
+ '1.3.5-identify-input-purpose': {
+ owner: 'not applicable',
+ verifiedBy: 'none needed',
+ reason:
+ 'An alert dialog collects a yes or no, not information about the user.',
+ },
+ '1.4.1-use-of-color': {
+ owner: 'the binding component and theme',
+ verifiedBy: "the component's action-variant tests plus rendered review",
+ reason:
+ "The destructive action's colour is a paint result owned by the binding and theme; its label carries the meaning.",
+ },
+ '1.4.3-contrast-minimum': {
+ owner: 'the binding component and theme',
+ verifiedBy: 'the repository axe audit plus rendered contrast review',
+ reason:
+ 'Title, message and button text contrast is a paint outcome owned by the binding and theme.',
+ },
+ '1.4.11-non-text-contrast': {
+ owner: 'the binding component and theme',
+ verifiedBy:
+ 'the repository axe audit plus rendered review of the surface edge and focus indicator',
+ reason:
+ 'Surface edge and focus indicator contrast are paint outcomes owned by the binding and theme.',
+ },
+ '2.1.1-keyboard': {
+ owner:
+ 'the modal-dialog contract through the composed Dialog, and the button pattern',
+ verifiedBy:
+ "MODAL_DIALOG_PATTERN bound by Dialog, BUTTON_PATTERN for the buttons, plus this contract's Escape row",
+ reason:
+ "This contract encodes Escape. Tab containment inside the surface is the modal-dialog contract's, and the buttons' own activation is the button pattern's.",
+ coversRemainderOnly: true,
+ },
+ '2.1.2-no-keyboard-trap': {
+ owner: 'the modal-dialog contract through the composed Dialog',
+ verifiedBy:
+ "MODAL_DIALOG_PATTERN bound by Dialog, plus this contract's Escape row",
+ reason:
+ 'A modal surface may contain Tab by design; leaving it is Escape or a button, which this contract and the modal-dialog contract prove.',
+ },
+ '2.4.2-page-titled': {
+ owner: 'the page',
+ verifiedBy: 'page-level review',
+ reason: 'An alert dialog rendered in isolation owns no document title.',
+ },
+ '2.4.3-focus-order': {
+ owner: 'the modal-dialog contract through the composed Dialog',
+ verifiedBy:
+ 'MODAL_DIALOG_PATTERN bound by Dialog (focus enters after modal presentation and returns to the opener on close)',
+ reason:
+ "This contract proves where focus lands first; entering and restoring focus are the modal-dialog contract's.",
+ coversRemainderOnly: true,
+ },
+ '2.4.4-link-purpose': {
+ owner: 'not applicable',
+ verifiedBy: 'none needed',
+ reason: 'An alert dialog renders no link.',
+ },
+ '2.4.6-headings-and-labels': {
+ owner: 'the binding component and caller content',
+ verifiedBy: "the component's name tests and caller content review",
+ reason:
+ 'This contract proves the surface is named by its title; whether that title is descriptive is caller content.',
+ coversRemainderOnly: true,
+ },
+ '2.4.7-focus-visible': {
+ owner: 'the Button binding and theme',
+ verifiedBy: "Button's focus-outline tests and rendered focus review",
+ reason:
+ "The focused button's indicator is a paint result owned by the Button binding and theme.",
+ },
+ '2.4.11-focus-not-obscured': {
+ owner: 'the binding component',
+ verifiedBy: "the component's top-layer rendering through Dialog",
+ reason:
+ 'A modal surface sits in the top layer; nothing in the page can cover it.',
+ },
+ '2.5.2-pointer-cancellation': {
+ owner: 'the button pattern',
+ verifiedBy: 'BUTTON_PATTERN for the Cancel and action controls',
+ reason: "The buttons' press cancellation is the button pattern's.",
+ },
+ '2.5.3-label-in-name': {
+ owner: 'the binding component',
+ verifiedBy: "the component's accessible-name tests",
+ reason:
+ "The surface's name is its visible title through aria-labelledby, proven by the computed name.",
+ },
+ '2.5.8-target-size': {
+ owner: 'the Button binding and theme',
+ verifiedBy:
+ "the repository axe audit's target-size rule over the buttons",
+ reason:
+ "The buttons' hit areas are geometry owned by the Button binding and theme.",
+ },
+ '3.1.1-language-of-page': {
+ owner: 'the page',
+ verifiedBy: 'page-level review',
+ reason: 'An alert dialog owns no document language.',
+ },
+ '3.2.2-on-input': {
+ owner: 'the caller and composing page',
+ verifiedBy:
+ 'integration review of what a caller does with onAction and in response to the dialog closing',
+ reason:
+ "3.2.2 governs changing the setting of a user interface component; an alert dialog has no setting to change, and a click beside it is not input to a control. What the confirmed action does, and whether closing the dialog changes context, is the caller's and the composing page's.",
+ },
+ '3.2.4-consistent-identification': {
+ owner: 'the composing page',
+ verifiedBy:
+ 'this shared contract across bindings plus content review of repeated confirmation wording',
+ reason:
+ 'Consistency is a property of the full set of repeated functions, not one isolated alert dialog.',
+ },
+ '3.3.1-error-identification': {
+ owner: 'not applicable',
+ verifiedBy: 'none needed',
+ reason: 'An alert dialog collects no input that could be in error.',
+ },
+ '3.3.2-labels-or-instructions': {
+ owner: 'not applicable',
+ verifiedBy: 'none needed',
+ reason:
+ 'An alert dialog collects no user input that needs form instructions.',
+ },
+ '4.1.2-name-role-value': {
+ owner: 'the binding component and the button pattern',
+ verifiedBy:
+ "the component's inline-preview (role group) and loading-action tests, BUTTON_PATTERN for the buttons",
+ reason:
+ "This contract encodes the surface's role, name and modality. The inline preview's group role and the buttons' states are the binding's and the button pattern's.",
+ coversRemainderOnly: true,
+ },
+ '4.1.3-status-messages': {
+ owner:
+ 'the caller and the assistive-technology verification record, spec:AST-009',
+ verifiedBy:
+ 'the status-message pattern and real-AT evidence under AST-009 when a change claims spoken or braille output',
+ reason:
+ 'An alert dialog takes focus; it is not a live-region status message and makes no announcement claim.',
+ },
+ 'apg-interaction': {
+ owner: "the binding component's record",
+ verifiedBy:
+ 'component:AlertDialog AR1, which adopts the pattern and delegates modal mechanics to component:Dialog',
+ reason:
+ "This contract encodes the alert dialog's role, references, modality, initial focus and dismissal. Top layer, inert page and focus restoration are the modal-dialog contract's.",
+ coversRemainderOnly: true,
+ },
+ 'forced-colors': {
+ owner: 'the binding component and theme',
+ verifiedBy:
+ "the component's forced-colors tests plus rendered Windows High Contrast review",
+ reason:
+ 'Forced-colors output is a paint result owned by the binding and theme.',
+ },
+ 'reduced-motion': {
+ owner: 'the binding component and theme',
+ verifiedBy:
+ "the component's reduced-motion source tests and rendered motion review",
+ reason:
+ 'Open and close motion is binding-specific paint over time and is not part of alert-dialog semantics.',
+ },
+ 'at-facing-strings': {
+ owner: 'the caller',
+ verifiedBy:
+ 'content review of authored titles, messages and button labels',
+ reason:
+ 'The alert-dialog contract introduces no string; title, message and button labels come from the caller.',
+ },
+ },
+ });
diff --git a/packages/core/src/AlertDialog/AlertDialog.test.tsx b/packages/core/src/AlertDialog/AlertDialog.test.tsx
index 1ef12a27a2..1c88d6a6d0 100644
--- a/packages/core/src/AlertDialog/AlertDialog.test.tsx
+++ b/packages/core/src/AlertDialog/AlertDialog.test.tsx
@@ -93,11 +93,9 @@ describe('AlertDialog', () => {
onAction: vi.fn(),
};
- it('renders with alertdialog role', () => {
- render(<AlertDialog {...defaultProps} />);
- expect(screen.getByRole('alertdialog')).toBeInTheDocument();
- });
-
+ // The alertdialog role and the aria-describedby link are asserted by the
+ // Alert Dialog accessibility contract binding (AlertDialog.a11y.test.tsx /
+ // .chromium.spec.ts), not here.
it('renders title and description', () => {
render(<AlertDialog {...defaultProps} />);
expect(screen.getByText('Delete item?')).toBeInTheDocument();
@@ -115,15 +113,6 @@ describe('AlertDialog', () => {
expect(titleEl).toHaveTextContent('Delete item?');
});
- it('links description via aria-describedby', () => {
- render(<AlertDialog {...defaultProps} />);
- const dialog = screen.getByRole('alertdialog');
- const describedBy = dialog.getAttribute('aria-describedby');
- expect(describedBy).toBeTruthy();
- const descEl = document.getElementById(describedBy!);
- expect(descEl).toHaveTextContent('This action cannot be undone.');
- });
-
it('renders cancel and action buttons', () => {
render(<AlertDialog {...defaultProps} />);
expect(screen.getByText('Cancel')).toBeInTheDocument();
diff --git a/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts
new file mode 100644
index 0000000000..fb5f85ccaa
--- /dev/null
+++ b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts
@@ -0,0 +1,115 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file AlertDialog.a11y.chromium.spec.ts
+ * @input Built AlertDialog stories and ALERT_DIALOG_PATTERN in real Chromium
+ * @output Browser evidence for every alert-dialog expectation across the binding's states, the surface opened through its opener the way a person reaches it
+ * @position Chromium lane of the AlertDialog binding (component:AlertDialog AR1)
+ */
+
+import {
+ expect,
+ test,
+ type CDPSession,
+ type Locator,
+ type Page,
+} from '@playwright/test';
+import {
+ ALERT_DIALOG_PATTERN,
+ blockingResults,
+ checkAccessibilitySpec,
+ formatFailures,
+ neverExercised,
+ summarize,
+ 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 {
+ ALERT_DIALOG_BINDING_STATES,
+ ALERT_DIALOG_CANCEL_LABEL,
+ ALERT_DIALOG_MESSAGE,
+ ALERT_DIALOG_OPEN_LABEL,
+ type AlertDialogBindingState,
+} from './AlertDialog.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: AlertDialogBindingState,
+): Promise<{subject: Locator; related: Record<string, Locator>}> {
+ await page.goto(storyUrl(state.storyId), {waitUntil: 'load'});
+ await holdMotionStill(page);
+ const root = page.locator('#storybook-root');
+ const subject = root.locator('dialog');
+ await root.getByRole('button', {name: ALERT_DIALOG_OPEN_LABEL}).click();
+ await subject.waitFor({state: 'visible'});
+ const message = subject.getByText(ALERT_DIALOG_MESSAGE);
+ const cancel = subject.getByRole('button', {
+ name: ALERT_DIALOG_CANCEL_LABEL,
+ });
+ return {subject, related: {message, cancel}};
+}
+
+async function runState(
+ page: Page,
+ cdp: CDPSession,
+ state: AlertDialogBindingState,
+): Promise<BindingResult> {
+ return checkAccessibilitySpec({
+ spec: ALERT_DIALOG_PATTERN,
+ binding: 'AlertDialog',
+ state: state.id,
+ facts: state.facts,
+ mount: async () => {
+ const {subject, related} = await mountState(page, state);
+ return createChromiumHarness({page, cdp, subject, related});
+ },
+ });
+}
+
+test('every alert-dialog expectation is exercised by an AlertDialog state', async ({
+ page,
+}) => {
+ const cdp = await page.context().newCDPSession(page);
+ const results: BindingResult[] = [];
+ for (const state of ALERT_DIALOG_BINDING_STATES) {
+ results.push(await runState(page, cdp, state));
+ }
+ expect(neverExercised(results)).toEqual([]);
+});
+
+for (const state of ALERT_DIALOG_BINDING_STATES) {
+ test(`AlertDialog [${state.id}] — ${state.summary}`, async ({page}) => {
+ const cdp = await page.context().newCDPSession(page);
+ const result = await runState(page, cdp, state);
+ const report = summarize(ALERT_DIALOG_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/AlertDialog/__tests__/AlertDialog.a11y.renders.tsx b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.renders.tsx
new file mode 100644
index 0000000000..bcbc93f13b
--- /dev/null
+++ b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.renders.tsx
@@ -0,0 +1,52 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file AlertDialog.a11y.renders.tsx
+ * @input One AlertDialog binding state
+ * @output The React tree every lane renders for that state: an opener button and the AlertDialog it opens (the jsdom test directly, the story through Storybook)
+ * @position Shared fixture for the AlertDialog binding
+ */
+
+import {useState, type ReactElement} from 'react';
+import {AlertDialog} from '../AlertDialog';
+import {
+ ALERT_DIALOG_ACTION_LABEL,
+ ALERT_DIALOG_CANCEL_LABEL,
+ ALERT_DIALOG_MESSAGE,
+ ALERT_DIALOG_OPEN_LABEL,
+ ALERT_DIALOG_TITLE,
+ type AlertDialogBindingState,
+} from './AlertDialog.a11y.states';
+
+function BoundAlertDialog({state}: {state: AlertDialogBindingState}) {
+ const [isOpen, setIsOpen] = useState(false);
+ return (
+ <>
+ <button type="button" onClick={() => setIsOpen(true)}>
+ {ALERT_DIALOG_OPEN_LABEL}
+ </button>
+ <AlertDialog
+ isOpen={isOpen}
+ onOpenChange={setIsOpen}
+ title={ALERT_DIALOG_TITLE}
+ description={ALERT_DIALOG_MESSAGE}
+ cancelLabel={ALERT_DIALOG_CANCEL_LABEL}
+ actionLabel={ALERT_DIALOG_ACTION_LABEL}
+ isActionLoading={state.isActionLoading}
+ onAction={() => setIsOpen(false)}
+ />
+ </>
+ );
+}
+
+export function renderAlertDialogState(
+ state: AlertDialogBindingState,
+): ReactElement {
+ return (
+ <div style={{padding: 24}}>
+ <BoundAlertDialog state={state} />
+ </div>
+ );
+}
diff --git a/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.states.ts b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.states.ts
new file mode 100644
index 0000000000..b022c123d2
--- /dev/null
+++ b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.states.ts
@@ -0,0 +1,68 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file AlertDialog.a11y.states.ts
+ * @input AlertDialog's representative modal states and the facts ALERT_DIALOG_PATTERN reads
+ * @output ALERT_DIALOG_BINDING_STATES, the shared labels, and the explicit ownership exclusions for this binding
+ * @position Binding inventory shared by the jsdom test, the Chromium spec, and the story (component:AlertDialog AR1)
+ */
+
+import type {AlertDialogStateFacts} from '@astryxdesign/a11y-spec';
+
+export const ALERT_DIALOG_OPEN_LABEL = 'Delete report';
+export const ALERT_DIALOG_TITLE = 'Delete this report?';
+export const ALERT_DIALOG_MESSAGE =
+ 'This permanently deletes the report and its 12 comments.';
+export const ALERT_DIALOG_CANCEL_LABEL = 'Keep report';
+export const ALERT_DIALOG_ACTION_LABEL = 'Delete';
+
+export interface AlertDialogBindingState {
+ readonly id: string;
+ readonly summary: string;
+ readonly storyId: string;
+ readonly facts: AlertDialogStateFacts;
+ readonly isActionLoading?: boolean;
+}
+
+const facts: AlertDialogStateFacts = {
+ modal: true,
+ // Dialog `purpose="form"`: Escape closes, a backdrop click does nothing.
+ dismissesOnEscape: true,
+ dismissesOnBackdrop: false,
+};
+
+const story = (id: string) => `a11y-alertdialog--${id}`;
+
+export const ALERT_DIALOG_BINDING_STATES = [
+ {
+ id: 'modal-confirm',
+ summary:
+ 'a modal AlertDialog with a destructive action, opened from a button',
+ storyId: story('modal-confirm'),
+ facts,
+ },
+ {
+ id: 'modal-action-loading',
+ summary:
+ 'the same AlertDialog while its action is loading: Cancel stays the first focus and Escape still cancels',
+ storyId: story('modal-action-loading'),
+ facts,
+ isActionLoading: true,
+ },
+] as const satisfies ReadonlyArray<AlertDialogBindingState>;
+
+export const ALERT_DIALOG_EXCLUSIONS = [
+ {
+ id: 'modal-mechanics',
+ owner:
+ 'MODAL_DIALOG_PATTERN bound by Dialog (Dialog.a11y.test.tsx and its Chromium spec)',
+ reason:
+ 'AlertDialog composes Dialog for the top layer, the inert page behind it, focus entering after modal presentation, and focus returning to the opener on close. Those outcomes are proven once on Dialog; this binding proves only what the alert dialog adds: its role, references, modality claim, initial focus on Cancel, and its dismissal rules.',
+ },
+ {
+ id: 'inline-preview',
+ owner: 'AlertDialog.test.tsx (inline preview suite)',
+ reason:
+ 'The `isInline` preview renders the same anatomy as a plain `role="group"` without modality; it is not an alert dialog and makes none of this pattern\'s claims, so it is not a binding state.',
+ },
+] as const;
diff --git a/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.test.tsx b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.test.tsx
new file mode 100644
index 0000000000..dc1fac0c01
--- /dev/null
+++ b/packages/core/src/AlertDialog/__tests__/AlertDialog.a11y.test.tsx
@@ -0,0 +1,144 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+/** @vitest-environment jsdom */
+
+/**
+ * @file AlertDialog.a11y.test.tsx
+ * @input ALERT_DIALOG_PATTERN bound to AlertDialog's representative states
+ * @output jsdom-lane proof of the DOM expectation (the description reference) and an honest "unrun" report for the browser layers
+ * @position Binding test for component:AlertDialog AR1 (the Chromium spec covers the rest)
+ */
+
+import {cleanup, fireEvent, render, screen} from '@testing-library/react';
+import {beforeEach, describe, expect, it, vi} from 'vitest';
+import {
+ ALERT_DIALOG_PATTERN,
+ checkAccessibilitySpec,
+ createJsdomHarness,
+ expectAccessibilitySpec,
+ summarize,
+ type BindingResult,
+} from '@astryxdesign/a11y-spec';
+import {renderAlertDialogState} from './AlertDialog.a11y.renders';
+import {
+ ALERT_DIALOG_BINDING_STATES,
+ ALERT_DIALOG_CANCEL_LABEL,
+ ALERT_DIALOG_EXCLUSIONS,
+ ALERT_DIALOG_OPEN_LABEL,
+ type AlertDialogBindingState,
+} from './AlertDialog.a11y.states';
+
+// jsdom has no native dialog methods; the DOM lane only needs the open flag.
+beforeEach(() => {
+ HTMLDialogElement.prototype.showModal = vi.fn(function (
+ this: HTMLDialogElement,
+ ) {
+ this.setAttribute('open', '');
+ });
+ HTMLDialogElement.prototype.close = vi.fn(function (this: HTMLDialogElement) {
+ this.removeAttribute('open');
+ });
+});
+
+function surface(): HTMLElement {
+ const element = document.querySelector('dialog');
+ if (element == null) {
+ throw new Error('no dialog element rendered');
+ }
+ return element;
+}
+
+function related(): Record<string, HTMLElement> {
+ const message = document.getElementById(
+ surface().getAttribute('aria-describedby') ?? '',
+ );
+ const cancel = screen.getByRole('button', {
+ name: ALERT_DIALOG_CANCEL_LABEL,
+ hidden: true,
+ });
+ return {
+ message: message ?? document.body,
+ cancel,
+ };
+}
+
+function openSurface(): void {
+ fireEvent.click(screen.getByRole('button', {name: ALERT_DIALOG_OPEN_LABEL}));
+}
+
+async function checkState(
+ state: AlertDialogBindingState,
+): Promise<BindingResult> {
+ return checkAccessibilitySpec({
+ spec: ALERT_DIALOG_PATTERN,
+ binding: 'AlertDialog',
+ state: state.id,
+ facts: state.facts,
+ mount: async () => {
+ render(renderAlertDialogState(state));
+ openSurface();
+ return createJsdomHarness({subject: surface(), related: related()});
+ },
+ unmount: cleanup,
+ });
+}
+
+describe('AlertDialog — alert dialog pattern, jsdom lane', () => {
+ it.each(
+ ALERT_DIALOG_BINDING_STATES.map(
+ state => [state.id, state.summary, state] as const,
+ ),
+ )('%s — %s', async (_id, _summary, state) => {
+ await expectAccessibilitySpec({
+ spec: ALERT_DIALOG_PATTERN,
+ binding: 'AlertDialog',
+ state: state.id,
+ facts: state.facts,
+ render: () => {
+ render(renderAlertDialogState(state));
+ },
+ subject: () => surface(),
+ related: () => related(),
+ cleanup,
+ });
+ });
+
+ it('runs the DOM layer and reports the browser-owned outcomes as unrun', async () => {
+ const results: BindingResult[] = [];
+ for (const state of ALERT_DIALOG_BINDING_STATES) {
+ results.push(await checkState(state));
+ }
+ const report = summarize(ALERT_DIALOG_PATTERN, results);
+ expect(report.counts.pass).toBeGreaterThan(0);
+ expect(report.unrunLayers).toEqual(['accessibility-tree', 'real-browser']);
+ expect(report.counts.unexpectedPass).toBe(0);
+ });
+});
+
+describe('AlertDialog binding inventory', () => {
+ it('gives every representative state a distinct checked-in story', () => {
+ const stories = ALERT_DIALOG_BINDING_STATES.map(state => state.storyId);
+ expect(new Set(stories).size).toBe(stories.length);
+ });
+
+ it('keeps modal mechanics and the inline preview explicitly owned elsewhere', () => {
+ expect(ALERT_DIALOG_EXCLUSIONS.map(exclusion => exclusion.id)).toEqual([
+ 'modal-mechanics',
+ 'inline-preview',
+ ]);
+ for (const exclusion of ALERT_DIALOG_EXCLUSIONS) {
+ expect(exclusion.owner.length, exclusion.id).toBeGreaterThan(20);
+ expect(exclusion.reason.length, exclusion.id).toBeGreaterThan(80);
+ }
+ });
+
+ it('renders the opener, the surface, its message and Cancel for every state', () => {
+ for (const state of ALERT_DIALOG_BINDING_STATES) {
+ render(renderAlertDialogState(state));
+ openSurface();
+ expect(surface(), state.id).toBeTruthy();
+ expect(related().message, state.id).not.toBe(document.body);
+ expect(related().cancel, state.id).toBeTruthy();
+ cleanup();
+ }
+ });
+});