Skip to content
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

chore: Add a11y checks for app layout toolbar #3030

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/__a11y__/app-layout-toolbar.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import useBrowser from '@cloudscape-design/browser-test-tools/use-browser';

import { findAllPages } from '../__integ__/utils';
import { getUrlParams } from '../app-layout/__integ__/utils';
import A11yPageObject from './a11y-page-object';

describe('A11y checks for app layout toolbar', () => {
findAllPages()
.filter(page => page.includes('app-layout'))
.forEach(inputUrl => {
const url = `#/light/${inputUrl}?${getUrlParams('refresh-toolbar')}`;
test(
url,
useBrowser(async browser => {
const page = new A11yPageObject(browser);
await browser.url(url);
await page.waitForVisible('main');
await page.assertNoAxeViolations();
})
);
});
});
4 changes: 2 additions & 2 deletions src/app-layout/__tests__/mobile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ describeEachAppLayout({ sizes: ['mobile'] }, ({ theme }) => {
expect(wrapper.findDrawerTriggerById('security')!.getElement().children[0]).toHaveClass(triggerBadgeClassName);
});

test('renders roles only when aria labels are not provided', () => {
(theme === 'refresh-toolbar' ? test.skip : test)('renders roles only when aria labels are not provided', () => {
const { wrapper } = renderComponent(<AppLayout drawers={[testDrawerWithoutLabels]} />);
const drawersAside = within(findMobileToolbar(wrapper)!.getElement()).getByRole('region');

Expand All @@ -595,7 +595,7 @@ describeEachAppLayout({ sizes: ['mobile'] }, ({ theme }) => {
expect(drawersToolbar).toHaveAttribute('role', 'toolbar');
});

test('renders roles and aria labels when provided', () => {
(theme === 'refresh-toolbar' ? test.skip : test)('renders roles and aria labels when provided', () => {
const { wrapper } = renderComponent(<AppLayout drawers={[testDrawer]} ariaLabels={{ drawers: 'Drawers' }} />);
const drawersAside = within(findMobileToolbar(wrapper)!.getElement()).getByRole('region');

Expand Down
6 changes: 5 additions & 1 deletion src/app-layout/visual-refresh-toolbar/toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ export function AppLayoutToolbarImplementation({
>
<div className={styles['toolbar-container']}>
{hasNavigation && (
<nav className={clsx(styles['universal-toolbar-nav'])}>
<nav
role="region"
aria-label={ariaLabels?.navigation ?? undefined}
className={clsx(styles['universal-toolbar-nav'])}
>
<TriggerButton
ariaLabel={ariaLabels?.navigationToggle ?? undefined}
ariaExpanded={false}
Expand Down
Loading