pcbjam/tests/playwright-web.config.ts
Istvan Matejcsok dc7c60f723 feat(mobile): canvas-only mobile mode — pinch-zoom/pan/tap gestures + chrome-less editors
On a mobile device (or ?mobile=1) the editors run canvas-only with touch
gestures driving the view:

- touch-gestures.ts: pure recognizer (unit-tested) + DOM shim installed in
  boot preRun — one-finger drag → synthetic middle-drag (pan), pinch →
  synthetic wheel at the centroid (zoom-to-cursor), tap → left click.
  preRun registration order is what lets stopImmediatePropagation suppress
  the wx layer's single-finger→LEFT-drag touch mapping.
- kicadSetChrome(bool) embind: hides all AUI panes except DrawFrame + the
  menubar/status bar via generic wx APIs (kicad fork untouched); boot polls
  it after runtime init. Pairs with the wxwidgets IsShown layout fix.
- mobile-mode.ts: ?mobile=1/0 override or UA-CH/coarse-pointer autodetect;
  shell hides its overlays and the inherent-to-mobile preflight warnings.
- e2e: mobile-chromium project (Pixel 7) + 4 specs (chrome-less, tap,
  pinch, pan) with screenshot-invertibility assertions; also fixes
  tool-switch.spec's stale pre-scope-refactor URLs (was broken on main).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 16:15:37 +02:00

80 lines
2.9 KiB
TypeScript
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 { defineConfig, devices } from '@playwright/test';
/**
* E2E config for the React WEB APP (web/standalone editor at :3048 + the
* @pcbjam/backend-example reference backend at :3060), as opposed to
* playwright-kicad.config.ts which drives the standalone tool harness HTMLs
* under tests/apps/kicad.
*
* These tests exercise the real web open paths: navigate to /p/<project>/<tool>/<file>,
* let WasmTool boot the tool in-document (boot.ts), drive the project into MEMFS
* and auto-open the file (open-flow.ts via Module.kicadOpenFile), and assert the
* editor loaded wizard-free.
*
* The backend serves a single project off the local filesystem — no DB, no
* seeding. The webServer block reuses an already-running stack (`pnpm dev` from
* web/) or cold-starts it with the env below, pointing PROJECT_DIR at the
* committed tests/fixtures/demo project (slug "demo").
*
* Firefox is the reliable headless target on ARM Mac (Chromium SwiftShader WebGL
* bug); use --project=chromium (system Chrome) for headed debugging.
*/
const FRONTEND_URL = process.env.WEB_APP_URL ?? 'http://localhost:3048';
export default defineConfig({
globalSetup: './web/global-setup-web.ts',
testDir: './web',
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
// KiCad WASM is process-global (one runtime per page) and each tool wasm is
// 40200 MB; run serially to avoid loading several giant runtimes at once.
workers: 1,
reporter: 'html',
timeout: 180000, // tool wasm download + boot + open can take minutes
use: {
baseURL: FRONTEND_URL,
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
},
projects: [
{
name: 'firefox',
testIgnore: /mobile-.*\.spec\.ts/,
use: { ...devices['Desktop Firefox'], viewport: { width: 1280, height: 720 } },
},
{
name: 'chromium',
testIgnore: /mobile-.*\.spec\.ts/,
use: { channel: 'chrome', viewport: { width: 1280, height: 720 } },
},
{
// Canvas-only mobile mode (features/mobile). Mobile emulation is
// Chromium-only, and headless SwiftShader WebGL is broken on ARM Mac (see
// header) — run this project headed locally: --project=mobile-chromium --headed.
name: 'mobile-chromium',
testMatch: /mobile-.*\.spec\.ts/,
use: { ...devices['Pixel 7'], channel: 'chrome' },
},
],
webServer: {
// Best-effort: reuse the dev stack if it's already up (the common case);
// otherwise cold-start turbo dev with the env a fresh checkout needs
// (turbo passes these through, so no hand-copied .env files required).
command: 'pnpm --dir ../web dev',
url: FRONTEND_URL,
reuseExistingServer: true,
timeout: 120000,
env: {
...process.env,
// resolved against web/backend/ (the backend's cwd)
PROJECT_DIR: '../../tests/fixtures/demo',
VITE_API_BASE_URL: 'http://localhost:3060',
CORS_ORIGIN: 'http://localhost:3048',
},
},
});