import { expect, test } from '@playwright/test' for (const width of [320, 768, 1440]) { test(`homepage composition at ${width}px`, async ({ page }) => { await page.setViewportSize({ width, height: 900 }) const errors = [] const failedRequests = [] page.on('pageerror', error => errors.push(error.message)) page.on('requestfailed', request => failedRequests.push(request.url())) await page.emulateMedia({ reducedMotion: 'reduce' }) await page.goto('/') const hero = page.getByRole('region', { name: /software solutions/i }) await expect(hero.getByRole('link')).toHaveCount(1) await expect(page.getByRole('region', { name: 'What we do' }).getByRole('link')).toHaveCount(4) await expect(page.getByRole('region', { name: 'Featured project' }).getByRole('img')).toHaveCount(1) await expect(page.getByText('Featured project pending')).toBeVisible() await expect(page.getByRole('region', { name: 'Why BortStack' }).getByRole('heading', { level: 3 })).toHaveCount(3) expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true) for (const heading of await page.getByRole('heading').all()) { const box = await heading.boundingBox() expect(box.x).toBeGreaterThanOrEqual(0) expect(box.x + box.width).toBeLessThanOrEqual(width + 1) } await hero.getByRole('link', { name: 'Discuss a Project' }).click() await expect(page).toHaveURL(/\/contact$/) await expect(page.getByRole('heading', { name: 'Have a project in mind?', exact: true })).toBeVisible() expect(errors).toEqual([]) expect(failedRequests).toEqual([]) }) }