Plan: E2E Coverage for Pre-PR Quality Gate (#231)#
Summary#
Add E2E tests verifying the pre-PR quality gate lifecycle: blocking at the deliver phase, bypassing via skip-quality-gate directive, normal pass-through, and edge cases for malformed/unauthorized directive usage. Tests exercise the PhaseRouterService → DirectiveService → TaskStateService integration path with an in-memory SQLite database.
Files#
| File | Action | Description |
|---|---|---|
test/quality-gate.e2e-spec.ts | create | E2E test suite for quality gate scenarios |
Steps#
-
Create
test/quality-gate.e2e-spec.ts— set up a NestJS testing module with realTaskStateService(in-memory SQLite), realPhaseRouterService, realDirectiveService, and mockedClaudeInvocationService,WorktreeService,ArtefactsService,PhaseHooksService,EventService,GitHubService. Follow patterns fromtest/task-state.e2e-spec.tsandtest/integration/webhook-to-state.integration.spec.ts. -
Scenario: gate blocks deliver phase — create a task with
directive=auto, advance todeliverphase via a non-directive event. Asserttask.status === 'gated',task.gatePhase === 'deliver', andClaudeInvocationService.invoke()was NOT called. -
Scenario:
skip-quality-gatebypasses gate — create a task withdirective=auto, applyskip-quality-gateviaDirectiveService.applyDirective(). Asserttask.qualityGateOverride === true. Then trigger thedeliverphase with a directive event (approve). AssertClaudeInvocationService.invoke()WAS called and env includesQUALITY_GATE_OVERRIDE=1. Assert override is consumed (task.qualityGateOverride === falseafter execution). -
Scenario: qualifying task passes normally — create a task with
directive=quick(no gates). Triggerdeliverphase. AssertClaudeInvocationService.invoke()was called and task was NOT gated. -
Scenario: malformed
skip-quality-gateedge cases — test that wrong casing or missing value in directive does not setqualityGateOverride. Assert the gate runs normally (blocks on its own merits forauto/carefuldirectives). -
Add
#231traceability — include(#231)in the top-leveldescribeblock and individual test descriptions for grep-ability.
Verification#
npm run test -- --testPathPattern=quality-gate.e2e-specpasses all scenarios.npm run lintpasses with zero warnings.grep -r '#231' test/quality-gate.e2e-spec.tsreturns matches confirming traceability.
Risks#
- The
PhaseRouterService.route()method has multiple dependencies — the test module must mock all of them correctly or tests will fail on initialization. Mitigation: follow existing integration test patterns that already mock these services.