---
phase: 08-e2e-scenario-tests
plan: 01
type: execute
wave: 1
depends_on: []
files_modified: [src/test/e2e/happy-path.test.ts]
autonomous: true
---

<objective>
E2E tests proving happy path scenarios work: basic dispatch, dependency ordering, parallel execution, and merge flow.

Purpose: Validate the core dispatch/coordination flow works end-to-end with mocked agents and worktrees.
Output: Comprehensive test file covering all happy path scenarios.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/07-mock-agent-test-harness/07-01-SUMMARY.md
@.planning/phases/07-mock-agent-test-harness/07-02-SUMMARY.md

# Test infrastructure from Phase 7:
@src/test/harness.ts
@src/test/fixtures.ts
@src/test/harness.test.ts

# Types for understanding dispatch/coordination:
@src/dispatch/types.ts
@src/coordination/types.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Create E2E happy path test file</name>
  <files>src/test/e2e/happy-path.test.ts</files>
  <action>
Create comprehensive E2E tests for happy path scenarios using the test harness from Phase 7.

Test scenarios to implement:

1. **Single task flow** (using SIMPLE_FIXTURE Task A - no dependencies):
   - Seed fixture, pre-seed idle agent
   - Queue task, dispatch, wait for completion
   - Verify: task:queued, task:dispatched, agent:spawned, agent:stopped events
   - Verify: task status becomes 'completed' in database

2. **Sequential dependencies** (using SIMPLE_FIXTURE):
   - Task A has no deps, Task B and C depend on A
   - Queue all three tasks
   - First dispatchNext: only Task A dispatchable
   - Complete Task A
   - Next dispatchNext: Task B or C now dispatchable
   - Verify dependency ordering enforced

3. **Parallel dispatch** (using PARALLEL_FIXTURE):
   - 4 independent tasks across 2 plans
   - Pre-seed 2 idle agents
   - Queue all tasks
   - Two dispatchNext calls: both should succeed (parallel)
   - Verify both agents assigned different tasks

4. **Full merge flow**:
   - Dispatch task, wait for completion
   - Call coordinationManager.queueMerge(taskId)
   - Call coordinationManager.processMerges('main')
   - Verify merge:queued, merge:completed events
   - Verify worktreeManager.merge was called

Pattern from harness.test.ts:
```typescript
vi.useFakeTimers();
const seeded = await harness.seedFixture(FIXTURE);
// Pre-seed idle agent (required by DispatchManager)
await harness.agentManager.spawn({ name: 'pool-agent', taskId: 'placeholder', prompt: 'placeholder' });
await vi.runAllTimersAsync();
harness.clearEvents();
// Queue and dispatch...
```

Create `src/test/e2e/` directory if it doesn't exist. File should:
- Import from '../index.js' (TestHarness, fixtures)
- Use vi.useFakeTimers() for agent completion control
- Clean up with harness.cleanup() in afterEach
  </action>
  <verify>npm run test -- src/test/e2e/happy-path.test.ts passes all tests</verify>
  <done>All 4 happy path scenario tests pass, events verified, database state correct</done>
</task>

<task type="auto">
  <name>Task 2: Add complex dependency flow test</name>
  <files>src/test/e2e/happy-path.test.ts</files>
  <action>
Add test for complex dependency graph using COMPLEX_FIXTURE:

**COMPLEX_FIXTURE structure:**
- Phase 1: Plan 1 (Task 1A, 1B), Plan 2 (Task 2A depends on 1A)
- Phase 2: Plan 3 (Task 3A depends on 1B), Plan 4 (Task 4A depends on 2A and 3A)

**Test: Complex dependency ordering**
- Seed COMPLEX_FIXTURE
- Queue all 5 tasks
- Verify dispatch order respects dependencies:
  1. First dispatch: Task 1A or Task 1B (both have no deps)
  2. After 1A completes: Task 2A becomes dispatchable
  3. After 1B completes: Task 3A becomes dispatchable
  4. After both 2A and 3A complete: Task 4A becomes dispatchable
  5. Task 4A cannot dispatch until BOTH 2A and 3A complete

Use getNextDispatchable() to check which tasks are ready without actually dispatching.

Verify:
- Correct event sequence
- No task dispatched before its dependencies complete
- Final task (4A) only dispatches after all predecessors
  </action>
  <verify>npm run test -- src/test/e2e/happy-path.test.ts passes (including new test)</verify>
  <done>Complex dependency test passes, proves multi-dependency ordering works</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `npm run test -- src/test/e2e/happy-path.test.ts` passes all tests
- [ ] Single task flow test exists and passes
- [ ] Sequential dependencies test exists and passes
- [ ] Parallel dispatch test exists and passes
- [ ] Full merge flow test exists and passes
- [ ] Complex dependency test exists and passes
- [ ] No flaky tests (run twice to confirm)
</verification>

<success_criteria>

- All happy path E2E tests pass
- Tests use TestHarness from Phase 7
- Event verification confirms correct flow
- Database state verification confirms persistence
- Complex dependency ordering proven correct
</success_criteria>

<output>
After completion, create `.planning/phases/08-e2e-scenario-tests/08-01-SUMMARY.md`
</output>
