-
Notifications
You must be signed in to change notification settings - Fork 584
/
Copy pathAxe.test.ts
52 lines (46 loc) · 1.69 KB
/
Axe.test.ts
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
import {test, expect} from '@playwright/test'
// @ts-ignore since this file is generated in the ci to generate this file run npx build storybook in packages/react
import componentsConfig from '../../packages/react/storybook-static/index.json'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
/**
* These stories should not be tested in the CI because they are stress-tests and
* perform slowly
*/
const SKIPPED_TESTS = [
'components-treeview-features--stress-test',
'components-treeview-features--contain-intrinsic-size',
'components-flash-features--with-icon-action-dismiss', // TODO: Remove once color-contrast issues have been resolved
'components-flash-features--with-icon-and-action', // TODO: Remove once color-contrast issues have been resolved
'components-filteredactionlist--default',
]
type Component = {
name: string
}
const {entries} = componentsConfig
test.describe('Axe tests', () => {
for (const [id, entry] of Object.entries(entries as Record<string, Component>)) {
if (SKIPPED_TESTS.includes(id)) {
continue
}
const {name} = entry
// remove parentheses and slashes from the name to avoid playwright file issues
// eslint-disable-next-line no-useless-escape
const cleanedName = name.replaceAll(/[\(\)\/]/g, '')
test.describe(id, () => {
for (const theme of themes) {
test.describe(theme, () => {
test(`@aat ${cleanedName}`, async ({page}) => {
await visit(page, {
id,
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})
}
})