michaelpeskov/tests/e2e/home.spec.ts

34 lines
1.1 KiB
TypeScript

import { test, expect } from '@playwright/test'
test('sticky CTA present and i18n toggle works', async ({ page }) => {
await page.goto('/')
const cta = page.locator('.floatingCTA')
await expect(cta).toBeVisible()
const toggle = page.getByRole('button', { name: /switch language/i })
await expect(toggle).toBeVisible()
await toggle.click()
await page.waitForURL(/lang=de/)
await expect(page.locator('text=Jetzt anfragen').first()).toBeVisible()
})
test('CLS guard on hero: cumulative layout shift stays under 0.05', async ({ page }) => {
await page.addInitScript(() => {
(window as any).__cls = 0
new PerformanceObserver((list) => {
for (const entry of list.getEntries() as PerformanceEntry[] & any) {
if (!entry.hadRecentInput) {
;(window as any).__cls += (entry as any).value
}
}
}).observe({ type: 'layout-shift', buffered: true })
})
await page.goto('/')
await page.waitForTimeout(1000)
const cls = await page.evaluate(() => (window as any).__cls || 0)
expect(cls).toBeLessThan(0.05)
})
test.skip('FAQ a11y keyboard toggling (deferred)', async ({ page }) => {
await page.goto('/')
})