Skip to content

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

TypeScript

test(rtl): RTL coverage for ContextMenu, TableHeaderCell, TableCell and TableSelectionToolbar (#9286)

Cindy Zhang69fb25721adb
diff --git a/apps/storybook/rtl-audit/targets.json b/apps/storybook/rtl-audit/targets.json
index d2d102d70a..2c787358c9 100644
--- a/apps/storybook/rtl-audit/targets.json
+++ b/apps/storybook/rtl-audit/targets.json
@@ -149,6 +149,49 @@
"next": "[data-testid=\"checkbox-end-content\"]"
}
},
+ {
+ "component": "ContextMenu",
+ "storyId": "core-contextmenu--bottom-sheet-submenu",
+ "dims": ["D2"],
+ "selectors": {
+ "prev": "button[aria-label=\"Back\"]",
+ "next": "h3:text-is(\"Share\")"
+ }
+ },
+ {
+ "component": "TableHeaderCell",
+ "storyId": "core-table--in-card",
+ "dims": ["D2", "D8"],
+ "selectors": {
+ "prev": "div:nth-child(2) > .astryx-card .astryx-table-header-cell:first-child",
+ "next": "div:nth-child(2) > .astryx-card .astryx-table-header-cell:last-child",
+ "subject": "div:nth-child(2) > .astryx-card .astryx-table-header-cell:first-child"
+ }
+ },
+ {
+ "component": "TableCell",
+ "storyId": "core-table--in-card",
+ "dims": ["D2", "D8"],
+ "selectors": {
+ "prev": "div:nth-child(2) > .astryx-card tbody tr:first-child > .astryx-table-cell:first-child",
+ "next": "div:nth-child(2) > .astryx-card tbody tr:first-child > .astryx-table-cell:last-child",
+ "subject": "div:nth-child(2) > .astryx-card tbody tr:first-child > .astryx-table-cell:first-child"
+ }
+ },
+ {
+ "component": "TableSelectionToolbar",
+ "storyId": "core-tableselection--bulk-actions",
+ "dims": ["D2"],
+ "selectors": {
+ "prev": "[role=\"toolbar\"][aria-label=\"Bulk actions\"] span:text-is(\"1 selected\")",
+ "next": "[role=\"toolbar\"][aria-label=\"Bulk actions\"] button:has-text(\"Unselect All\")"
+ }
+ },
+ {
+ "component": "Table",
+ "storyId": "core-table--in-card",
+ "dims": []
+ },
{
"component": "GridSpan",
"storyId": "core-gridspan--span-matrix",
diff --git a/apps/storybook/stories/ContextMenu.stories.tsx b/apps/storybook/stories/ContextMenu.stories.tsx
index 5c144b8bf4..891b4ca1c4 100644
--- a/apps/storybook/stories/ContextMenu.stories.tsx
+++ b/apps/storybook/stories/ContextMenu.stories.tsx
@@ -589,3 +589,61 @@ export const InScrollContainer: Story = {
</div>
),
};
+
+/**
+ * The BottomSheet presentation opened into a submenu. The sheet's back button
+ * points toward the previous view, so its chevron mirrors in right-to-left
+ * layouts; this story keeps that view on screen for the RTL audit.
+ */
+export const BottomSheetSubmenu: Story = {
+ name: 'Presentation / BottomSheet submenu',
+ parameters: {
+ layout: 'fullscreen',
+ viewport: {defaultViewport: 'mobile1'},
+ docs: {story: {inline: false, height: '560px'}},
+ },
+ render: () => (
+ <div style={{padding: 16}}>
+ <ContextMenu
+ data-testid="bottom-sheet-submenu-context-menu"
+ presentation="bottom-sheet"
+ label="Document actions"
+ items={[
+ {label: 'Edit', icon: PencilIcon, onClick: () => {}},
+ {
+ label: 'Share',
+ icon: ShareIcon,
+ items: [
+ {label: 'Copy link', onClick: () => {}},
+ {label: 'Email', onClick: () => {}},
+ ],
+ },
+ ]}>
+ <div {...stylex.props(triggerStyles.area)}>
+ Long-press or right-click for document actions
+ </div>
+ </ContextMenu>
+ </div>
+ ),
+ play: async ({canvasElement}) => {
+ const trigger = canvasElement.querySelector(
+ '[data-testid="bottom-sheet-submenu-context-menu"]',
+ );
+ trigger?.dispatchEvent(
+ new MouseEvent('contextmenu', {bubbles: true, clientX: 40, clientY: 40}),
+ );
+ // The sheet renders in the top layer, outside the canvas.
+ for (let attempt = 0; attempt < 40; attempt++) {
+ const share = Array.from(
+ document.body.querySelectorAll<HTMLElement>(
+ '[role="menuitem"], button',
+ ),
+ ).find(element => element.textContent?.trim() === 'Share');
+ if (share != null) {
+ share.click();
+ return;
+ }
+ await new Promise(resolve => setTimeout(resolve, 50));
+ }
+ },
+};
diff --git a/docs/specs/components/ContextMenu/ContextMenu.spec.md b/docs/specs/components/ContextMenu/ContextMenu.spec.md
index 128c44674c..a64df5f48e 100644
--- a/docs/specs/components/ContextMenu/ContextMenu.spec.md
+++ b/docs/specs/components/ContextMenu/ContextMenu.spec.md
@@ -16,6 +16,7 @@ verified_by:
packages/core/src/ContextMenu/ContextMenu.triggerProps.test.tsx,
packages/core/src/theme/themingTargets.test.ts,
scripts/check-knowledge.mjs,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families: [family:overlay-dismissal]
@@ -237,6 +238,7 @@ anchor is positioning infrastructure rather than consumer anatomy.
| FR9 | `ContextMenu.test.tsx` "lets a nested layer consume Escape before the context menu", "closes on Escape even when opened without auto-focus", and "ignores Escape during IME composition" | Nested layer; Escape; composition | A context menu that closes with its nested child, or on a composition Escape, fails. | `audit:ContextMenu/behavior` |
| FR10, PR1 | `ContextMenu.test.tsx` invocation and handler-composition cases ("composes the consumer context-menu handler with menu opening", "keeps component-owned opening when a consumer prevents default", "composes consumer touch handlers with long-press detection") | Right click, long press, keyboard | A context request that does not open the menu, or a dropped consumer handler, fails. Evidence gap: no test asserts listener cleanup on unmount; nothing tests a headless factory, which does not ship (the FR10 gap). | `audit:ContextMenu/behavior` |
| Theming anatomy map | `scripts/check-knowledge.mjs` | Canonical anatomy and target | Missing, extra, prefixed, stale, or unclassified mappings fail repository validation. | `audit:ContextMenu/theming` |
+| RTL relation | RTL audit curated D2 target (`apps/storybook/rtl-audit/targets.json`) on the `Presentation / BottomSheet submenu` story | BottomSheet opened into a submenu, LTR and RTL | The sheet header's back button not at the inline start of its heading in both directions fails D2. | `audit:ContextMenu/i18n-rtl` |
## Current-state impact
diff --git a/docs/specs/components/Table/TableCell.spec.md b/docs/specs/components/Table/TableCell.spec.md
index 4204663e84..7997fb4e54 100644
--- a/docs/specs/components/Table/TableCell.spec.md
+++ b/docs/specs/components/Table/TableCell.spec.md
@@ -19,6 +19,7 @@ verified_by:
packages/core/src/Table/__tests__/TableRowGlide.a11y.browser.spec.ts,
packages/core/src/theme/themingTargets.test.ts,
scripts/check-knowledge.mjs,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families: []
@@ -155,14 +156,15 @@ its own, so no anatomy-theming block is declared here.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
-| FR1, AR1 | `Table.test.tsx` children-mode and density-reflection tests; `themingTargets.test.ts` | Children mode; each density | A missing cell, a lost target, or a missing `data-density` fails. `themingTargets.test.ts` catches only a renamed or undocumented target. | `audit:TableCell/anatomy` |
-| FR2 | `Table.test.tsx` density, overflow, divider, and vertical-alignment tests; `TableRowGlide.a11y.browser.spec.ts`; `useTableRowExpansion.glide.test.tsx` | Densities; wrap and truncate; dividers; mid-glide, pinned cells, themed and overridden dividers | A mid-glide divider that does not move with its row, or the line on the wrong cell, fails in the glide checks. A truncating Table whose data-mode cells lose their truncating text wrapper, or a cell without the requested `vertical-align`, fails. Gap: the density and divider tests assert only that the table renders, and no test covers the cell's own truncation. | `audit:TableCell/layout` |
-| FR3 | Source review | Inside Card, Section, Layout | Gap: no test covers edge cells aligning to the container inset. | `audit:TableCell/layout` |
-| FR4 | `tableContextMenu.test.tsx` body-cell row-actions and full-cell tests; `useTableRowExpansion.test.tsx` context-menu action test | Body cell with a list; body cell with a getter (expandable rows); full-cell trigger | A body cell that ignores its action list or getter fails. Gap: the full-cell test checks only that the trigger has a class, so a trigger that does not fill the cell passes; no test covers an empty list or the edge-cell padding outside the trigger. | `audit:TableCell/behavior` |
-| FR5, ORD1 | `Table.test.tsx` TableCell ref, `colSpan`, and `rowSpan` tests | `ref`; `colSpan`, `rowSpan` | A ref off the `td` or a dropped `colSpan` or `rowSpan` fails. Gap: no TableCell test covers event props, `xstyle`, `className`, `style`, or the order in which caller styles follow the Table's treatment. | `audit:TableCell/api` |
-| PR1 | Source review | Every state | Gap: no automated check covers lazy context-menu loading. | `audit:TableCell/behavior` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
+| FR1, AR1 | `Table.test.tsx` children-mode and density-reflection tests; `themingTargets.test.ts` | Children mode; each density | A missing cell, a lost target, or a missing `data-density` fails. `themingTargets.test.ts` catches only a renamed or undocumented target. | `audit:TableCell/anatomy` |
+| FR2 | `Table.test.tsx` density, overflow, divider, and vertical-alignment tests; `TableRowGlide.a11y.browser.spec.ts`; `useTableRowExpansion.glide.test.tsx` | Densities; wrap and truncate; dividers; mid-glide, pinned cells, themed and overridden dividers | A mid-glide divider that does not move with its row, or the line on the wrong cell, fails in the glide checks. A truncating Table whose data-mode cells lose their truncating text wrapper, or a cell without the requested `vertical-align`, fails. Gap: the density and divider tests assert only that the table renders, and no test covers the cell's own truncation. | `audit:TableCell/layout` |
+| FR3 | Source review | Inside Card, Section, Layout | Gap: no test covers edge cells aligning to the container inset. | `audit:TableCell/layout` |
+| FR4 | `tableContextMenu.test.tsx` body-cell row-actions and full-cell tests; `useTableRowExpansion.test.tsx` context-menu action test | Body cell with a list; body cell with a getter (expandable rows); full-cell trigger | A body cell that ignores its action list or getter fails. Gap: the full-cell test checks only that the trigger has a class, so a trigger that does not fill the cell passes; no test covers an empty list or the edge-cell padding outside the trigger. | `audit:TableCell/behavior` |
+| FR5, ORD1 | `Table.test.tsx` TableCell ref, `colSpan`, and `rowSpan` tests | `ref`; `colSpan`, `rowSpan` | A ref off the `td` or a dropped `colSpan` or `rowSpan` fails. Gap: no TableCell test covers event props, `xstyle`, `className`, `style`, or the order in which caller styles follow the Table's treatment. | `audit:TableCell/api` |
+| PR1 | Source review | Every state | Gap: no automated check covers lazy context-menu loading. | `audit:TableCell/behavior` |
+| RTL relation | RTL audit curated D2 and D8 targets (`apps/storybook/rtl-audit/targets.json`) on the `In Card` story | A Card with `padding={0}`, where the first column's logical inline-start padding differs from its inline-end padding; LTR and RTL | A first column not at the inline start, or an edge padding that stays on the same physical side in RTL, fails D2 or D8. | `audit:TableCell/i18n-rtl` |
## Decision log
diff --git a/docs/specs/components/Table/TableHeaderCell.spec.md b/docs/specs/components/Table/TableHeaderCell.spec.md
index f39bb2954c..097330497b 100644
--- a/docs/specs/components/Table/TableHeaderCell.spec.md
+++ b/docs/specs/components/Table/TableHeaderCell.spec.md
@@ -17,6 +17,7 @@ verified_by:
packages/core/src/Table/Table.test.tsx,
packages/core/src/theme/themingTargets.test.ts,
scripts/check-knowledge.mjs,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families: []
@@ -147,13 +148,14 @@ block is declared here.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| --------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
-| FR1, AR1 | `TableHeaderCell.test.tsx` element, scope, and outside-Table tests; `Table.test.tsx` density-reflection test; `themingTargets.test.ts` | Default; `scope`; standalone; densities | A non-`th` element, an unrequested or missing `scope`, styling outside a Table, or a missing target or `data-density` fails. `themingTargets.test.ts` catches only a renamed or undocumented target. | `audit:TableHeaderCell/anatomy` |
-| FR2 | `TableHeaderCell.test.tsx` density, weight and color, bottom divider, and column divider tests | Three densities; dividers off, rows, columns, grid | Wrong density padding, weight, or color, a missing bottom divider, or a wrong column divider fails. Gap: truncation and edge alignment have no check. | `audit:TableHeaderCell/layout` |
-| FR3 | `tableContextMenu.test.tsx` header context-menu tests | Header cell with actions | A header cell with actions that does not open its menu, or one without actions that does, fails. | `audit:TableHeaderCell/behavior` |
-| FR4, ORD1 | `TableHeaderCell.test.tsx` xstyle, array xstyle, ref, attribute, and className and style tests | Caller inputs | A ref off the `th`, a dropped attribute, context styling that beats `xstyle`, or a lost caller class or style fails. | `audit:TableHeaderCell/api` |
-| PR1 | Source review | Every state | Gap: no automated check fails if TableHeaderCell adds state. | `audit:TableHeaderCell/behavior` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ------------ | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
+| FR1, AR1 | `TableHeaderCell.test.tsx` element, scope, and outside-Table tests; `Table.test.tsx` density-reflection test; `themingTargets.test.ts` | Default; `scope`; standalone; densities | A non-`th` element, an unrequested or missing `scope`, styling outside a Table, or a missing target or `data-density` fails. `themingTargets.test.ts` catches only a renamed or undocumented target. | `audit:TableHeaderCell/anatomy` |
+| FR2 | `TableHeaderCell.test.tsx` density, weight and color, bottom divider, and column divider tests | Three densities; dividers off, rows, columns, grid | Wrong density padding, weight, or color, a missing bottom divider, or a wrong column divider fails. Gap: truncation and edge alignment have no check. | `audit:TableHeaderCell/layout` |
+| FR3 | `tableContextMenu.test.tsx` header context-menu tests | Header cell with actions | A header cell with actions that does not open its menu, or one without actions that does, fails. | `audit:TableHeaderCell/behavior` |
+| FR4, ORD1 | `TableHeaderCell.test.tsx` xstyle, array xstyle, ref, attribute, and className and style tests | Caller inputs | A ref off the `th`, a dropped attribute, context styling that beats `xstyle`, or a lost caller class or style fails. | `audit:TableHeaderCell/api` |
+| PR1 | Source review | Every state | Gap: no automated check fails if TableHeaderCell adds state. | `audit:TableHeaderCell/behavior` |
+| RTL relation | RTL audit curated D2 and D8 targets (`apps/storybook/rtl-audit/targets.json`) on the `In Card` story | A Card with `padding={0}`, where the first column's logical inline-start padding differs from its inline-end padding; LTR and RTL | A first column not at the inline start, or an edge padding that stays on the same physical side in RTL, fails D2 or D8. | `audit:TableHeaderCell/i18n-rtl` |
## Decision log
diff --git a/docs/specs/components/Table/TableSelectionToolbar.spec.md b/docs/specs/components/Table/TableSelectionToolbar.spec.md
index e8fd55ae3e..d1d2902c34 100644
--- a/docs/specs/components/Table/TableSelectionToolbar.spec.md
+++ b/docs/specs/components/Table/TableSelectionToolbar.spec.md
@@ -14,6 +14,7 @@ verified_by:
[
packages/core/src/Table/TableSelectionToolbar.test.tsx,
scripts/check-knowledge.mjs,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families: []
@@ -144,11 +145,12 @@ so no anatomy-theming block is declared here.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| -------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
-| FR1, ORD1, AR1 | `TableSelectionToolbar.test.tsx` no-selection, actions and status, empty count, and custom-label tests | No selection; selection; custom labels | A toolbar without a selection, a missing name, count, action, or clear button, or ignored custom labels fail. | `audit:TableSelectionToolbar/behavior` |
-| FR2 | `TableSelectionToolbar.test.tsx` clear test | Clear | A clear that leaves rows selected fails. Gap: no test covers where focus goes after clearing. | `audit:TableSelectionToolbar/a11y` |
-| FR3, PR1 | `TableSelectionToolbar.test.tsx` defaults test; source review | Defaults | A toolbar that does not default to `sm` and `muted` fails. Gap: no automated check fails if TableSelectionToolbar adds state or a listener. | `audit:TableSelectionToolbar/api` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| -------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
+| FR1, ORD1, AR1 | `TableSelectionToolbar.test.tsx` no-selection, actions and status, empty count, and custom-label tests | No selection; selection; custom labels | A toolbar without a selection, a missing name, count, action, or clear button, or ignored custom labels fail. | `audit:TableSelectionToolbar/behavior` |
+| FR2 | `TableSelectionToolbar.test.tsx` clear test | Clear | A clear that leaves rows selected fails. Gap: no test covers where focus goes after clearing. | `audit:TableSelectionToolbar/a11y` |
+| FR3, PR1 | `TableSelectionToolbar.test.tsx` defaults test; source review | Defaults | A toolbar that does not default to `sm` and `muted` fails. Gap: no automated check fails if TableSelectionToolbar adds state or a listener. | `audit:TableSelectionToolbar/api` |
+| RTL relation | RTL audit curated D2 target (`apps/storybook/rtl-audit/targets.json`) on `TableSelection / Bulk actions` | One row selected; LTR and RTL | A selected count that is not at the inline start of "Unselect All" fails D2. | `audit:TableSelectionToolbar/i18n-rtl` |
## Decision log