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

[AVT] - Added keyboard nav test Breadcrumb #14639

Merged
merged 9 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
116 changes: 116 additions & 0 deletions e2e/components/breadcrumb/breadcrumb-test.avt.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* 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';

import { expect, test } from '@playwright/test';
import { visitStory } from '../../test-utils/storybook';

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

test('accessibility-checker with overflow menu', async ({ page }) => {
tay1orjones marked this conversation as resolved.
Show resolved Hide resolved
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--breadcrumb-with-overflow-menu',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Breadcrumb-with-overflow-menu');
});

test('accessibility-checker skeleton', async ({ page }) => {
tay1orjones marked this conversation as resolved.
Show resolved Hide resolved
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--skeleton',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Breadcrumb-skeleton');
});

test('accessibility-checker keyboard navigation', async ({ page }) => {
tay1orjones marked this conversation as resolved.
Show resolved Hide resolved
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--default',
globals: {
theme: 'white',
},
});
await expect(page.getByText('Breadcrumb 1')).toBeVisible();
await page.keyboard.press('Tab');
await expect(page.getByText('Breadcrumb 1')).toBeFocused();

// Testing link. For this test pass the href must be like that: href="#"
await page.keyboard.press('Enter');
await expect(page).toHaveURL(
'?path=/docs/getting-started-welcome--welcome'
);
});

test('accessibility-checker keyboard navigation - item without href prop', async ({
tay1orjones marked this conversation as resolved.
Show resolved Hide resolved
page,
}) => {
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--default',
globals: {
theme: 'white',
},
});
await expect(page.getByText('Breadcrumb 3')).toBeVisible();
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await expect(page.getByText('Breadcrumb 3')).toBeFocused();

// The Breadcrumb 4 should not be focusable
await page.keyboard.press('Tab');
await expect(page.getByText('Breadcrumb 4')).not.toBeFocused();
});

test('accessibility-checker with overflow menu keyboard navigation', async ({
tay1orjones marked this conversation as resolved.
Show resolved Hide resolved
page,
}) => {
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--breadcrumb-with-overflow-menu',
globals: {
theme: 'white',
},
});

await expect(page.getByText('Breadcrumb 1')).toBeVisible();
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');

// Verify icon-description
await expect(page.getByText('Options')).toBeVisible();

// Entering and navigating the options
await page.keyboard.press('Enter');
await expect(
page.locator('button', { hasText: 'Breadcrumb 3' })
).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(
page.locator('button', { hasText: 'Breadcrumb 4' })
).toBeFocused();
});
});
13 changes: 1 addition & 12 deletions e2e/components/breadcrumb/breadcrumb-test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

const { expect, test } = require('@playwright/test');
const { test } = require('@playwright/test');
const { themes } = require('../../test-utils/env');
const { snapshot } = require('../../test-utils/snapshot');
const { snapshotStory, visitStory } = require('../../test-utils/storybook');
Expand Down Expand Up @@ -40,15 +40,4 @@ test.describe('breadcrumb', () => {
});
});
});

test('accessibility-checker @avt', async ({ page }) => {
await visitStory(page, {
component: 'breadcrumb',
story: 'breadcrumb-story',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('breadcrumb');
});
});
Loading