Skip to content

Testing

This page documents the verification infrastructure that actually exists in the repositories — nothing more.

Backend test suites (dps-code-api)

The API repository contains executable contract suites. They import the real Flask app but replace Supabase with an in-memory fake, so they exercise route logic, gates, and response contracts without a database:

SuiteCovers
report_route_tests.pyReport create/list/update/delete routes, actions, notes/evidence/timeline, contact, gates, error mapping
punishment_route_tests.pyPunishment create/edit/revoke, discipline queue, user-lookup flow, permissions
training_route_tests.pyTraining auth/API-key rejection, role gates, session lifecycle, action idempotency, engine evaluation, controls, realtime config/token
authz_tests.pyClearance/rank gates, assignment matching, admin gating
db_access_tests.pySerializers, identifier scrubbing, profile normalization
action_queue_tests.pyQueue helpers, claim/requeue logic, error mapping
event_service_tests.pyEvent recording, taxonomy validation
agents_service_tests.py / admin_service_tests.pyAgent/admin contracts
contact_threads_tests.pyContact serialization
oauth_service_tests.pyOAuth helpers, return_to validation
health_service_tests.pyHealth payload building
environment_tests.pyEnvironment config isolation, session binding, ingress resolution
datetime_unix_tests.pyJS-date → Unix timestamp parsing
erlc_relay_route_tests.py / erlc_relay_failover_tests.py / erlc_relay_failover_smoke.pyER:LC relay route, failover ordering, circuit breaker
training_runtime_tests.pySession payload assembly, elapsed time, role filters
security_hardening_tests.pyURL validation, body limits, identifier bounds, CORS

Run a suite with the API's Python environment:

bash
cd dps-code-api
source .venv/bin/activate
python report_route_tests.py
python training_route_tests.py

Limitations: the fake Supabase proves route logic and response contracts, not actual PostgREST query behavior, RLS execution, or database transaction semantics. SQL-level behavior (row locks, error tags, privileges) is verified against a real PostgreSQL project when migrations are applied.

Frontend checks (ecc-dps-dashboard)

CommandWhat it does
npm run buildtsc -b (project typecheck) then vite build (production bundle)
npm run lintESLint over the repository
npm run smoke:typechecktsc --noEmit -p tsconfig.playwright.json (Playwright specs)
npm run smokePlaywright suite against the configured base URL
npm run smoke:loginInteractive production session capture (saves playwright/.auth/state.json)

Interpreting failures:

  • npm run build failures are type errors or bundling problems — fix them before anything else; the build is the project's primary gate.
  • The repository has known pre-existing ESLint debt: lint failures unrelated to your change are tracked separately and do not gate release (per the project's recent release work). Do not "fix" unrelated lint noise in the same change.
  • npm run smoke runs against production (https://eccdps.org by default) with a saved auth state — it requires a valid saved session and stable production fixtures, and is not part of a clean-checkout flow.

Playwright suites (tests/smoke/)

SpecCovers
smoke.spec.tsDashboard stats, docket sorting/filters/pagination, detail rendering, queue sections, audit log
training.spec.tsTrainer dashboard, new-session modal, history, dockets, recovery panel
realtime-join.spec.tsAPI-minted Realtime token + private channel joins (asserts SUBSCRIBED)
realtime-live.spec.tsLive trainer→trainee transition without refresh (creates + aborts an isolated session)
agent-management.spec.tsAgent-management flows

Additional diagnostic/E2E scripts live in playwright/ (trainee flows, pause/abort, grading, recovery behavior). Some are production workflow harnesses that create disposable training sessions — treat them as diagnostics, not stable unit tests.

Database / RPC tests

There is no separate SQL test harness in the repository. Verification of migrations and RPCs is performed by:

  1. Applying the full chain 000034 in order to a scratch PostgreSQL 16 project;
  2. exercising each RPC's happy path + documented error tags and privilege posture (public/anon/authenticated denied, service_role allowed);
  3. checking RLS behavior with browser-role JWTs where relevant (migrations 026/027 document their live verification).

What is not covered (known gaps)

  • No broad frontend unit/component tests (React components and the Realtime hook lifecycle are covered only via Playwright).
  • Production smoke tests depend on saved OAuth state and existing data.
  • The API contract suites do not prove real database transaction/RLS behavior.
  • No CI workflow is configured in the repositories — verification runs locally/manually.