test(e2e): make Playwright BASE_URL-overridable + record Phase 2 e2e baseline

- playwright.config.ts: honor BASE_URL env (and skip the auto-started webServer when
  set) so a server booted from a specific worktree on a non-default port can be tested
  without fighting over :3333.
- skill test-recipes.md: record the recipe for running e2e from a non-default worktree
  (in-process test server + reseed helper) and the measured baseline on the merged
  hx-select reference: swap-doctrine 6/6 green; transaction-edit.spec.ts has a
  pre-existing Shared-Location save failure that masks 7 via serial mode; full suite
  30 pass / 2 fail / 7 skip. Gate for the refactor = swap spec + REPL pure-fn checks.
This commit is contained in:
2026-06-03 00:18:31 -07:00
parent bdb286ca71
commit ed3344438b
2 changed files with 58 additions and 12 deletions

View File

@@ -82,8 +82,46 @@ The full suite must stay green after every migration. Specs touching the migrate
| `e2e/transaction-import.spec.ts` | 4 | import |
| `e2e/transaction-navigation.spec.ts` | 13 | navigation |
**Pass/fail baseline: TO BE CAPTURED at the first Phase 2 e2e run** against a test server
booted from *this* worktree (`integreat-execute-refactor`). At distillation time `:3333`
was occupied by the `integreat-render-whole-form` worktree (morph version), so a run then
would not reflect the merged hx-select reference. Record the green count here once
captured, and never drop below it.
### Running e2e from a non-default worktree (recipe)
`:3333` is often taken by another worktree's server. To run this worktree's code:
1. Boot the test server in-process on this worktree's REPL at an alternate port — no
second JVM, and it live-reloads as you edit:
```clojure
(require '[auto-ap.test-server :as ts] '[ring.adapter.jetty :refer [run-jetty]]
'[datomic.api :as dc])
;; reseed helper — call before each full run so state doesn't leak between runs
(defn reseed! []
(try (.stop (:server test-srv)) (catch Throwable _))
(try (dc/delete-database "datomic:mem://playwright-test") (catch Throwable _))
(def test-srv (let [c (ts/create-test-db) id (ts/seed-test-data c)]
(reset! ts/test-transaction-id id)
{:server (run-jetty (ts/test-app) {:port 3334 :join? false}) :tx-id id})))
(reseed!)
```
2. `playwright.config.ts` honors `BASE_URL`; setting it also disables the auto-started
webServer (so worktrees don't fight over :3333):
```bash
BASE_URL=http://localhost:3334 npx playwright test --workers=1 --reporter=line
```
3. **Reseed (`reseed!`) before each full run.** One long-lived in-process server persists
its in-mem DB across separate `npx playwright` invocations; the swap spec's
`clearAccounts`/save mutate the shared transaction and leak into later specs. The
normal harness avoids this by booting a fresh server per `npx playwright test`.
### Pass/fail baseline — measured on the merged hx-select reference (Phase 2 start)
Server: in-process from `integreat-execute-refactor` on `:3334`, `--workers=1`, fresh seed.
| Spec | Result |
|------|--------|
| `transaction-edit-swap.spec.ts` | **6 / 6 pass** — the whole-form swap parity contract |
| `transaction-edit.spec.ts` | **1 fail (masks 7 via `mode: 'serial'`)** — `Shared Location … spread on save and reopen` fails: the save POST returns a validation error (amount/balance test-data assumption: "$200 = full amount of the 2nd transaction" doesn't hold), so the modal stays open. **Pre-existing on the merged reference, not introduced by this work.** |
| Full suite (39) | **30 pass / 2 fail / 7 skipped.** 2nd failure: `transaction-navigation.spec.ts` date-range persistence (`date-range=all` expected, got `month`) — drift from the base branch's "require Apply for date-range filters" change, unrelated to forms. |
**Gate for the Transaction Edit refactor:** the 6/6 swap-doctrine spec + REPL pure-fn
checks. The `transaction-edit.spec.ts` `Shared Location` failure must be understood/fixed
to unmask the other 7 before that file can serve as a full parity gate — it is **not**
a regression to introduce, but it does cap the available characterization coverage today.
Never drop below 30 passing on the full suite.

View File

@@ -1,5 +1,11 @@
import { defineConfig, devices } from '@playwright/test';
// Allow pointing the suite at an already-running test server (e.g. one booted from a
// specific worktree on a non-default port) via BASE_URL. When BASE_URL is set we skip
// the auto-started webServer entirely, so parallel worktrees don't fight over :3333.
const baseURL = process.env.BASE_URL ?? 'http://localhost:3333';
const useExternalServer = !!process.env.BASE_URL;
export default defineConfig({
testDir: './e2e',
fullyParallel: true,
@@ -8,15 +14,17 @@ export default defineConfig({
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: 'http://localhost:3333',
baseURL,
trace: 'on-first-retry',
},
webServer: {
command: 'lein run -m auto-ap.test-server',
url: 'http://localhost:3333/test-info',
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
webServer: useExternalServer
? undefined
: {
command: 'lein run -m auto-ap.test-server',
url: 'http://localhost:3333/test-info',
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
projects: [
{
name: 'chromium',