-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
ContentSwitcher-test.avt.e2e.js
75 lines (67 loc) · 2.41 KB
/
ContentSwitcher-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
/**
* 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('@avt ContentSwitcher', () => {
test('@avt-default-state ContentSwitcher', async ({ page }) => {
await visitStory(page, {
component: 'ContentSwitcher',
id: 'components-contentswitcher--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('ContentSwitcher');
});
test('@avt-advanced-states icon only', async ({ page }) => {
await visitStory(page, {
component: 'ContentSwitcher',
id: 'components-contentswitcher--icon-only',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('ContentSwitcher--icon-only');
});
test('@avt-keyboard-nav ContentSwitcher', async ({ page }) => {
await visitStory(page, {
component: 'ComboButton',
id: 'components-contentswitcher--default',
globals: {
theme: 'white',
},
});
const firstContentTab = page.getByRole('tab', { name: 'First section' });
const secondContentTab = page.getByRole('tab', { name: 'Second section' });
const thirdContentTab = page.getByRole('tab', { name: 'Third section' });
// Testing content switcher
await expect(firstContentTab).toBeVisible();
await page.keyboard.press('ArrowRight');
await expect(secondContentTab).toBeVisible();
await page.keyboard.press('ArrowRight');
await expect(thirdContentTab).toBeVisible();
});
test('@avt-keyboard-nav ContentSwitcher Icon only', async ({ page }) => {
await visitStory(page, {
component: 'ComboButton',
id: 'components-contentswitcher--icon-only',
globals: {
theme: 'white',
},
});
const firstIconTab = page.getByRole('tab', { name: 'Table of Contents' });
const secondIconTab = page.getByRole('tab', { name: 'Workspace Test' });
const thirdIconTab = page.getByRole('tab', { name: 'View Mode' });
// Testing content switcher
await expect(firstIconTab).toBeVisible();
await page.keyboard.press('ArrowRight');
await expect(secondIconTab).toBeVisible();
await page.keyboard.press('ArrowRight');
await expect(thirdIconTab).toBeVisible();
});
});