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

feat: toggle avt test #14449

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
02ffa5b
feat: toggle avt test
andreancardona Aug 16, 2023
a52d27d
fix: test arial
andreancardona Aug 16, 2023
5f27b72
fix: test arialabelledby - test
andreancardona Aug 16, 2023
d3a5539
fix: test arialabelledby
andreancardona Aug 16, 2023
714b233
feat: fix tests
andreancardona Aug 17, 2023
01b986d
Merge branch 'main' into 14331-toggle-avt-tests
andreancardona Aug 17, 2023
08e9205
fix: updating tests
andreancardona Aug 17, 2023
9572453
fix: updating tests
andreancardona Aug 17, 2023
fbc8dce
Merge branch 'main' into 14331-toggle-avt-tests
guidari Aug 18, 2023
36c59b7
fix: update tests
andreancardona Aug 21, 2023
eb96f54
Merge branch '14331-toggle-avt-tests' of https://github.com/andreanca…
andreancardona Aug 21, 2023
c719ba4
Merge branch 'main' into 14331-toggle-avt-tests
andreancardona Aug 21, 2023
badc78d
Merge branch 'main' into 14331-toggle-avt-tests
alisonjoseph Aug 21, 2023
bb4dffe
Merge branch 'main' into 14331-toggle-avt-tests
guidari Aug 22, 2023
cd134f3
Update e2e/components/Toggle/Toggle-test.avt.e2e.js
andreancardona Aug 22, 2023
473907d
feat: added skeleton test
andreancardona Aug 22, 2023
fb2bab9
Merge branch 'main' into 14331-toggle-avt-tests
andreancardona Aug 22, 2023
1b42d28
fix: tests
andreancardona Aug 22, 2023
c35372c
Merge branch 'main' into 14331-toggle-avt-tests
andreancardona Aug 22, 2023
d6447b6
fix: tests aria
andreancardona Aug 23, 2023
3428c90
chore: update snapshots
andreancardona Aug 23, 2023
8960d95
Merge branch 'main' into 14331-toggle-avt-tests
andreancardona Aug 23, 2023
b2a7594
feat: toggle avt test
andreancardona Aug 16, 2023
032cc96
fix: test arial
andreancardona Aug 16, 2023
962dad8
fix: test arialabelledby - test
andreancardona Aug 16, 2023
927ddbd
fix: test arialabelledby
andreancardona Aug 16, 2023
473b434
feat: fix tests
andreancardona Aug 17, 2023
b74994d
fix: updating tests
andreancardona Aug 17, 2023
04f0211
fix: update tests
andreancardona Aug 21, 2023
b0f50eb
Update e2e/components/Toggle/Toggle-test.avt.e2e.js
andreancardona Aug 22, 2023
863288a
feat: added skeleton test
andreancardona Aug 22, 2023
ff9842c
fix: tests
andreancardona Aug 22, 2023
f3d9c1f
fix: tests aria
andreancardona Aug 23, 2023
3400036
chore: update snapshots
andreancardona Aug 23, 2023
6e43ffa
chore(snapshot): update snapshots
tw15egan Aug 23, 2023
a13465a
Merge branch '14331-toggle-avt-tests' of https://github.com/andreanca…
andreancardona Aug 23, 2023
b503526
fix: snapshots
andreancardona Aug 23, 2023
8c69192
Merge branch 'main' into 14331-toggle-avt-tests
guidari Aug 23, 2023
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
61 changes: 61 additions & 0 deletions e2e/components/Toggle/Toggle-test.avt.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const { expect, test } = require('@playwright/test');
const { visitStory } = require('../../test-utils/storybook');

test.describe('Toggle @avt', () => {
test('accessibility-checker @avt', async ({ page }) => {
andreancardona marked this conversation as resolved.
Show resolved Hide resolved
await visitStory(page, {
component: 'Toggle',
id: 'components-toggle--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Toggle');
});

test('accessibility-checker small toggle', async ({ page }) => {
await visitStory(page, {
component: 'Tabs',
id: 'components-toggle--small-toggle',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Toggle-small');
});
test('accessibility-checker with accessible labels', async ({ page }) => {
await visitStory(page, {
component: 'Tabs',
id: 'components-toggle--with-accessible-labels',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Toggle-accessible-labels');
});

test('default Toggle state - keyboard nav', async ({ page }) => {
await visitStory(page, {
component: 'Tabs',
id: 'components-toggle--default',
globals: {
theme: 'white',
},
});
await page.keyboard.press('Tab');
await expect(page.getByRole('switch')).toBeVisible();
await page.keyboard.press('Space');
await page.getByText('Off');
await page.keyboard.press('Space');
await page.getByText('On');
});
});
17 changes: 2 additions & 15 deletions e2e/components/Toggle/Toggle-test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

'use strict';

const { expect, test } = require('@playwright/test'); // eslint-disable-line
const { test } = require('@playwright/test'); // eslint-disable-line
const { themes } = require('../../test-utils/env');
const { snapshotStory, visitStory } = require('../../test-utils/storybook'); // eslint-disable-line
const { snapshotStory } = require('../../test-utils/storybook'); // eslint-disable-line

test.describe('Toggle', () => {
themes.forEach((theme) => {
Expand Down Expand Up @@ -39,17 +39,4 @@ test.describe('Toggle', () => {
});
});
});

// TODO: uncomment when https://github.com/IBMa/equal-access/issues/761 is resolved

// test('accessibility-checker @avt', async ({ page }) => {
// await visitStory(page, {
// component: 'Toggle',
// id: 'components-toggle--default',
// globals: {
// theme: 'white',
// },
// });
// await expect(page).toHaveNoACViolations('Toggle');
// });
});
6 changes: 3 additions & 3 deletions packages/react/src/components/Toggle/Toggle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ describe('Toggle', () => {
});

it("doesn't render sideLabel if props.hideLabel and no props.labelText is provided", () => {
const externalElementId = 'external-element-id';
wrapper.rerender(
<Toggle
role="switch"
{...props}
hideLabel
labelText={null}
aria-labelledby={externalElementId}
aria-labelledby={props.id}
/>
);

Expand All @@ -117,7 +117,7 @@ describe('Toggle', () => {
// eslint-disable-next-line testing-library/prefer-screen-queries
expect(wrapper.getByRole('switch')).toHaveAttribute(
'aria-labelledby',
externalElementId
props.id
);

expect(
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Toggle/Toggle.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Playground.argTypes = {
},
};

export const WithAcessibleLabels = () => (
export const WithAccessibleLabels = () => (
<VStack gap={7}>
<Toggle id="toggle-4" labelText="Toggle label" />

Expand All @@ -93,7 +93,7 @@ export const WithAcessibleLabels = () => (
<div id="toggle-6-label" style={{ marginBlockEnd: '0.5rem' }}>
External toggle label
</div>
<Toggle id="toggle-6" aria-labelledby="toggle-6-label" hideLabel />
<Toggle id="toggle-6" hideLabel />
</div>

<div>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function Toggle({
role="switch"
type="button"
aria-checked={checked}
aria-labelledby={ariaLabelledby}
aria-labelledby={id}
disabled={disabled}
onClick={handleClick}
/>
Expand Down