import AxeBuilder from '@axe-core/playwright' import { expect, test } from '@playwright/test' for (const theme of ['dark', 'light']) { test(`${theme} footer identity, navigation and accessibility on public routes`, async ({ page }) => { await page.addInitScript(theme => localStorage.setItem('bortstack-theme', theme), theme) for (const path of ['/', '/services', '/about', '/contact', '/projects', '/projects/example', '/privacy']) { await page.goto(path) const footer = page.getByRole('contentinfo') await expect(footer).toContainText('BortStack') await expect(footer).not.toContainText(/roborto/i) await expect(footer.getByText('Navigation', { exact: true })).toBeVisible() await expect(footer.getByRole('link')).toHaveCount(5) await expect(footer.getByRole('img')).toHaveCount(0) await expect(footer).toContainText('Software, websites and integrations built around your business.') for (const [name, href] of [['Services', '/services'], ['Projects', '/projects'], ['About', '/about'], ['Contact', '/contact'], ['Privacy', '/privacy']]) { await expect(footer.getByRole('link', { name, exact: true })).toHaveAttribute('href', href) } expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true) } const footer = page.getByRole('contentinfo') await footer.getByRole('link', { name: 'Contact', exact: true }).focus() await page.keyboard.press('Enter') await expect(page).toHaveURL(/\/contact$/) await footer.getByRole('link', { name: 'Privacy', exact: true }).focus() await page.keyboard.press('Enter') await expect(page).toHaveURL(/\/privacy$/) expect((await new AxeBuilder({ page }).include('footer').analyze()).violations).toEqual([]) }) } for (const width of [1440, 768, 375, 320]) { test(`footer follows showcase navigation layout at ${width}px`, async ({ page }) => { await page.setViewportSize({ width, height: 900 }) await page.goto('/') const links = page.getByRole('navigation', { name: 'Footer navigation' }).getByRole('link') const boxes = await Promise.all((await links.all()).map(link => link.boundingBox())) expect(boxes).toHaveLength(4) if (width >= 768) { expect(Math.max(...boxes.map(box => box.y)) - Math.min(...boxes.map(box => box.y))).toBeLessThan(2) } else { expect(Math.abs(boxes[0].y - boxes[1].y)).toBeLessThan(2) expect(boxes[2].y).toBeGreaterThan(boxes[0].y) expect(Math.abs(boxes[2].y - boxes[3].y)).toBeLessThan(2) } expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true) }) }