Skip to main content

29 · Testing, deploy & operations

Local development (Node ≥ 20)

cd frontend; npm ci; npm run build        # → dist/
cd ../worker; npm ci; npm run gen-assets  # embed dist into src/assets.js
npm run d1:migrate                        # migrations on the local dev DB
npx wrangler dev                          # http://localhost:8787

A fresh dev DB has no password until one is set through the first-run screen.

npm test (from worker/)

One command, same in PowerShell, Git Bash and CI (scripts/run-tests.mjs). Per suite: a throwaway state folder in the OS temp dir, migrations applied, wrangler dev --local started with that suite’s variables, waits until the Worker answers, runs, then always stops the server and deletes the state. Builds the frontend first if src/assets.js is missing or stale. Exits non-zero if anything fails. Options: --port <n> (or TEST_PORT, default 8787), --only family,push,local,assistant,chat, --keep-state, --startup-timeout <s>. Refuses to start if the port is in use.

Suite What it checks
test-local.mjs End-to-end API suite (450 checks, 21 sections): seeds a full fake plan, exercises the API, guest pages v1–v5, preview gate, countdown HTML, access codes, RSVP flow, imports, deadline recalcs, and the email pipeline in simulation. Needs internet DNS (*.127.0.0.1.nip.io). Section 20 probes every route without a session.
test-assistant.mjs Email assistant against a fake mailbox and fake Claude API; proves canary env vars never reach the SDK
test-chat.mjs In-app chat against a fake Claude, a fake push service that decrypts every push, and fake SMTP
test-family.mjs Family portal unit suite (76 checks, no server): real RS256 tokens vs mocked certs (bad signature / audience / issuer / expiry / alg:none / key rotation), host isolation, list check, policy sync
test-push.mjs Web Push encryption + VAPID
test-site.mjs every host, link and the cookie domain derive from SITE_DOMAIN
test-brand.mjs branding strings, the neutral fallback, placeholder escaping
test-log-safe.mjs log redaction masks emails

Refactor guards (the index.js split, worker/docs/index-split-map.md)

  • routes: route sets per method must match scripts/route-baseline.json; a module that registers routes but isn’t imported fails; no overlapping patterns; layering holds (no upward import, no route→route import, no cycle).
  • lint: ESLint no-undef.
  • bundle: dry-run size within ±2 KiB of scripts/bundle-baseline.json (baseline 1789.04 KiB), every route registration present in the bundle.
  • move-selftest / move: check-move proves a split PR moves code verbatim (by AST node), rejecting known tricks (aliases, side-effect imports, hidden U+2028/U+2029/CR, edited lines). fix-imports may edit only import lines. Rendered outputs are compared before and after with scripts/capture-outputs.mjs.

Deploying: push-to-deploy (Cloudflare Workers Builds)

Setting Value
Branch main (every push to main is a deploy)
Root directory worker
Build command npm ci && node test-family.mjs && node test-site.mjs && cd ../frontend && npm ci && npm run build && cd ../worker && npm run gen-assets
Deploy command npx wrangler deploy (branches: npx wrangler deploy --dry-run, so they get the same red/green check without touching live)
  • Deploy gate: the build is a && chain, so a failing unit suite or a TypeScript error (npm run build is tsc && vite build) stops the deploy and the old version keeps serving.
  • The full npm test isn’t in the build (it needs workerd and DNS), so run npm test green before merging anything that touches the Worker.
  • Both package-lock.json files must be committed and current. Workers Builds ignores any [build] block in wrangler.toml and makes its own deploy token.
  • After a deploy, verify-live.mjs runs (CI runs it after every production deploy): apex and its guest API public; planner, v1–v5 and family behind Access; www a 301 to the apex keeping path and query; the MCP host 401 without a token. Options LIVE_DOMAIN, LIVE_MCP_HOST, VERIFY_ATTEMPTS (default 3).

Manual deploy, same result: cd frontend; npm run build → cd ../worker; npm run gen-assets → npx wrangler deploy.

Monitoring

  • Workers → Builds for deploys; Workers → Observability for logs; Workers → Metrics for request counts.
  • Each cron run logs one cron digest: and one cron assistant: line (states and counts only).
  • Per-request logs off, query strings redacted, /mcp/<token> requests silent, emails masked.

Runtime settings

compatibility_date = 2026-11-13, nodejs_compat_do_not_populate_process_env (process.env stays empty), keep_vars = true, Wrangler 4, postal-mime 4.0.8.

Backups

D1 Time Travel (30 days, restore with wrangler d1 time-travel restore, the API or the dashboard), plus Download full backup on Setup for long-term or off-site copies.

Operating rules (project invariants)

  1. Migrations are additive only.
  2. Never touch live guest/RSVP rows directly; go through the app’s matching and review flows.
  3. One feature per deploy.
  4. No credentials in the repo.
  5. No personal data in the repo; names, dates and venues belong in Setup.

Ops log

demo-preview-handoff.txt in the repo root is the running operations log: every change to setup, DB, Worker and frontend, deployments, restore-point bookmarks. No credentials.