import AxeBuilder from '@axe-core/playwright' import { expect, test } from '@playwright/test' for (const [path, heading] of [ ['/', /Software solutions\s*for real-world use\./], ['/services', 'Services'], ['/projects', 'Projects'], ['/projects/example', 'Project not found'], ['/about', 'About BortStack'], ['/contact', 'Have a project in mind?'], ['/privacy', 'Privacy policy'], ['/login', 'Page not found'], ['/dashboard', 'Page not found'], ]) { test(`${path} renders without overflow or auth requests`, async ({ page }) => { const errors = [] const accountRequests = [] page.on('pageerror', error => errors.push(error.message)) page.on('request', request => { if (/\/api\//.test(request.url()) && !request.url().endsWith('/api/contact/config')) accountRequests.push(request.url()) }) await page.goto(path) await expect(page.getByRole('heading', { name: heading, exact: true })).toBeVisible() expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true) expect(errors).toEqual([]) expect(accountRequests).toEqual([]) }) } test('public shell has accessible landmarks and first keyboard skip link', async ({ page }) => { await page.goto('/') await page.keyboard.press('Tab') await expect(page.getByRole('link', { name: 'Skip to main content' })).toBeFocused() await expect(page.getByRole('main')).toHaveCount(1) expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([]) }) test('privacy draft is accessible and excluded from indexing', async ({ page }) => { await page.goto('/privacy') await expect(page.locator('meta[name="robots"]')).toHaveAttribute('content', 'noindex, nofollow') await expect(page.getByRole('heading', { name: 'Project enquiries' })).toBeVisible() expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([]) }) test('navigation works and closes on mobile selection', async ({ page, isMobile }) => { await page.goto('/') const navigation = page.getByRole('navigation', { name: 'Main navigation' }) if (isMobile) await page.getByRole('button', { name: 'Toggle navigation' }).click() await navigation.getByRole('link', { name: 'Services', exact: true }).click() await expect(page.getByRole('heading', { name: 'Services', exact: true })).toBeVisible() if (isMobile) await expect(page.getByRole('button', { name: 'Toggle navigation' })).toHaveAttribute('aria-expanded', 'false') await expect(page.getByRole('link', { name: /login|register|dashboard/i })).toHaveCount(0) })