forked from carbon-design-system/carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slug-test.avt.e2e.js
100 lines (89 loc) · 2.84 KB
/
Slug-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
92
93
94
95
96
97
98
99
100
/**
* 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('@avt Slug', async () => {
test('@avt-default-state', async ({ page }) => {
await visitStory(page, {
component: 'Slug',
id: 'experimental-unstable-slug--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Slug');
});
test.slow('@avt-advanced-states open state', async ({ page }) => {
await visitStory(page, {
component: 'Slug',
id: 'experimental-unstable-slug--default',
globals: {
theme: 'white',
},
});
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Enter');
await expect(page).toHaveNoACViolations('Slug-open');
});
test.slow('@avt-advanced-states ai form', async ({ page }) => {
await visitStory(page, {
component: 'Slug',
id: 'experimental-unstable-slug-form--form-example',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('Slug-form');
});
test('@avt-keyboard-nav - slug', async ({ page }) => {
await visitStory(page, {
component: 'Search',
id: 'experimental-unstable-slug--callout',
globals: {
theme: 'white',
},
});
const slug = page.getByRole('button', {
name: 'AI - Show information',
});
const callout = page.locator('.cds--popover--open');
await expect(slug).toBeVisible();
await expect(callout).toBeVisible();
// Tab to the Slug
await page.keyboard.press('Tab');
await expect(slug).toBeFocused();
// Close the slug (example is open by default)
await page.keyboard.press('Enter');
await expect(callout).toBeHidden();
// Should also be able to open with space
await page.keyboard.press('Space');
await expect(callout).toBeVisible();
// Tab should go to buttons, and then close after last button
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await expect(
page.getByRole('button', {
name: 'View details',
})
).toBeFocused();
await page.keyboard.press('Tab');
await expect(callout).toBeHidden();
// Should also close on escape
await page.keyboard.press('Shift+Tab');
await page.keyboard.press('Shift+Tab');
await expect(callout).toBeHidden();
await slug.click();
await expect(callout).toBeVisible();
await page.keyboard.press('Escape');
await expect(callout).toBeHidden();
});
});