Plan: Integration Test — BLOCKED:PERSISTENT → Gated → Refine Eligibility#
Summary#
Add an integration test that validates the end-to-end state-machine handoff: BLOCKED:PERSISTENT transitions a task to status=gated, a gated task is accepted by DirectiveService.applyDirective('refine'), a non-gated task is rejected, and re-firing BLOCKED:PERSISTENT on an already-gated task is idempotent. This bridges the gap between the isolated unit tests in internal-adapter.service.spec.ts and directive.service.spec.ts.
Files#
| File | Action | Description |
|---|---|---|
test/integration/blocked-persistent-gated-refine.integration.spec.ts | create | New integration test covering the BLOCKED:PERSISTENT → gated → refine flow |
test/integration/integration-test.utils.ts | inspect | Reuse existing test module factory pattern |
src/internal-adapter/internal-adapter.service.ts | inspect | handleSignal() and handlePersistentBlock() under test |
src/directive/directive.service.ts | inspect | applyDirective('refine') pre-validation under test |
src/database/entities/task.entity.ts | inspect | TaskEntity schema for status/gate columns |
Steps#
-
S1: Create integration test file — Create
test/integration/blocked-persistent-gated-refine.integration.spec.tsusing the same in-memory SQLite + realTypeOrmModulepattern frominternal-adapter.service.spec.ts. Wire bothInternalAdapterServiceandDirectiveServicewith real TaskEntity repositories but mock external I/O (GitHub API calls, job queue, dispatch). -
S2: Implement test cases — Write four test cases: (a)
BLOCKED:PERSISTENTsetsstatus=gated,gatePhase, andgateReason; (b)applyDirective('refine')on that gated task succeeds — callsclearGateand enqueues the refine phase; (c)applyDirective('refine')on an active (non-gated) task is rejected with a comment; (d) re-firingBLOCKED:PERSISTENTon an already-gated task remainsstatus=gatedwith no duplicate side effects. Each test includes inline comments referencing #243 and #237. -
S3: Verify tests pass — Run
npm run test -- --testPathPattern=blocked-persistent-gated-refineandnpm run lintto confirm green.
Verification#
npm run test -- --testPathPattern=blocked-persistent-gated-refinepasses with 4 test casesnpm run lintreports zero warnings- Each test case includes traceability comments linking to #243 and #237
Risks#
DirectiveServicehas multiple dependencies (GitHub API, TaskStateService, etc.) that need careful mocking — mitigation: use the same mock patterns already established indirective.service.spec.ts, keeping real DB access for TaskEntity only.