Files
BortStack/react/e2e/homepage-fidelity.spec.js
T

23 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { expect, test } from '@playwright/test'
// Measured from assets/references/home-approved-direction.png (1024×1536).
// These are composition anchors, not acceptance of missing brand/media assets.
test('homepage composition stays aligned with approved desktop reference', async ({ page }, testInfo) => {
await page.setViewportSize({ width: 1024, height: 1536 })
await page.goto('/')
await page.evaluate(() => globalThis.document.fonts.ready)
const header = await page.getByRole('navigation', { name: 'Main navigation' }).boundingBox()
expect(Math.abs(header.height - 67)).toBeLessThanOrEqual(3)
const media = await page.getByRole('region', { name: 'Featured project' }).getByRole('img').boundingBox()
for (const [actual, reference] of [[media.x, 56], [media.y, 814], [media.width, 507], [media.height, 267]]) {
expect(Math.abs(actual - reference)).toBeLessThanOrEqual(8)
}
const closing = await page.getByRole('region', { name: 'Have a project in mind?' }).boundingBox()
expect(Math.abs(closing.x - 35)).toBeLessThanOrEqual(2)
expect(Math.abs(closing.y - 1287)).toBeLessThanOrEqual(15)
expect(Math.abs(closing.width - 954)).toBeLessThanOrEqual(3)
expect(Math.abs(closing.height - 203)).toBeLessThanOrEqual(6)
await page.screenshot({ path: testInfo.outputPath('homepage-reference-viewport.png') })
await page.screenshot({ path: testInfo.outputPath('homepage-reference-full.png'), fullPage: true })
})