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 TimePicker #14908

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

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

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

const inputTime = page.locator('#time-picker');
await expect(inputTime).toBeVisible();
await page.keyboard.press('Tab');

// Checking input time interaction
await expect(inputTime).toBeFocused();
await inputTime.fill('11:45');
await expect(inputTime).toHaveValue('11:45');

// Checking select time interaction
await page.keyboard.press('Tab');
const selectTime = page.locator('#time-picker-select-1');
await page.keyboard.press('Space');
await selectTime.selectOption('PM');
await expect(selectTime).toHaveValue('PM');

// Checking select time zone interaction
await page.keyboard.press('Tab');
const selectTimeZone = page.locator('#time-picker-select-2');
await page.keyboard.press('Space');
await selectTimeZone.selectOption('Time zone 1');
await expect(selectTimeZone).toHaveValue('Time zone 1');
});

test('@avt-keyboard-nav TimePicker with layer', async ({ page }) => {
await visitStory(page, {
component: 'TimePicker',
id: 'components-timepicker--with-layer',
globals: {
theme: 'white',
},
});

// Testing focus on each layer
await expect(page.locator('#time-picker-0')).toBeVisible();
await page.keyboard.press('Tab');
await expect(page.locator('#time-picker-0')).toBeFocused();

await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');

await expect(page.locator('#time-picker-1')).toBeVisible();
await expect(page.locator('#time-picker-1')).toBeFocused();

await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');

await expect(page.locator('#time-picker-2')).toBeVisible();
await expect(page.locator('#time-picker-2')).toBeFocused();
});
});
17 changes: 3 additions & 14 deletions e2e/components/TimePicker/TimePicker-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('TimePicker', () => {
themes.forEach((theme) => {
Expand All @@ -31,15 +31,4 @@ test.describe('TimePicker', () => {
});
});
});

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