mission-control/tests
Nyk 45ad4a488b test: add 94 E2E tests covering all CRUD routes + fix middleware location
Add comprehensive Playwright E2E test coverage for all major API routes:
- tasks-crud (18 tests): full lifecycle, filters, Aegis approval gate
- agents-crud (15 tests): CRUD, lookup by name/id, admin-only delete
- task-comments (7 tests): threaded comments, validation
- workflows-crud (8 tests): workflow template lifecycle
- webhooks-crud (9 tests): secret masking, regeneration
- alerts-crud (8 tests): alert rule lifecycle
- notifications (7 tests): delivery tracking, read status
- quality-review (6 tests): reviews with batch lookup
- search-and-export (7 tests): global search, export, activities
- user-management (8 tests): user admin CRUD
- helpers.ts: shared factory functions and cleanup utilities

Infrastructure fixes:
- Move middleware.ts to src/middleware.ts (Next.js 16 Turbopack
  requires middleware in src/ when using src/app/ directory — the
  root-level file was silently ignored, breaking CSRF protection)
- Add MC_DISABLE_RATE_LIMIT env var to bypass non-critical rate
  limiters during E2E runs (login limiter stays active via critical flag)
- Fix limit-caps test: /api/activities caps at 500, not 200
- Set playwright workers=1, fullyParallel=false for serial execution
- Add CSRF origin fallback to request.nextUrl.host

Roadmap additions from user feedback:
- Agent-agnostic gateway support (not just OpenClaw)
- Direct CLI integration (Codex, Claude Code, etc.)
- Native macOS app (Electron or Tauri)

146/146 E2E tests passing (up from 51).
2026-03-02 02:21:10 +07:00
..
README.md test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
agents-crud.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
alerts-crud.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
auth-guards.spec.ts test: add 52 Playwright E2E tests covering all critical fixes 2026-02-27 15:38:49 +07:00
csrf-validation.spec.ts test: add 52 Playwright E2E tests covering all critical fixes 2026-02-27 15:38:49 +07:00
delete-body.spec.ts test: add 52 Playwright E2E tests covering all critical fixes 2026-02-27 15:38:49 +07:00
helpers.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
legacy-cookie-removed.spec.ts test: add 52 Playwright E2E tests covering all critical fixes 2026-02-27 15:38:49 +07:00
limit-caps.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
login-flow.spec.ts test: add 52 Playwright E2E tests covering all critical fixes 2026-02-27 15:38:49 +07:00
notifications.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
quality-review.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
rate-limiting.spec.ts test: add 52 Playwright E2E tests covering all critical fixes 2026-02-27 15:38:49 +07:00
search-and-export.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
task-comments.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
tasks-crud.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
timing-safe-auth.spec.ts test: add 52 Playwright E2E tests covering all critical fixes 2026-02-27 15:38:49 +07:00
user-management.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
webhooks-crud.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00
workflows-crud.spec.ts test: add 94 E2E tests covering all CRUD routes + fix middleware location 2026-03-02 02:21:10 +07:00

README.md

E2E Tests

Playwright end-to-end specs for Mission Control API and UI.

Running

# Start the dev server first (or let Playwright auto-start via reuseExistingServer)
pnpm dev --hostname 127.0.0.1 --port 3005

# Run all tests
pnpm test:e2e

# Run a specific spec
pnpm exec playwright test tests/tasks-crud.spec.ts

Test Environment

Tests require .env.local with:

  • API_KEY=test-api-key-e2e-12345
  • MC_DISABLE_RATE_LIMIT=1 (bypasses mutation/read rate limits, keeps login rate limit active)

Spec Files

Security & Auth

  • auth-guards.spec.ts — All API routes return 401 without auth
  • csrf-validation.spec.ts — CSRF origin header validation
  • legacy-cookie-removed.spec.ts — Old cookie format rejected
  • login-flow.spec.ts — Login, session, redirect lifecycle
  • rate-limiting.spec.ts — Login brute-force protection
  • timing-safe-auth.spec.ts — Constant-time API key comparison

CRUD Lifecycle

  • tasks-crud.spec.ts — Tasks POST/GET/PUT/DELETE with filters, Aegis gate
  • agents-crud.spec.ts — Agents CRUD, lookup by name/id, admin-only delete
  • task-comments.spec.ts — Threaded comments on tasks
  • workflows-crud.spec.ts — Workflow template CRUD
  • webhooks-crud.spec.ts — Webhooks with secret masking and regeneration
  • alerts-crud.spec.ts — Alert rule CRUD with full lifecycle
  • user-management.spec.ts — User admin CRUD

Features

  • notifications.spec.ts — Notification delivery and read tracking
  • quality-review.spec.ts — Quality reviews with batch lookup
  • search-and-export.spec.ts — Global search, data export, activity feed

Infrastructure

  • limit-caps.spec.ts — Endpoint limit caps enforced
  • delete-body.spec.ts — DELETE body standardization

Shared

  • helpers.ts — Factory functions (createTestTask, createTestAgent, etc.) and cleanup helpers