import AxeBuilder from '@axe-core/playwright' import { expect, test } from '@playwright/test' const publicPages = [ ['/', 'Build your application from here'], ['/contact', 'Contact'], ['/privacy', 'Privacy policy'], ['/terms', 'Terms of service'], ['/login', 'Login'], ['/register', 'Register'], ['/forgot-password', 'Reset password'], ] for (const [path, heading] of publicPages) { test(`${path} renders without horizontal overflow`, async ({ page }) => { await page.goto(path) await expect(page.getByRole('heading', { name: heading, exact: true })).toBeVisible() const dimensions = await page.locator('html').evaluate((element) => ({ viewport: element.clientWidth, content: element.scrollWidth, })) expect(dimensions.content).toBeLessThanOrEqual(dimensions.viewport) }) } test('public shell passes automated accessibility diagnostics', async ({ page }) => { await page.goto('/contact') const results = await new AxeBuilder({ page }).analyze() expect(results.violations).toEqual([]) }) test('skip link is the first keyboard navigation target', async ({ page }) => { await page.goto('/') await page.keyboard.press('Tab') const skipLink = page.getByRole('link', { name: 'Skip to main content' }) await expect(skipLink).toBeFocused() await expect(skipLink).toHaveAttribute('href', '#main-content') }) test('mobile navigation expands and exposes public destinations', async ({ page, isMobile }) => { test.skip(!isMobile, 'mobile navigation diagnostic') await page.goto('/') await page.getByRole('button', { name: 'Toggle navigation' }).click() await expect(page.getByRole('link', { name: 'Contact', exact: true }).first()).toBeVisible() await expect(page.getByRole('link', { name: 'Login', exact: true })).toBeVisible() }) test('contact form reports mocked delivery success', async ({ page }) => { await page.route('**/api/contact', async (route) => { await route.fulfill({ status: 200, contentType: 'application/json', body: '{"success":true}' }) }) await page.goto('/contact') await page.getByLabel('Name').fill('Example Person') await page.getByLabel('Email').fill('person@example.com') await page.getByLabel('Subject').fill('A useful question') await page.getByLabel('Message').fill('This message is long enough to be accepted.') await page.getByRole('button', { name: 'Send message' }).click() await expect(page.getByRole('status')).toContainText('message has been sent') }) test('protected dashboard with no session does not expose its content', async ({ page }) => { await page.goto('/dashboard') await expect(page.getByRole('heading', { name: 'Unauthorized' })).toBeVisible() await expect(page.getByText('Protected application workspace')).toHaveCount(0) await expect(page.locator('meta[name="robots"]')).toHaveAttribute('content', 'noindex, nofollow') })