Files
token-circles/frontend/playwright.shots.config.ts
KomediruzeckiandGitHub 4de84a5a04 feat(pwa): a maskable icon and install-dialog screenshots (#431)
The manifest declared four `any` icons and no screenshots, so Chrome's
install dialog fell back to a name, an icon and a URL — and Android, given
nothing maskable, did not mask ours: it shrank the whole square into a white
circle, which is the small dark tile in a white ring on the home screen.

The maskable master is the same artwork with a full-bleed background and
scale(0.8) on the content, so all of it clears the 80% safe circle; without
that a circular mask clips the orange marker, which reaches 207px from the
centre of a 512 canvas against a 204.8px safe radius.

Six screenshots, wide and narrow, re-shootable with `npm run pwa:shots`
against the same two servers and the same seeded fixture the e2e suite uses.

The manifest moved into src/pwaManifest.ts so a test can read the PNG headers
back off disk and check them against the declared sizes. Everything here
fails silently in a browser and never reaches a build log — which is how the
test found that icon-192.svg, declared 192x192, is a byte-identical copy of
icon-512.svg drawing a 512 canvas. Collapsed to one `sizes: 'any'` entry.
2026-08-24 04:09:44 +02:00

77 lines
2.3 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test'
import {
E2E_API_BASE,
E2E_API_PORT,
E2E_BASE,
E2E_PORT,
STORAGE_STATE,
} from './tests/e2e-constants'
/**
* The manifest screenshots, re-shot on demand:
*
* cd frontend && npm run pwa:shots
*
* Deliberately a SECOND config rather than a spec in the main suite. These write into
* `public/`, they take a browser at two fixed viewports, and they are not assertions — running
* them on every CI push would mean every run produced a dirty working tree.
*
* Everything else is shared with playwright.config.ts on purpose: the same two servers
* (wrangler on a local D1, vite proxying /api at it), the same setup project, and therefore the
* same seeded fixture account. A screenshot pipeline with its own idea of what the data looks
* like drifts from the app the moment either side moves.
*/
export default defineConfig({
timeout: 120000,
fullyParallel: false,
// Two viewports against one wrangler process, and the shots are ordered by the spec.
workers: 1,
retries: 0,
reporter: 'list',
use: {
baseURL: E2E_BASE,
headless: true,
testIdAttribute: 'data-test-id',
// Shot at 2x and downscaled by the encoder step in the spec: a browser at
// deviceScaleFactor 2 renders text on the full hinting grid, and an exact 2:1 reduction
// keeps that detail rather than asking the resampler to invent it.
deviceScaleFactor: 2,
},
projects: [
{ name: 'setup', testDir: './tests', testMatch: /global\.setup\.ts/ },
{
name: 'shots',
testDir: './tests-shots',
use: {
...devices['Desktop Chrome'],
storageState: STORAGE_STATE,
deviceScaleFactor: 2,
colorScheme: 'dark',
},
dependencies: ['setup'],
},
],
webServer: [
{
command: `pnpm run d1:migrate:local && pnpm exec wrangler dev --port ${E2E_API_PORT}`,
cwd: '../worker',
url: `${E2E_API_BASE}/api/health`,
reuseExistingServer: true,
timeout: 120000,
stdout: 'pipe',
stderr: 'pipe',
},
{
command: `npm run dev -- --port ${E2E_PORT} --strictPort`,
url: E2E_BASE,
reuseExistingServer: true,
timeout: 120000,
stdout: 'pipe',
stderr: 'pipe',
env: { API_PROXY_TARGET: E2E_API_BASE },
},
],
})