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 avt tests for OverflowMenu #14250

Merged
merged 8 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
102 changes: 102 additions & 0 deletions e2e/components/OverflowMenu/OverflowMenu-test.avt.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* 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('OverflowMenu', () => {
test('accessibility-checker @avt', async ({ page }) => {
guidari marked this conversation as resolved.
Show resolved Hide resolved
await visitStory(page, {
component: 'OverflowMenu',
id: 'components-overflowmenu--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('OverflowMenu');
});

test('accessibility-checker render custom icon @avt', async ({ page }) => {
await visitStory(page, {
component: 'OverflowMenu',
id: 'components-overflowmenu--render-custom-icon',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('OverflowMenu-custom-icon');
});

test('accessibility-checker open menu @avt', async ({ page }) => {
await visitStory(page, {
component: 'OverflowMenu',
id: 'components-overflowmenu--default',
globals: {
theme: 'white',
},
});
await expect(page.getByRole('button')).toBeVisible();

// Tab and open the toggle button for the OverflowMenu
await page.keyboard.press('Tab');
const toggleButton = page.getByRole('button');
await expect(toggleButton).toBeFocused();
await page.keyboard.press('Enter');
await expect(toggleButton).toHaveClass(/cds--overflow-menu--open/);

await expect(page).toHaveNoACViolations('OverflowMenu-open');
});

test('accessibility-checker render custom icon open @avt', async ({
page,
}) => {
await visitStory(page, {
component: 'OverflowMenu',
id: 'components-overflowmenu--render-custom-icon',
globals: {
theme: 'white',
},
});
await expect(page.getByRole('button')).toBeVisible();

// Tab and open the toggle button for the OverflowMenu
await page.keyboard.press('Tab');
const toggleButton = page.getByRole('button');
await expect(toggleButton).toBeFocused();
await page.keyboard.press('Enter');
await expect(toggleButton).toHaveClass(/cds--overflow-menu--open/);
guidari marked this conversation as resolved.
Show resolved Hide resolved

await expect(page).toHaveNoACViolations('OverflowMenu-custom-icon-open');
});

test('overflow-menu - keyboard nav', async ({ page }) => {
await visitStory(page, {
component: 'OverflowMenu',
id: 'components-overflowmenu--default',
globals: {
theme: 'white',
},
});
await expect(page.getByRole('button')).toBeVisible();

// Tab and open the toggle button for the OverflowMenu
await page.keyboard.press('Tab');
const toggleButton = page.getByRole('button');
await expect(toggleButton).toBeFocused();
await page.keyboard.press('Enter');
await expect(toggleButton).toHaveClass(/cds--overflow-menu--open/);
// Navigation inside the menu
await expect(page.getByTestId('stop-app')).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByTestId('restart-app')).toBeFocused();
guidari marked this conversation as resolved.
Show resolved Hide resolved
await page.keyboard.press('Enter');
// focus comes back to the toggle button
await expect(toggleButton).toBeFocused();
});
});
26 changes: 2 additions & 24 deletions e2e/components/OverflowMenu/OverflowMenu-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');
const { test } = require('@playwright/test');
const { themes } = require('../../test-utils/env');
const { snapshotStory, visitStory } = require('../../test-utils/storybook');
const { snapshotStory } = require('../../test-utils/storybook');

test.describe('OverflowMenu', () => {
themes.forEach((theme) => {
Expand Down Expand Up @@ -47,26 +47,4 @@ test.describe('OverflowMenu', () => {
});
});
});

test('accessibility-checker @avt', async ({ page }) => {
await visitStory(page, {
component: 'OverflowMenu',
id: 'components-overflowmenu--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('OverflowMenu');
});

test('feature flag accessibility-checker @avt', async ({ page }) => {
await visitStory(page, {
component: 'OverflowMenu',
id: 'experimental-feature-flags-overflowmenu--overflow-menu',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('OverflowMenu');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default {

export const Default = () => (
<OverflowMenu aria-label="overflow-menu">
<OverflowMenuItem itemText="Stop app" />
<OverflowMenuItem itemText="Restart app" />
<OverflowMenuItem itemText="Stop app" data-testid="stop-app" />
<OverflowMenuItem itemText="Restart app" data-testid="restart-app" />
<OverflowMenuItem itemText="Rename app" />
<OverflowMenuItem itemText="Clone and move app" disabled requireTitle />
<OverflowMenuItem itemText="Edit routes and access" requireTitle />
Expand Down
Loading