/
Popover-test.avt.e2e.js
91 lines (77 loc) · 3.14 KB
/
Popover-test.avt.e2e.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Copyright IBM Corp. 2022
*
* 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('@avt Popover', () => {
test('@avt-advanced-states auto align', async ({ page }) => {
await visitStory(page, {
component: 'Popover',
id: 'components-popover--experimental-auto-align',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Popover-auto-align');
});
test('@avt-advanced-states tab tip', async ({ page }) => {
await visitStory(page, {
component: 'Popover',
id: 'components-popover--tab-tip',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Popover-tab-tip');
});
test('@avt-keyboard-nav tab tip', async ({ page }) => {
await visitStory(page, {
component: 'Popover',
id: 'components-popover--tab-tip',
globals: {
theme: 'white',
},
});
const leftButton = page.getByRole('button', { name: 'Settings' }).first();
const rightButton = page.getByRole('button', { name: 'Settings' }).last();
await expect(leftButton).toBeVisible();
await page.keyboard.press('Tab');
await expect(leftButton).toBeFocused();
// Checking popover state and interaction with Enter key
await expect(page.locator('.cds--popover--open')).toBeVisible();
await page.keyboard.press('Enter');
await expect(page.locator('.cds--popover--open')).toBeHidden();
// Checking popover state and interaction with Space key
await page.keyboard.press('Space');
await expect(page.locator('.cds--popover--open')).toBeVisible();
await page.keyboard.press('Space');
await expect(page.locator('.cds--popover--open')).toBeHidden();
// Checking popover state and interaction with Escape key
await page.keyboard.press('Space');
await expect(page.locator('.cds--popover--open')).toBeVisible();
await page.keyboard.press('Escape');
await expect(page.locator('.cds--popover--open')).toBeHidden();
// Testing right popover
await page.keyboard.press('Tab');
await expect(rightButton).toBeFocused();
// Checking popover state and interaction with Enter key
await page.keyboard.press('Enter');
await expect(page.locator('.cds--popover--open')).toBeVisible();
await page.keyboard.press('Enter');
await expect(page.locator('.cds--popover--open')).toBeHidden();
// Checking popover state and interaction with Space key
await page.keyboard.press('Space');
await expect(page.locator('.cds--popover--open')).toBeVisible();
await page.keyboard.press('Space');
await expect(page.locator('.cds--popover--open')).toBeHidden();
// Checking popover state and interaction with Escape key (it should not close)
await page.keyboard.press('Space');
await expect(page.locator('.cds--popover--open')).toBeVisible();
await page.keyboard.press('Escape');
await expect(page.locator('.cds--popover--open')).toBeVisible();
});
});