|
1 | 1 | import { e2eStandToHtml } from '@semcore/testing-utils/e2e-stand'; |
2 | 2 | import { expect, test, getAccessibilityViolations } from '@semcore/testing-utils/playwright'; |
3 | | - |
4 | | -test.describe('Wizard axe checks', () => { |
| 3 | +import type { Page, Locator } from '@semcore/testing-utils/playwright'; |
| 4 | +import { loadPage } from '@semcore/testing-utils/shared/helpers'; |
| 5 | +import { TAG } from '@semcore/testing-utils/shared/tags'; |
| 6 | + |
| 7 | +export const locators = { |
| 8 | + button: (page: Page, name?: string, index?: number): Locator => { |
| 9 | + const base = page.getByRole('button', { name }); |
| 10 | + return typeof index === 'number' ? base.nth(index) : base; |
| 11 | + }, |
| 12 | +}; |
| 13 | + |
| 14 | +test.describe(`@wizard ${TAG.ACCESSIBILITY}`, () => { |
5 | 15 | test('Base example', async ({ page }) => { |
6 | | - const standPath = 'stories/components/wizard/docs/examples/basic_example.tsx'; |
7 | | - const htmlContent = await e2eStandToHtml(standPath, 'en'); |
| 16 | + await loadPage(page, 'stories/components/wizard/docs/examples/basic_example.tsx', 'en'); |
8 | 17 |
|
9 | | - await page.setContent(htmlContent); |
10 | 18 | await page.keyboard.press('Tab'); |
11 | 19 | await page.keyboard.press('Enter'); |
12 | | - await page.waitForTimeout(100); |
| 20 | + await locators.button(page, 'Close').waitFor({ state: 'visible' }); |
13 | 21 | const violations = await getAccessibilityViolations({ page }); |
14 | 22 |
|
15 | 23 | expect(violations).toEqual([]); |
16 | 24 | }); |
17 | 25 |
|
18 | 26 | test('Custom Step', async ({ page }) => { |
19 | | - const standPath = 'stories/components/wizard/docs/examples/custom_step.tsx'; |
20 | | - const htmlContent = await e2eStandToHtml(standPath, 'en'); |
| 27 | + await loadPage(page, 'stories/components/wizard/docs/examples/custom_step.tsx', 'en'); |
21 | 28 |
|
22 | | - await page.setContent(htmlContent); |
23 | 29 | await page.keyboard.press('Tab'); |
24 | 30 | await page.keyboard.press('Enter'); |
25 | | - await page.waitForTimeout(100); |
| 31 | + await locators.button(page, 'Close').waitFor({ state: 'visible' }); |
26 | 32 | const violations = await getAccessibilityViolations({ page }); |
27 | 33 |
|
28 | 34 | expect(violations).toEqual([]); |
29 | 35 | }); |
30 | 36 |
|
31 | 37 | test('Custom Stepper', async ({ page }) => { |
32 | | - const standPath = 'stories/components/wizard/docs/examples/custom_stepper.tsx'; |
33 | | - const htmlContent = await e2eStandToHtml(standPath, 'en'); |
| 38 | + await loadPage(page, 'stories/components/wizard/docs/examples/custom_stepper.tsx', 'en'); |
34 | 39 |
|
35 | | - await page.setContent(htmlContent); |
36 | 40 | await page.keyboard.press('Tab'); |
37 | 41 | await page.keyboard.press('Enter'); |
38 | | - await page.waitForTimeout(100); |
| 42 | + await locators.button(page, 'Close').waitFor({ state: 'visible' }); |
39 | 43 | const violations = await getAccessibilityViolations({ page }); |
40 | 44 |
|
41 | 45 | expect(violations).toEqual([]); |
|
0 commit comments