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 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
110 changes: 110 additions & 0 deletions e2e/components/breadcrumb/breadcrumb-test.avt.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/**
* 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('@avt-default-state', async ({ page }) => {
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Breadcrumb');
});

test('@avt-advanced-states with overflow menu', async ({ page }) => {
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--breadcrumb-with-overflow-menu',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Breadcrumb-with-overflow-menu');
});

test('@avt-advanced-states skeleton', async ({ page }) => {
await visitStory(page, {
component: 'Breadcrumb',
id: 'components-breadcrumb--skeleton',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Breadcrumb-skeleton');
});

test('@avt-keyboard-nav default', async ({ page }) => {
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();
// Checking if the link is enabled to be clicked on
await expect(page.getByText('Breadcrumb 1')).toBeEnabled();
});

test('@avt-keyboard-nav - item without href prop', async ({ 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('@avt-keyboard-nav with overflow menu keyboard navigation', async ({
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');
});
});