-
Notifications
You must be signed in to change notification settings - Fork 256
test(action-group): add unit, accessibility, and VRT coverage #6589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rise-erpelding
wants to merge
9
commits into
swc-2212/migrate-action-group
from
swc-2217/action-group-tests
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d9e2411
test: vitest
3e477a8
test: a11y tests
a82c2d1
test: vrts
e40e4c5
docs: update migration plan
80d5522
test(actionbutton): fix action button vrts to reflect new custom props
5dcf4a4
fix: only show focus on middle child once
e9ceb69
fix: remove static colors from test coverage
79daec7
fix: exclude inline-size 100 from global styles
5b8862a
fix: address feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,4 +372,32 @@ export const Justified: Story = { | |
| // ACCESSIBILITY STORIES | ||
| // ──────────────────────────────── | ||
|
|
||
| // Outer `role="toolbar"` landmark wrapping two named `role="group"` clusters, | ||
| // per the APG toolbar example and the migration plan's accessibility | ||
| // section. `swc-action-group` never sets `role="toolbar"` itself; that role | ||
| // belongs on this wrapper only, since the host role is fixed to `"group"` | ||
| // and not author-overridable. Backs the `ToolbarComposition` ARIA-snapshot | ||
| // assertion in `action-group.a11y.spec.ts`. | ||
| export const ToolbarComposition: Story = { | ||
| render: () => html` | ||
| <div | ||
| role="toolbar" | ||
| aria-label="Document actions" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use of |
||
| style="display: flex; gap: var(--swc-spacing-400);" | ||
| > | ||
| <swc-action-group accessible-label="Edit actions"> | ||
| <swc-action-button>Cut</swc-action-button> | ||
| <swc-action-button>Copy</swc-action-button> | ||
| <swc-action-button>Paste</swc-action-button> | ||
| </swc-action-group> | ||
| <swc-action-group accessible-label="View actions"> | ||
| <swc-action-button>Zoom in</swc-action-button> | ||
| <swc-action-button>Zoom out</swc-action-button> | ||
| </swc-action-group> | ||
| </div> | ||
| `, | ||
| tags: ['a11y'], | ||
| }; | ||
| ToolbarComposition.storyName = 'Toolbar wrapper composition'; | ||
|
|
||
| // TODO: will complete in separate documentation pass of phase 7 | ||
327 changes: 327 additions & 0 deletions
327
2nd-gen/packages/swc/components/action-group/test/action-group.a11y.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,327 @@ | ||
| /** | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import AxeBuilder from '@axe-core/playwright'; | ||
| import { expect, test } from '@playwright/test'; | ||
|
|
||
| import { gotoStory } from '../../../utils/a11y-helpers.js'; | ||
|
|
||
| /** | ||
| * Accessibility tests for ActionGroup component (2nd Generation) | ||
| * | ||
| * ARIA snapshot tests validate the accessibility tree structure. | ||
| * Keyboard interaction tests verify the composite Tab-stop model (one Tab | ||
| * stop into the strip, arrow keys move among children) — the main behavioral | ||
| * difference from ButtonGroup, which lets Tab reach each button independently. | ||
| * aXe WCAG validation ensures no accessibility violations per story. | ||
| */ | ||
|
|
||
| test.describe('ActionGroup - ARIA Snapshots', () => { | ||
| test('should have correct accessibility tree for overview', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
| await expect(root).toMatchAriaSnapshot(` | ||
| - group "Text formatting": | ||
| - button "Bold" | ||
| - button "Italic" | ||
| - button "Underline" | ||
| `); | ||
| }); | ||
|
|
||
| test('should not set aria-orientation (not valid on role=group)', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--orientations', | ||
| 'swc-action-group' | ||
| ); | ||
| const verticalGroup = root | ||
| .locator('swc-action-group[orientation="vertical"]') | ||
| .first(); | ||
| await expect(verticalGroup).not.toHaveAttribute('aria-orientation'); | ||
| }); | ||
|
|
||
| test('should expose group names for each orientation', async ({ page }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--orientations', | ||
| 'swc-action-group' | ||
| ); | ||
| await expect(root).toMatchAriaSnapshot(` | ||
| - group "horizontal": | ||
| - button "horizontal 1" | ||
| - button "horizontal 2" | ||
| - group "vertical": | ||
| - button "vertical 1" | ||
| - button "vertical 2" | ||
| `); | ||
| }); | ||
|
|
||
| test('toolbar wrapper composition exposes a toolbar landmark with named inner groups', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--toolbar-composition', | ||
| 'swc-action-group' | ||
| ); | ||
| await expect(root).toMatchAriaSnapshot(` | ||
| - toolbar "Document actions": | ||
| - group "Edit actions": | ||
| - button "Cut" | ||
| - button "Copy" | ||
| - button "Paste" | ||
| - group "View actions": | ||
| - button "Zoom in" | ||
| - button "Zoom out" | ||
| `); | ||
| }); | ||
|
|
||
| test('disabled group sets aria-disabled on host and children', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--disabled', | ||
| 'swc-action-group' | ||
| ); | ||
| const group = root.locator('swc-action-group'); | ||
| const buttons = root.locator('swc-action-button'); | ||
|
|
||
| await expect(group).toHaveAttribute('aria-disabled', 'true'); | ||
| for (const button of await buttons.all()) { | ||
| await expect(button).toHaveAttribute('aria-disabled', 'true'); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('ActionGroup - Keyboard Interactions', () => { | ||
| test('group host is NOT focusable', async ({ page }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
| const group = root.locator('swc-action-group'); | ||
| await expect(group).not.toBeFocused(); | ||
| await page.keyboard.press('Tab'); | ||
| await expect(group).not.toBeFocused(); | ||
| }); | ||
|
|
||
| test('Tab enters the strip once and focuses the first child', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
| const buttons = root.locator('swc-action-button'); | ||
|
|
||
| await page.keyboard.press('Tab'); | ||
| await expect(buttons.nth(0)).toBeFocused(); | ||
| }); | ||
|
|
||
| test('a second Tab leaves the strip instead of moving to the next button', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
| const buttons = root.locator('swc-action-button'); | ||
|
|
||
| await page.keyboard.press('Tab'); | ||
| await expect(buttons.nth(0)).toBeFocused(); | ||
|
|
||
| await page.keyboard.press('Tab'); | ||
| await expect(buttons.nth(0)).not.toBeFocused(); | ||
| await expect(buttons.nth(1)).not.toBeFocused(); | ||
| await expect(buttons.nth(2)).not.toBeFocused(); | ||
| }); | ||
|
|
||
| test('ArrowRight moves focus among children, ArrowLeft wraps to the last', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
| const buttons = root.locator('swc-action-button'); | ||
|
|
||
| await buttons.nth(0).focus(); | ||
| await page.keyboard.press('ArrowRight'); | ||
| await expect(buttons.nth(1)).toBeFocused(); | ||
|
|
||
| await page.keyboard.press('ArrowRight'); | ||
| await expect(buttons.nth(2)).toBeFocused(); | ||
|
|
||
| await page.keyboard.press('ArrowRight'); | ||
| await expect(buttons.nth(0)).toBeFocused(); | ||
|
|
||
| await page.keyboard.press('ArrowLeft'); | ||
| await expect(buttons.nth(2)).toBeFocused(); | ||
| }); | ||
|
|
||
| test('Home and End move focus to the first and last child', async ({ | ||
| page, | ||
| }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
| const buttons = root.locator('swc-action-button'); | ||
|
|
||
| await buttons.nth(0).focus(); | ||
| await page.keyboard.press('End'); | ||
| await expect(buttons.nth(2)).toBeFocused(); | ||
|
|
||
| await page.keyboard.press('Home'); | ||
| await expect(buttons.nth(0)).toBeFocused(); | ||
| }); | ||
|
|
||
| test('ArrowDown/ArrowUp move focus in a vertical group', async ({ page }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-action-group--orientations', | ||
| 'swc-action-group' | ||
| ); | ||
| const verticalGroup = root | ||
| .locator('swc-action-group[orientation="vertical"]') | ||
| .first(); | ||
| const buttons = verticalGroup.locator('swc-action-button'); | ||
|
|
||
| await buttons.nth(0).focus(); | ||
| await page.keyboard.press('ArrowDown'); | ||
| await expect(buttons.nth(1)).toBeFocused(); | ||
|
|
||
| await page.keyboard.press('ArrowUp'); | ||
| await expect(buttons.nth(0)).toBeFocused(); | ||
| }); | ||
|
|
||
| test('button is activatable via Enter key', async ({ page }) => { | ||
| await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
|
|
||
| const firstButton = page.locator('swc-action-button').first(); | ||
| await firstButton.focus(); | ||
| await expect(firstButton).toBeFocused(); | ||
| await page.keyboard.press('Enter'); | ||
| }); | ||
|
|
||
| test('button is activatable via Space key', async ({ page }) => { | ||
| await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
|
|
||
| const firstButton = page.locator('swc-action-button').first(); | ||
| await firstButton.focus(); | ||
| await expect(firstButton).toBeFocused(); | ||
| await page.keyboard.press('Space'); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('ActionGroup - aXe Validation', () => { | ||
| test('default state has no WCAG violations', async ({ page }) => { | ||
| await gotoStory( | ||
| page, | ||
| 'components-action-group--overview', | ||
| 'swc-action-group' | ||
| ); | ||
|
|
||
| const results = await new AxeBuilder({ page }) | ||
| .include('#storybook-root') | ||
| .analyze(); | ||
|
|
||
| expect(results.violations).toEqual([]); | ||
| }); | ||
|
|
||
| test('disabled state has no WCAG violations', async ({ page }) => { | ||
| await gotoStory( | ||
| page, | ||
| 'components-action-group--disabled', | ||
| 'swc-action-group' | ||
| ); | ||
|
|
||
| const results = await new AxeBuilder({ page }) | ||
| .include('#storybook-root') | ||
| .analyze(); | ||
|
|
||
| expect(results.violations).toEqual([]); | ||
| }); | ||
|
|
||
| test('vertical orientation has no WCAG violations', async ({ page }) => { | ||
| await gotoStory( | ||
| page, | ||
| 'components-action-group--orientations', | ||
| 'swc-action-group' | ||
| ); | ||
|
|
||
| const results = await new AxeBuilder({ page }) | ||
| .include('#storybook-root') | ||
| .analyze(); | ||
|
|
||
| expect(results.violations).toEqual([]); | ||
| }); | ||
|
|
||
| test('compact density has no WCAG violations', async ({ page }) => { | ||
| await gotoStory( | ||
| page, | ||
| 'components-action-group--compact', | ||
| 'swc-action-group' | ||
| ); | ||
|
|
||
| const results = await new AxeBuilder({ page }) | ||
| .include('#storybook-root') | ||
| .analyze(); | ||
|
|
||
| expect(results.violations).toEqual([]); | ||
| }); | ||
|
|
||
| test('quiet style has no WCAG violations', async ({ page }) => { | ||
| await gotoStory(page, 'components-action-group--quiet', 'swc-action-group'); | ||
|
|
||
| const results = await new AxeBuilder({ page }) | ||
| .include('#storybook-root') | ||
| .analyze(); | ||
|
|
||
| expect(results.violations).toEqual([]); | ||
| }); | ||
|
|
||
| test('justified layout has no WCAG violations', async ({ page }) => { | ||
| await gotoStory( | ||
| page, | ||
| 'components-action-group--justified', | ||
| 'swc-action-group' | ||
| ); | ||
|
|
||
| const results = await new AxeBuilder({ page }) | ||
| .include('#storybook-root') | ||
| .analyze(); | ||
|
|
||
| expect(results.violations).toEqual([]); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compact action groups need to be able to modify the action button corner radii, this adds VRT testing for those