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

Add Keyboard Nav AVT test for ToggleTip #14916

Merged
merged 3 commits into from
Oct 31, 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
57 changes: 57 additions & 0 deletions e2e/components/Toggletip/Toggletip-test.avt.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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('Toggletip @avt', () => {
test('@avt-default-state Toggletip', async ({ page }) => {
await visitStory(page, {
component: 'Toggletip',
id: 'components-toggletip--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Toggletip');
});

test('@avt-keyboard-nav Toggletip', async ({ page }) => {
await visitStory(page, {
component: 'Toggletip',
id: 'components-toggletip--default',
globals: {
theme: 'white',
},
});

// Checking if the defaultOpen is working
await expect(page.locator('.cds--popover--open')).toBeVisible();

// Checking first Toggletip interaction
await page.keyboard.press('Tab');
await expect(page.getByLabel('Show information').first()).toBeFocused();
await page.keyboard.press('Enter');
await expect(page.locator('.cds--popover--open')).toBeVisible();
// Tabbing inside the popover
await page.keyboard.press('Tab');
await expect(page.locator('.cds--link').first()).toBeFocused();
await page.keyboard.press('Tab');
await expect(page.getByRole('button', { name: 'Button' })).toBeFocused();
await page.keyboard.press('Tab');
await expect(page.locator('.cds--popover--open')).not.toBeVisible();

// Checking second Toggletip interaction and close on Escape key
await expect(page.getByLabel('Show information').last()).toBeFocused();
await page.keyboard.press('Enter');
await expect(page.locator('.cds--popover--open')).toBeVisible();
await page.keyboard.press('Escape');
await expect(page.locator('.cds--popover--open')).not.toBeVisible();
});
});
17 changes: 3 additions & 14 deletions e2e/components/Toggletip/Toggletip-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 { themes } = require('../../test-utils/env');
const { snapshotStory, visitStory } = require('../../test-utils/storybook');
import { test } from '@playwright/test';
import { themes } from '../../test-utils/env';
import { snapshotStory } from '../../test-utils/storybook';

test.describe('Toggletip', () => {
themes.forEach((theme) => {
Expand All @@ -23,15 +23,4 @@ test.describe('Toggletip', () => {
});
});
});

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