auth-yes/tasks/complete/2026-0825.01.jul.story.arch.monolith-decomposition-roadmap-1845.ph5.md
google-labs-jules[bot] 0d59c2ac75 refactor(test): decompose main.test.ts into domain specific test files
Extracted the 1,577-line monolithic `server/main.test.ts` into five isolated, domain-specific files under `server/tests/`:
- `forward_auth.test.ts`: ForwardAuth bypass, cookie scoping, and sandbox.
- `rpc.test.ts`: ConnectRPC SPIFFE and RBAC tests.
- `auth.test.ts`: Audit ledger, WebAuthn PRF, passkey magic links.
- `events.test.ts`: Multi-claim join endpoints and killswitch.
- `scopes.test.ts`: Zero-trust guards and self-revocations.

Successfully maintained all tests cleanly isolated via standard mocking and deleted `main.test.ts` after migrating and executing `deno test --allow-all` with zero failures.

Co-authored-by: mrteye <1945243+mrteye@users.noreply.github.com>
2026-08-26 05:12:08 +00:00

42 lines
1.9 KiB
Markdown

# TASK METADATA
- **Target Files:** `server/main.test.ts`, `server/tests/forward_auth.test.ts`,
`server/tests/rpc.test.ts`, `server/tests/auth.test.ts`,
`server/tests/events.test.ts`, `server/tests/scopes.test.ts`
- **Core Objective:** Phase 5 (Test Suite Tier Separation): Decompose the
1,577-line `server/main.test.ts` monolith into isolated, domain-specific test
suites under `server/tests/` preserving 100% test coverage and hermetic
execution without live database daemons.
- **Dependencies:**
`tasks/new/2026-0825.01.jul.story.arch.monolith-decomposition-roadmap-1845.md`
- **Additional Important Notes:** Must run with `deno test --allow-all` and
maintain all 59+ test steps passing cleanly.
---
### 2. Architectural Considerations & Risks
- **Risks:**
- Mock state pollution across test files (e.g. shared `sqlWrapper` or `valkey`
stubs leaking between test cases).
- **Alternatives:**
- Keeping all tests in `server/main.test.ts`; rejected because single massive
test files make targeted debugging and CI test parallelization difficult.
### 3. Proposed Implementation
1. **Create Domain Test Files (`server/tests/`):**
- `server/tests/forward_auth.test.ts`: Tier 1 & 2 ForwardAuth tests, cookie
domain scoping, bypass rules, and guest sandbox tests.
- `server/tests/rpc.test.ts`: Tier 3 ConnectRPC session validation, RBAC
grant evaluation, and SPIFFE attestation tests.
- `server/tests/auth.test.ts`: WebAuthn registration/login PRF extraction,
session creation, and audit logging.
- `server/tests/events.test.ts`: Multi-claim event passes, PIN join
endpoints, session extension, and master killswitch.
- `server/tests/scopes.test.ts`: Zero-trust scope guards, self-revocation,
and UI `/admin` redirection gates.
2. **Quality Gates & Validation:**
- Run `deno test --allow-all` to ensure all domain test suites execute
hermetically and pass with 0 failures.