e2e: run Detox suite against local Worker + local D1
Makes the Detox E2E suite runnable against a LOCAL Worker (wrangler dev + local D1) instead of local Django or prod workers.dev. DO NOT MERGE yet — orchestrator coordinates merge with the detox lane (they hold an untracked file at front/e2e/seedHelpers.js).
Runbook:
Terminal 1: cd worker && npx wrangler dev (needs worker/.dev.vars with JWT_SECRET — gitignored, local-only; then migrations + seed below)
Terminal 2: API_BASE_URL=http://127.0.0.1:8787/api npx detox test -c ios.sim.debug
What changed (2 new files, +567):
- worker/scripts/seed-local-e2e.sql — inserts ONLY e2e-test-user (id 60) + e2e-teen-helper (id 61, maya@school.edu) with pbkdf2 testpassword123 hashes (cheap 10k-iter Django format, iteration-agnostic per crypto.ts), PIN-less bots_useraccount rows (sub level 0), plus one default bots_aimodel row (bootstrap/ensureBot need it). Idempotent (OR REPLACE/OR IGNORE). Load: wrangler d1 execute syft-db --local --file=./scripts/seed-local-e2e.sql
- front/e2e/seedHelpers.js (CREATED fresh — absent on origin/main) — shared REST helpers plus D1-direct helpers (d1/resetPinLockoutState/resetOnboardingFresh/deleteAllChatsD1/ensureSubscriptionLevel) that shell out to wrangler d1 execute --local on 127.0.0.1:8787 bases, use Cloudflare D1 REST on workers.dev, and throw Django seed hints on localhost:8000.
Verification (no simulator; wrangler dev + migrations + seed loaded locally): node script logging in as both users, resetOnboardingFresh, ensurePin/reauth-wrong-then-right/resetPinLockoutState/ensureNoPin round-trip, deleteAllChatsD1, renames, deleteExtra helpers, getDefaultModelId, completeOnboarding, helper /login, Django-hint error — 19/19 PASS (one wrangler --json quirk: NULL TEXT reads back as string 'null'; harmless, worker treats it as unlocked).
Specs will need beyond seedHelpers: specs currently inline their own token/profile/bot fetching (no seedHelpers import on main) — adopting them to require('./seedHelpers') is the detox lane's call; helper PIN default is '1234'; teen-delegated minting (01 spec shells to Django venv) has no Worker equivalent yet — GET /api/login with the helper session returns delegated tokens only when a parent-owned profile binds maya@school.edu.
Summary by cubic
Makes the Detox E2E suite runnable against a local Worker (wrangler dev + local D1) instead of Django or prod workers.dev, via two new files: a Worker SQL seed and shared front-end helpers. Do not merge yet — the orchestrator coordinates with the detox lane, which holds an untracked copy of front/e2e/seedHelpers.js.
What changed
worker/scripts/seed-local-e2e.sqlseeds only the two E2E users (ids 60/61, passwordtestpassword123via cheap 10k-iteration pbkdf2 hashes) with PIN-less accounts and one default AI model; re-runs are idempotent.front/e2e/seedHelpers.jsadds REST plus D1-direct helpers: local bases shell out towrangler d1 execute --local, workers.dev bases use the Cloudflare D1 REST API, and Django bases throw a seed-command hint.- Verified without a simulator: 19/19 node-script checks pass against local
wrangler dev; specs still inline their own token/profile/bot fetching, and adopting them torequire('./seedHelpers')is the detox lane's call.
Migration (local runbook)
- Terminal 1:
cd worker && npx wrangler dev; first time, createworker/.dev.varswith aJWT_SECRET, apply local migrations, and loadworker/scripts/seed-local-e2e.sqlvianpx wrangler d1 execute syft-db --local --file=./scripts/seed-local-e2e.sql. - Terminal 2:
API_BASE_URL=http://127.0.0.1:8787/api npx detox test -c ios.sim.debug <spec>.