Skip to content

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

TypeScript

test(rtl): RTL coverage for the SideNav parts (#9311)

Cindy Zhang1a4c048bcb39
diff --git a/apps/storybook/rtl-audit/targets.json b/apps/storybook/rtl-audit/targets.json
index 9eae72b2db..f208e7b8f6 100644
--- a/apps/storybook/rtl-audit/targets.json
+++ b/apps/storybook/rtl-audit/targets.json
@@ -557,6 +557,49 @@
"next": ".astryx-input-group > .astryx-input-group-text:last-child"
}
},
+ {
+ "component": "SideNavHeading",
+ "storyId": "core-sidenav--default",
+ "dims": ["D2", "D8"],
+ "selectors": {
+ "prev": ".astryx-side-nav-heading .astryx-nav-icon",
+ "next": ".astryx-side-nav-heading span:text-is(\"My App\")",
+ "subject": ".astryx-side-nav-heading"
+ }
+ },
+ {
+ "component": "SideNavItem",
+ "storyId": "core-sidenav--default",
+ "dims": ["D2"],
+ "selectors": {
+ "prev": ".astryx-side-nav-item svg.astryx-icon",
+ "next": ".astryx-side-nav-item span:text-is(\"Dashboard\")"
+ }
+ },
+ {
+ "component": "SideNavSection",
+ "storyId": "core-sidenav--section-end-content",
+ "dims": ["D2"],
+ "selectors": {
+ "prev": ".astryx-side-nav-section span:text-is(\"Projects\")",
+ "next": ".astryx-side-nav-section .astryx-badge"
+ }
+ },
+ {
+ "component": "SideNavCollapseButton",
+ "storyId": "core-sidenav--collapsible-sidebar",
+ "dims": []
+ },
+ {
+ "component": "SideNav",
+ "storyId": "core-sidenav--section-end-content",
+ "dims": []
+ },
+ {
+ "component": "SideNav",
+ "storyId": "core-sidenav--collapsible-sidebar",
+ "dims": []
+ },
{
"component": "NumberInput",
"storyId": "core-numberinput--with-number-steppers",
diff --git a/apps/storybook/stories/SideNav.stories.tsx b/apps/storybook/stories/SideNav.stories.tsx
index 9bec8f05ee..d3773789aa 100644
--- a/apps/storybook/stories/SideNav.stories.tsx
+++ b/apps/storybook/stories/SideNav.stories.tsx
@@ -896,3 +896,19 @@ export const CollapseFocusWithoutToggle: Story = {
name: 'Collapse Focus Without Toggle',
render: () => <CollapseFocusDemo hasButton={false} />,
};
+
+/**
+ * Fixture for the RTL audit: a section header with end content, so the
+ * title-then-end-content order can be measured in both directions.
+ */
+export const SectionEndContent: Story = {
+ name: 'Section / End content',
+ render: () => (
+ <SideNav>
+ <SideNavSection title="Projects" endContent={<Badge label="12" />}>
+ <SideNavItem label="Atlas" icon={FolderIcon} href="/atlas" />
+ <SideNavItem label="Beacon" icon={FolderIcon} href="/beacon" />
+ </SideNavSection>
+ </SideNav>
+ ),
+};
diff --git a/docs/specs/components/SideNav/SideNavCollapseButton.spec.md b/docs/specs/components/SideNav/SideNavCollapseButton.spec.md
index 3ae1f72f2c..222d316358 100644
--- a/docs/specs/components/SideNav/SideNavCollapseButton.spec.md
+++ b/docs/specs/components/SideNav/SideNavCollapseButton.spec.md
@@ -14,6 +14,7 @@ verified_by:
[
packages/core/src/SideNav/SideNav.test.tsx,
apps/storybook/stories/SideNavCollapseOwnership.stories.tsx,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families: []
@@ -131,12 +132,13 @@ anatomy-theming map is recorded.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| -------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------- |
-| FR1, FR2 | `SideNav.test.tsx` handleRef, outside-button, and collapse-ownership tests | Inside, handleRef, controlled | A stale or wrong state source fails. | `audit:SideNavCollapseButton/behavior` |
-| FR1, FR3, ORD2 | `SideNav.test.tsx` outside-button and controlled-collapsible tests | Own `collapsible`; `label` override; expanded and collapsed default names | A wrong state source, an ignored `label`, or a stale default name fails. | `audit:SideNavCollapseButton/accessibility` |
-| FR4 | `SideNav.test.tsx` consumer onClick test | Outside with handleRef | A replaced toggle fails. | `audit:SideNavCollapseButton/behavior` |
-| FR3 | `SideNav.test.tsx` footer icon row sizing tests | Built-in button; explicit `size` outside the nav | A Button-default size or an ignored explicit size fails. | `audit:SideNavCollapseButton/behavior` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------- |
+| FR1, FR2 | `SideNav.test.tsx` handleRef, outside-button, and collapse-ownership tests | Inside, handleRef, controlled | A stale or wrong state source fails. | `audit:SideNavCollapseButton/behavior` |
+| FR1, FR3, ORD2 | `SideNav.test.tsx` outside-button and controlled-collapsible tests | Own `collapsible`; `label` override; expanded and collapsed default names | A wrong state source, an ignored `label`, or a stale default name fails. | `audit:SideNavCollapseButton/accessibility` |
+| FR4 | `SideNav.test.tsx` consumer onClick test | Outside with handleRef | A replaced toggle fails. | `audit:SideNavCollapseButton/behavior` |
+| FR3 | `SideNav.test.tsx` footer icon row sizing tests | Built-in button; explicit `size` outside the nav | A Button-default size or an ignored explicit size fails. | `audit:SideNavCollapseButton/behavior` |
+| RTL relation | RTL audit automatic D1 on `SideNav / Collapsible sidebar`, routed by a route-only entry in `apps/storybook/rtl-audit/targets.json` | The collapse button's chevron; LTR and RTL | A chevron that does not mirror fails D1. | `audit:SideNavCollapseButton/i18n-rtl` |
Read from source, with no focused test yet:
diff --git a/docs/specs/components/SideNav/SideNavHeading.spec.md b/docs/specs/components/SideNav/SideNavHeading.spec.md
index 451f4e9a31..f2ff635ba0 100644
--- a/docs/specs/components/SideNav/SideNavHeading.spec.md
+++ b/docs/specs/components/SideNav/SideNavHeading.spec.md
@@ -14,6 +14,7 @@ verified_by:
[
packages/core/src/SideNav/SideNav.test.tsx,
apps/storybook/stories/SideNav.stories.tsx,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families:
@@ -190,14 +191,15 @@ map is recorded.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| ------------ | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------ |
-| FR1–FR4, AR1 | `SideNav.test.tsx` SideNavHeading and headerEndContent suites | Each configuration | Wrong element, unnamed link, or misplaced end content fails. | `audit:SideNavHeading/behavior` |
-| FR5 | `SideNav.test.tsx` SideNavHeading hover/click guard suite | Hover, click, late click, Escape | Lost guard or focus return fails. | `audit:SideNavHeading/behavior` |
-| FR6, AR2 | `SideNav.test.tsx` menu popover semantics suite | Whole trigger; mixed; collapsed | A dialog wrapper or misplaced menu role fails. | `audit:SideNavHeading/accessibility` |
-| FR8 | `SideNav.test.tsx` SideNavHeading collapsed suite | Link, menu, plain, no icon | Missing name, tooltip, or invoker fails. | `audit:SideNavHeading/behavior` |
-| FR9 | `SideNav.test.tsx` focus ring suite | Whole-heading link, collapsed link, menu trigger | A missing shared ring class fails. | `audit:SideNavHeading/accessibility` |
-| FR10 | `SideNav.test.tsx` SideNavHeading menu-popover suite (touch and mouse slides) | Touch and mouse slides across items; a caller button and link; a release outside | Removing the adoption fails the slide tests. | — |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ------------ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ |
+| FR1–FR4, AR1 | `SideNav.test.tsx` SideNavHeading and headerEndContent suites | Each configuration | Wrong element, unnamed link, or misplaced end content fails. | `audit:SideNavHeading/behavior` |
+| FR5 | `SideNav.test.tsx` SideNavHeading hover/click guard suite | Hover, click, late click, Escape | Lost guard or focus return fails. | `audit:SideNavHeading/behavior` |
+| FR6, AR2 | `SideNav.test.tsx` menu popover semantics suite | Whole trigger; mixed; collapsed | A dialog wrapper or misplaced menu role fails. | `audit:SideNavHeading/accessibility` |
+| FR8 | `SideNav.test.tsx` SideNavHeading collapsed suite | Link, menu, plain, no icon | Missing name, tooltip, or invoker fails. | `audit:SideNavHeading/behavior` |
+| FR9 | `SideNav.test.tsx` focus ring suite | Whole-heading link, collapsed link, menu trigger | A missing shared ring class fails. | `audit:SideNavHeading/accessibility` |
+| FR10 | `SideNav.test.tsx` SideNavHeading menu-popover suite (touch and mouse slides) | Touch and mouse slides across items; a caller button and link; a release outside | Removing the adoption fails the slide tests. | — |
+| RTL relation | RTL audit curated D2 and D8 targets (`apps/storybook/rtl-audit/targets.json`) on `SideNav / Default` | Heading icon and title, with 0px start and 8px end padding; LTR and RTL | An icon that is not at the inline start of the title, or an end padding that stays on the same physical side in RTL, fails D2 or D8. | `audit:SideNavHeading/i18n-rtl` |
Read from source, with no focused test yet:
diff --git a/docs/specs/components/SideNav/SideNavItem.spec.md b/docs/specs/components/SideNav/SideNavItem.spec.md
index 8812ce6ce7..3a5b17b7e2 100644
--- a/docs/specs/components/SideNav/SideNavItem.spec.md
+++ b/docs/specs/components/SideNav/SideNavItem.spec.md
@@ -14,6 +14,7 @@ verified_by:
[
packages/core/src/SideNav/SideNav.test.tsx,
apps/storybook/stories/SideNav.stories.tsx,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families: [family:navigation-destinations, family:overlay-dismissal]
@@ -197,15 +198,16 @@ is recorded. Row geometry visual intent is `component:SideNav` DD1.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| ------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------- |
-| FR1–FR3, FR5 | `SideNav.test.tsx` SideNavItem suite | Link, button, `as`, provider, disabled | Wrong element, lost `aria-current`, or a disabled item that runs `onClick` fails. | `audit:SideNavItem/behavior` |
-| FR4–FR7, AR3 | `SideNav.test.tsx` actions-slot suite | Actions with toggle, endContent, disabled; row-wrapper `data-testid`; `defaultIsCollapsed` with whole-row `aria-controls` | Actions inside the primary element or wrong order fails. | `audit:SideNavItem/behavior` |
-| FR6, FR7, AR2 | `SideNav.test.tsx` collapsible + href suite | Split, whole-row, controlled | A link that toggles or duplicated `aria-expanded` fails. | `audit:SideNavItem/accessibility` |
-| FR8, FR9 | `SideNav.test.tsx` collapsed, hover-intent, and rail-tooltip suites | Leaf, parent, hover, click, keyboard, coarse | Lost delay, focus restore, or tooltip anchor fails. | `audit:SideNavItem/behavior` |
-| FR10 | `SideNav.test.tsx` mobile drawer close-on-activate suite | Link, button, toggle, action, outside drawer | Wrong close behavior fails. | `audit:SideNavItem/behavior` |
-| FR11 | `SideNav.test.tsx` focus ring suite | Plain, split, actions rows | Missing shared ring classes fail. | `audit:SideNavItem/accessibility` |
-| FR3, FR7, FR9 | `SideNav.test.tsx` keyboard operation and focus management suites | Tab order, Enter/Space toggle, flyout Escape | Lost order, a stranded focus, or no focus return fails. | `audit:SideNavItem/accessibility` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------- |
+| FR1–FR3, FR5 | `SideNav.test.tsx` SideNavItem suite | Link, button, `as`, provider, disabled | Wrong element, lost `aria-current`, or a disabled item that runs `onClick` fails. | `audit:SideNavItem/behavior` |
+| FR4–FR7, AR3 | `SideNav.test.tsx` actions-slot suite | Actions with toggle, endContent, disabled; row-wrapper `data-testid`; `defaultIsCollapsed` with whole-row `aria-controls` | Actions inside the primary element or wrong order fails. | `audit:SideNavItem/behavior` |
+| FR6, FR7, AR2 | `SideNav.test.tsx` collapsible + href suite | Split, whole-row, controlled | A link that toggles or duplicated `aria-expanded` fails. | `audit:SideNavItem/accessibility` |
+| FR8, FR9 | `SideNav.test.tsx` collapsed, hover-intent, and rail-tooltip suites | Leaf, parent, hover, click, keyboard, coarse | Lost delay, focus restore, or tooltip anchor fails. | `audit:SideNavItem/behavior` |
+| FR10 | `SideNav.test.tsx` mobile drawer close-on-activate suite | Link, button, toggle, action, outside drawer | Wrong close behavior fails. | `audit:SideNavItem/behavior` |
+| FR11 | `SideNav.test.tsx` focus ring suite | Plain, split, actions rows | Missing shared ring classes fail. | `audit:SideNavItem/accessibility` |
+| FR3, FR7, FR9 | `SideNav.test.tsx` keyboard operation and focus management suites | Tab order, Enter/Space toggle, flyout Escape | Lost order, a stranded focus, or no focus return fails. | `audit:SideNavItem/accessibility` |
+| RTL relation | RTL audit curated D2 target (`apps/storybook/rtl-audit/targets.json`) on `SideNav / Default` | Item icon and label; LTR and RTL | An icon that is not at the inline start of its label fails D2. | `audit:SideNavItem/i18n-rtl` |
Read from source, with no focused test yet:
diff --git a/docs/specs/components/SideNav/SideNavSection.spec.md b/docs/specs/components/SideNav/SideNavSection.spec.md
index 8785e4c36d..7645ff30c5 100644
--- a/docs/specs/components/SideNav/SideNavSection.spec.md
+++ b/docs/specs/components/SideNav/SideNavSection.spec.md
@@ -14,6 +14,7 @@ verified_by:
[
packages/core/src/SideNav/SideNav.test.tsx,
apps/storybook/stories/SideNav.stories.tsx,
+ apps/storybook/rtl-audit/targets.json,
]
modules: []
families: []
@@ -127,10 +128,11 @@ map is recorded.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| ------------- | --------------------------------------------- | ----------------------------------- | ------------------------------------------- | ------------------------------------ |
-| FR1, FR2, FR4 | `SideNav.test.tsx` SideNavSection suite | Title, subtitle, end content, props | A lost role, name, or forwarded prop fails. | `audit:SideNavSection/accessibility` |
-| FR3 | `SideNav.test.tsx` hidden section header test | Header hidden | A header removed from the tree fails. | `audit:SideNavSection/accessibility` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------ | -------------------------------------------------------------------- | ------------------------------------ |
+| FR1, FR2, FR4 | `SideNav.test.tsx` SideNavSection suite | Title, subtitle, end content, props | A lost role, name, or forwarded prop fails. | `audit:SideNavSection/accessibility` |
+| FR3 | `SideNav.test.tsx` hidden section header test | Header hidden | A header removed from the tree fails. | `audit:SideNavSection/accessibility` |
+| RTL relation | RTL audit curated D2 target (`apps/storybook/rtl-audit/targets.json`) on `SideNav / Section / End content` | Section title and end content; LTR and RTL | A title that is not at the inline start of the end content fails D2. | `audit:SideNavSection/i18n-rtl` |
Read from source, with no focused test yet: the forwarded `ref`, the
`side-nav-section` target, and the role and label winning over caller props