Files
crumbs/tests/e2e/pwa.spec.ts
T
Frederic CabassutandClaude Fable 5.1 7bf06edd97 perf(e2e): log in once and share the admin session via storage state
Every test in the `app` project submitted the login form through the
authenticatedPage fixture: a page load, an Argon2 verification on the
server, a redirect and a networkidle wait. Over 137 tests that was
roughly half of the median test's 1.8s.

A new `login-state` setup project (tests/e2e/auth.setup.ts) authenticates
once after auth.spec has created the account and saves the session cookie
to data/test-storage-state.json. The `app` project loads it into every
context, so setupAndLogin takes its "session still valid" path and the
fixture is reduced to a page load.

pwa.spec and mcp.spec describe anonymous visitors and opt out with an
empty storageState so their baseline is unchanged.

Local run, 4 workers: summed test time 276s -> 256s, median 1.8s -> 1.6s.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 15:29:46 +02:00

29 lines
1.1 KiB
TypeScript

import { test, expect } from '@playwright/test';
// These scenarios describe what an anonymous visitor receives, so drop the
// shared admin session the `app` project injects.
test.use({ storageState: { cookies: [], origins: [] } });
test.describe('PWA', () => {
test('Scenario: Web manifest provides correct app metadata', async ({ page }) => {
// When the browser requests the web manifest
const response = await page.goto('/manifest.webmanifest');
// Then it returns successfully with the correct app name, display mode, and icons
expect(response?.status()).toBe(200);
const manifest = await response?.json();
expect(manifest?.name).toBe('Crumbs by Bretzel');
expect(manifest?.display).toBe('standalone');
expect(manifest?.icons?.length).toBeGreaterThan(0);
});
test('Scenario: Application declares a theme color for mobile browsers', async ({ page }) => {
// Given the application is loaded
await page.goto('/login');
// Then a theme-color meta tag is present
const themeColor = await page.getAttribute('meta[name="theme-color"]', 'content');
expect(themeColor).toBeTruthy();
});
});