Description
The 49-file vitest suite covers stream CRUD and middleware but has sparse coverage of the admin route surface in src/routes/admin.ts. Routes for pause flags (GET/PUT /api/admin/pause), read-only mode (GET /api/admin/status/read-only), DLQ management, API-key lifecycle, and reindex operations lack dedicated integration tests. Full coverage of these routes is critical since they control operational state of the running service.
Requirements and context
- Add tests for all admin route permutations: pause enable/disable, read-only mode toggle, DLQ list/delete, API-key create/list/delete, and admin status
- Test both
operator (authorised) and viewer/unauthenticated (forbidden) paths for every route
- Use
supertest with an in-process Express app and a seeded test database
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested execution
Fork the repo and create a branch
git checkout -b feature/admin-endpoint-test-coverage
Implement changes
- Update/Write:
tests/routes/admin.pause.test.ts — pause and read-only mode tests
- Update/Write:
tests/routes/admin.dlq.test.ts — DLQ CRUD tests
- Update/Write:
tests/routes/admin.apiKeys.test.ts — API-key lifecycle tests
- Update/Write:
tests/fixtures/adminSeeds.ts — shared database seed helpers for admin tests
- Add documentation:
docs/testing.md — document admin test setup and fixture patterns
- Include clear code comments and types
- Validate security assumptions
Test and commit
- Run tests:
pnpm test (or pnpm test:coverage)
- Cover edge cases: concurrent pause toggle, delete non-existent DLQ entry, create API key with duplicate name, reindex while pause is active
- Include test output and security notes
Example commit message
test: add comprehensive integration coverage for admin endpoints
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
The 49-file vitest suite covers stream CRUD and middleware but has sparse coverage of the admin route surface in
src/routes/admin.ts. Routes for pause flags (GET/PUT /api/admin/pause), read-only mode (GET /api/admin/status/read-only), DLQ management, API-key lifecycle, and reindex operations lack dedicated integration tests. Full coverage of these routes is critical since they control operational state of the running service.Requirements and context
operator(authorised) andviewer/unauthenticated (forbidden) paths for every routesupertestwith an in-process Express app and a seeded test databaseSuggested execution
Fork the repo and create a branch
Implement changes
tests/routes/admin.pause.test.ts— pause and read-only mode teststests/routes/admin.dlq.test.ts— DLQ CRUD teststests/routes/admin.apiKeys.test.ts— API-key lifecycle teststests/fixtures/adminSeeds.ts— shared database seed helpers for admin testsdocs/testing.md— document admin test setup and fixture patternsTest and commit
pnpm test(orpnpm test:coverage)Example commit message
Guidelines