Skip to content

Commit

Permalink
[AVT] - Added keyboard nav test Breadcrumb (#14639)
Browse files Browse the repository at this point in the history
* test: added keyboard navigation test

* Apply suggestions from code review

* test: changed test name

* test: added timeout to avoid github action fail

* test: increase time by 50s

* test: added timeout

* test: changed expected test

* test: checking if the link is enabled

---------

Co-authored-by: Taylor Jones <[email protected]>
  • Loading branch information
guidari and tay1orjones authored Sep 15, 2023
1 parent 33f414f commit 616e981
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 12 deletions.
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');
});
});

0 comments on commit 616e981

Please sign in to comment.