microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
docs/docusaurus/e2e/mobile-menu.spec.ts
28lines · modecode
| 1 | import { test, expect } from '@playwright/test'; |
| 2 | import AxeBuilder from '@axe-core/playwright'; |
| 3 | |
| 4 | const WCAG_TAGS = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']; |
| 5 | |
| 6 | // WCAG 2.1.2 No Keyboard Trap: the mobile navigation menu must open, expose its |
| 7 | // contents to assistive tech, and remain operable in its expanded state. |
| 8 | test.use({ viewport: { width: 390, height: 844 } }); |
| 9 | |
| 10 | test.describe('Mobile navigation menu', () => { |
| 11 | test('toggle opens the sidebar and the opened state passes an axe scan', async ({ page }) => { |
| 12 | await page.goto('/hve-core/docs/getting-started/'); |
| 13 | |
| 14 | const toggle = page.locator('.navbar__toggle'); |
| 15 | await expect(toggle).toBeVisible(); |
| 16 | |
| 17 | await toggle.click(); |
| 18 | |
| 19 | const mobileSidebar = page.locator('.navbar-sidebar'); |
| 20 | await expect(mobileSidebar).toBeVisible(); |
| 21 | |
| 22 | const results = await new AxeBuilder({ page }) |
| 23 | .withTags(WCAG_TAGS) |
| 24 | .include('.navbar-sidebar') |
| 25 | .analyze(); |
| 26 | expect(results.violations).toEqual([]); |
| 27 | }); |
| 28 | }); |
| 29 | |