Plan: Integration Test — BLOCKED:PERSISTENT → gated → refine eligibility#
Summary#
Add an integration test that proves the end-to-end handoff between #243 (BLOCKED:PERSISTENT sets status=gated) and #237 (refine pre-validation rejects non-gated tasks). The test wires InternalAdapterService and DirectiveService against an in-memory SQLite database to verify the combined state-machine path without mocking the DB layer.
Files#
| Path | Action | Description |
|---|---|---|
test/integration/blocked-persistent-to-refine.integration.spec.ts | create | Integration spec covering the full BLOCKED:PERSISTENT → gated → refine flow |
Steps#
- Create integration test file at
test/integration/blocked-persistent-to-refine.integration.spec.ts. Wire a NestJS testing module with real in-memory SQLite (TaskEntity, EventEntity, JobEntity), realInternalAdapterService, realDirectiveService, realTaskStateService, and mocked external dependencies (GitHub client, ConfigService, PhaseHooksService, ClaudeInvocationService, JobQueueService). - Test: BLOCKED:PERSISTENT transitions task to status=gated. Create a task via
TaskStateService.createTask(), callInternalAdapterService.handleSignal()with'BLOCKED:PERSISTENT', asserttask.status === 'gated',gatePhaseandgateReasonare set. - Test: gated task is accepted by refine pre-validation. Using the gated task from step 2's setup, call
DirectiveService.applyDirective()with directive'refine'. Assert gate is cleared andInternalAdapterService.enqueuePhase()is called with'refine'. - Test: non-gated task is rejected by refine pre-validation. Create a fresh task (status=
active), callDirectiveService.applyDirective()with directive'refine'. Assert rejection comment is posted and no phase is enqueued. - Add traceability references. Include
describeblock description and inline comments referencing #243 and #237 per acceptance criteria.
Verification#
npm run test -- --testPathPattern=blocked-persistent-to-refinepasses all three test cases.npm run lintreports zero warnings.
Risks#
DirectiveService.applyDirective()has many dependencies; mock surface may be large. Mitigate by mocking only external I/O (GitHub API, job queue) and keeping DB real.