# Testing Ekklesia separates fast code-level evidence from live infrastructure evidence. ## Unit and repository verification ```bash pnpm test pnpm verify ``` These commands exercise package tests, repository boundaries, type checking, offline Core and module migration discovery, identity schema drift detection, formatting, linting, and builds. Migration-runner unit tests use a narrow database/session port to prove deterministic planning, approval, transaction orchestration, cleanup, and sanitized errors. They do not claim to prove PostgreSQL behavior. Identity unit tests cover branded opaque-ID contracts, principal shapes, configuration validation (secret rules, canonical-origin-only base URL and trusted origins, and the full loopback/unspecified classifier production rejects — `.localhost`, all of `127.0.0.0/8`, `0.0.0.0`, `::1` compressed and expanded, `::`, and IPv4-mapped forms), bounded/validated connection and operation (`query_timeout`/`statement_timeout`) database timeouts, the Core identity runtime (explicit construction, exact schema mapping, only email/password and rate limiting enabled, an explicit `advanced.disableCSRFCheck`/`disableOriginCheck: false` pair, an explicit error-only sanitized logger that strips Better Auth's own message and arguments regardless of what they contain, pinned 8–128 password-length bounds, sanitized failures, exact whole-name session-cookie detection that never fires on a prefixed, suffixed, or differently-cased lookalike, and that a broken session store during principal resolution is never silently reported as anonymous while an unrelated cookie performs no identity database work at all), the PostgreSQL transport policy (`core/tests/database-transport.test.ts`: mode validation including every loose or aliased spelling, production's plaintext refusal with no loopback exception, connection-string TLS-parameter rejection, and that no configuration path yields `rejectUnauthorized: false` or leaks CA material into an error), and Core migration discovery (deterministic ordering, the reserved `core` identity, and collision rejection) — all without a live database. `apps/api`'s own unit tests cover its pure Hono app factory (route shapes, module route mounting/enforcement/CORS/response sanitization, CORS allow/deny/preflight, deterministic 404 and sanitized error responses), its runtime configuration, its idempotent shutdown lifecycle (concurrent callers share one server-close-then-module-runtime-stop-then-pool-close promise; a module-stop failure never prevents pool cleanup; a startup failure after the pool was already created still closes it, stopping the module runtime first if it had already started; `SIGINT`/`SIGTERM` wiring is exercised through an injectable exit function rather than the real `process.exit`), and that importing any of its modules — including the executable server module without calling its exported `main` — never reads the environment, connects to PostgreSQL, imports a module entrypoint, or starts a server. Real, working (non-throwing) module fixtures prove production module-runtime startup/shutdown ordering and cleanup against a mocked pool/Better Auth/server — see [Authorization](authorization.md#tests). Phase 7B pass 1 adds browser-authentication evidence ([ADR 0034](../architecture/decisions/0034-host-owned-browser-authentication.md)). API tests pin the two exact browser-boundary exceptions. Any body-bearing successful `2xx` from `POST /api/auth/sign-in/email` preserves Better Auth's `Set-Cookie` and status but returns fixed `{"ok":true}`, with no token/user body. `/api/auth/get-session`, `/api/auth/list-sessions`, `/api/auth/update-session`, and `/api/auth/change-password` each receive the identical sanitized `404` without invoking the identity handler; failures and every other supported auth route retain their native semantics. The live browser transport additionally proves the host-only cookie and that no token, session, user, or email appears in the sign-in body. Shell protocol and React tests cover principal-first anonymous/authenticated/failure states; the labelled email/password form and keyboard submission; autocomplete, pending state, and same-tick duplicate suppression; password clearing; fixed credential-versus-service errors; no credential or raw exception logging; fresh principal and navigation resolution after login; sign-out followed by principal resolution; and retry without a full-page reload. The same shell suites exercise session transitions under repeated timing: active module cleanup and realtime teardown on sign-out/verified expiry; stale attempts after unmount; platform bootstrap `401` mapping directly to unauthenticated; and deduplicated principal revalidation for both module `401` and `403`. They prove an authenticated recheck preserves the module's original response, session, and mounted UI; an anonymous recheck unmounts once and shows login; a revalidation failure is a sanitized host failure; and a response from an already-unmounted frame cannot overwrite a newer transition. Return/callback input is not part of the browser contract, and tests pin that external, protocol-relative, backslash-prefixed, and scheme-bearing values cannot become navigation. Modularity checks keep authentication out of the module UI SDK/context and Dashboard login code out of the separate display bundle. Phase 8 adds evidence for the five platform prerequisites. **Design tokens and shared elements** (ADR 0039). The token registry's tests prove it is deterministic and enumerable, that every token derives a unique `--ekklesia-*` identifier from its name and carries a label, description, and category, that each status family pairs a colour with a non-colour symbol, and that a duplicate name, an unknown category, an invalid or single-segment name, and a value carrying a declaration terminator, a rule block, a comment, an at-rule, `url(`, `!important`, an escape, a control character, or markup are each rejected — with an error that never echoes the rejected declaration. The elements' tests assert accessible structure (label/hint/error association, icon-button naming, tab roles and arrow-key movement, announced error and loading states), that status never depends on colour alone, that a dialog renders in place rather than portalling out of an isolated root, and — mechanically — that the stylesheet and every component source contain no literal colour, font stack, or theme value and reference only registered tokens. Both packages compile module-shaped source under the exact browser project a module uses, where `process.env` must fail to typecheck, so the browser boundary is measured rather than asserted. **Module stylesheets and artifact isolation** (ADR 0040). The builder's tests prove a plain stylesheet is compiled into the declared artifact with no `.css` emitted beside it, that a local `@import` is inlined, and that an unresolved `@import`, a stylesheet declaring an `--ekklesia-*` variable, and a non-CSS dialect are each rejected with their own sanitized code — while a private alias derived from a registered token is accepted. The loader's tests prove every artifact mounts inside an open shadow root, that the artifact receives that root rather than the host's element, that exactly one `