microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
docs/docusaurus/e2e/doc-navigation.spec.ts
35lines · 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 | // Document navigation: the sidebar, prev/next pagination, and breadcrumbs must |
| 7 | // drive real navigation and remain accessible. |
| 8 | test.describe('Document navigation', () => { |
| 9 | test('sidebar renders and breadcrumbs are present on a doc page', async ({ page }) => { |
| 10 | await page.goto('/hve-core/docs/getting-started/'); |
| 11 | |
| 12 | await expect(page.locator('.theme-doc-sidebar-container')).toBeVisible(); |
| 13 | await expect(page.locator('nav.theme-doc-breadcrumbs')).toBeVisible(); |
| 14 | |
| 15 | const results = await new AxeBuilder({ page }).withTags(WCAG_TAGS).analyze(); |
| 16 | expect(results.violations).toEqual([]); |
| 17 | }); |
| 18 | |
| 19 | test('pagination navigates to an adjacent doc', async ({ page }) => { |
| 20 | // Start from the docs landing page, whose "next" link targets a distinct |
| 21 | // adjacent doc (deeper category-index pages can emit a self-referential |
| 22 | // next link, which would never change the URL). |
| 23 | await page.goto('/hve-core/docs/'); |
| 24 | |
| 25 | const nextLink = page.locator('.pagination-nav__link--next'); |
| 26 | await expect(nextLink).toBeVisible(); |
| 27 | |
| 28 | const startUrl = page.url(); |
| 29 | await nextLink.click(); |
| 30 | await page.waitForLoadState('networkidle'); |
| 31 | |
| 32 | expect(page.url()).not.toBe(startUrl); |
| 33 | await expect(page.getByRole('main')).toBeVisible(); |
| 34 | }); |
| 35 | }); |
| 36 | |