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 AVT test for ComboButton #14687

Merged
merged 1 commit into from
Sep 27, 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
98 changes: 98 additions & 0 deletions e2e/components/ComboButton/ComboButton-test.avt.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Copyright IBM Corp. 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('ComboButton @avt', () => {
test('@avt-default-state ComboButton ', async ({ page }) => {
await visitStory(page, {
component: 'ComboButton',
id: 'components-combobutton--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('ComboButton');
});

test('@avt-advanced-states ComboButton With Danger ', async ({ page }) => {
await visitStory(page, {
component: 'ComboButton',
id: 'components-combobutton--with-danger',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('ComboButton-with-danger');
});

test('@avt-keyboard-nav ComboButton', async ({ page }) => {
await visitStory(page, {
component: 'ComboButton',
id: 'components-combobutton--default',
globals: {
theme: 'white',
},
});
const primaryButton = page.getByRole('button', { name: 'Primary action' });
const iconButton = page.locator('button.cds--btn--icon-only');

// Testing buttons
await expect(primaryButton).toBeVisible();
await page.keyboard.press('Tab');
await expect(primaryButton).toBeFocused();
await page.keyboard.press('Enter');
await page.keyboard.press('Tab');
await expect(iconButton).toBeFocused();

// Checking menu interaction
await page.keyboard.press('Enter');
await expect(page.getByRole('menuitem').first()).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem').nth(1)).toBeFocused();
await page.keyboard.press('Escape');
await expect(page.getByRole('menuitem').first()).not.toBeVisible();
});

test('@avt-keyboard-nav ComboButton with danger', async ({ page }) => {
await visitStory(page, {
component: 'ComboButton',
id: 'components-combobutton--with-danger',
globals: {
theme: 'white',
},
});
const primaryButton = page.getByRole('button', { name: 'Primary action' });
const iconButton = page.locator('button.cds--btn--icon-only');

// Testing buttons
await expect(primaryButton).toBeVisible();
await page.keyboard.press('Tab');
await expect(primaryButton).toBeFocused();
await page.keyboard.press('Enter');
await page.keyboard.press('Tab');
await expect(iconButton).toBeFocused();

// Checking menu interaction
await page.keyboard.press('Enter');
await expect(page.getByRole('menuitem').first()).toBeFocused();
await page.keyboard.press('ArrowDown');
await page.keyboard.press('ArrowDown');
await page.keyboard.press('ArrowDown');
// Checking danger button
await expect(page.getByRole('menuitem').nth(3)).toBeFocused();
await expect(page.getByRole('menuitem').nth(3)).toHaveClass(
/cds--menu-item--danger/
);
// Selecting the item to close the menu
await page.keyboard.press('Enter');
await expect(page.getByRole('menuitem').first()).not.toBeVisible();
});
});
15 changes: 2 additions & 13 deletions e2e/components/ComboButton/ComboButton-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('ComboButton', () => {
themes.forEach((theme) => {
Expand All @@ -23,15 +23,4 @@ test.describe('ComboButton', () => {
});
});
});

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