Browse Source

docs(16): add test tasks to all plans

- 16-02: Add Task 4 for execution module tests
  - topologicalSort tests (cycle detection, branching)
  - buildProviderHeaders tests (all provider types)
  - nodeExecutors tests (error cases, mocked API calls)

- 16-03: Add Task 4 for slice tests
  - groupSlice tests (create, delete, lock, move)
  - persistenceSlice tests (save, load, auto-save)
  - Zustand testing pattern documented

All extracted functionality now has explicit test requirements.
handoff-20260429-1057
shrimbly 6 months ago
parent
commit
e8261ff0a7
  1. 37
      .planning/phases/16-store-modularization/16-02-PLAN.md
  2. 48
      .planning/phases/16-store-modularization/16-03-PLAN.md

37
.planning/phases/16-store-modularization/16-02-PLAN.md

@ -142,16 +142,50 @@ The goal is to reduce executeWorkflow from ~800 lines to ~200 lines of orchestra
<done>executeWorkflow refactored to ~200 lines, uses extracted modules, all tests pass</done> <done>executeWorkflow refactored to ~200 lines, uses extracted modules, all tests pass</done>
</task> </task>
<task type="auto">
<name>Task 4: Add unit tests for execution modules</name>
<files>src/store/execution/__tests__/utils.test.ts, src/store/execution/__tests__/nodeExecutors.test.ts</files>
<action>
Create comprehensive tests for the extracted execution modules:
1. Create src/store/execution/__tests__/utils.test.ts:
- Test topologicalSort with simple linear graph (A -> B -> C)
- Test topologicalSort with branching graph (A -> B, A -> C, B -> D, C -> D)
- Test topologicalSort throws on cycle detection (A -> B -> C -> A)
- Test topologicalSort with disconnected nodes
- Test buildProviderHeaders returns correct headers for each provider type
- Test buildProviderHeaders with missing API keys returns base headers only
- Test getSourceOutput for each node type returns correct type/value
2. Create src/store/execution/__tests__/nodeExecutors.test.ts:
- Test executeImageInput returns { continue: true } (no-op)
- Test executePrompt returns { continue: true } (no-op)
- Test executeAnnotation updates outputImage when sourceImage provided
- Test executeOutput updates node data with connected content
- Test executeNanaBanana handles missing text input (returns error)
- Test executeLlmGenerate handles missing text input (returns error)
- Mock fetch for API call tests
- Mock updateNodeData to verify state updates
Focus on testing the pure logic and error cases. API success paths can use mocked fetch responses.
</action>
<verify>npm test passes with new tests, coverage report shows execution modules covered</verify>
<done>Unit tests added for execution utilities and node executors, all tests pass</done>
</task>
</tasks> </tasks>
<verification> <verification>
Before declaring plan complete: Before declaring plan complete:
- [ ] `npm run build` succeeds without errors - [ ] `npm run build` succeeds without errors
- [ ] `npm test` passes all tests - [ ] `npm test` passes all tests (existing + new execution module tests)
- [ ] executeWorkflow function reduced from ~800 to ~200 lines - [ ] executeWorkflow function reduced from ~800 to ~200 lines
- [ ] Workflow execution still works (test with a simple prompt -> generate -> output flow) - [ ] Workflow execution still works (test with a simple prompt -> generate -> output flow)
- [ ] regenerateNode still works - [ ] regenerateNode still works
- [ ] Error handling preserved - [ ] Error handling preserved
- [ ] topologicalSort has test coverage including cycle detection
- [ ] buildProviderHeaders has test coverage for all provider types
- [ ] Node executors have test coverage for error cases
</verification> </verification>
<success_criteria> <success_criteria>
@ -160,6 +194,7 @@ Before declaring plan complete:
- All verification checks pass - All verification checks pass
- executeWorkflow is significantly shorter and more readable - executeWorkflow is significantly shorter and more readable
- Node execution logic is isolated and testable - Node execution logic is isolated and testable
- Execution modules have comprehensive test coverage
- No regression in workflow execution behavior - No regression in workflow execution behavior
</success_criteria> </success_criteria>

48
.planning/phases/16-store-modularization/16-03-PLAN.md

@ -184,17 +184,62 @@ Target: Main store file reduced from ~2800 to ~1500 lines.
<done>Store composed from slices, main file significantly reduced, all functionality preserved</done> <done>Store composed from slices, main file significantly reduced, all functionality preserved</done>
</task> </task>
<task type="auto">
<name>Task 4: Add unit tests for slices</name>
<files>src/store/slices/__tests__/groupSlice.test.ts, src/store/slices/__tests__/persistenceSlice.test.ts</files>
<action>
Create comprehensive tests for the extracted slices:
1. Create src/store/slices/__tests__/groupSlice.test.ts:
- Test createGroup calculates correct bounding box from node positions
- Test createGroup assigns unique colors to groups
- Test createGroup sets groupId on all provided nodes
- Test deleteGroup removes group and clears groupId from nodes
- Test addNodesToGroup updates nodes' groupId
- Test removeNodesFromGroup clears groupId
- Test toggleGroupLock toggles the locked state
- Test moveGroupNodes updates position of all nodes in group
- Use Zustand's testing pattern: create isolated store instance per test
2. Create src/store/slices/__tests__/persistenceSlice.test.ts:
- Test setWorkflowMetadata sets all metadata fields
- Test setWorkflowName marks as unsaved
- Test markAsUnsaved sets hasUnsavedChanges to true
- Test saveToFile calls fetch with correct payload (mock fetch)
- Test saveToFile updates lastSavedAt and hasUnsavedChanges on success
- Test loadWorkflow hydrates nodes/edges and resets execution state
- Test loadWorkflow migrates legacy nanoBanana nodes
- Test clearWorkflow resets all state
- Test initializeAutoSave/cleanupAutoSave manage interval
- Mock fetch, localStorage, and imageStorage utilities
Testing pattern for Zustand slices:
```typescript
const createTestStore = () => create<WorkflowStore>()((...args) => ({
...createGroupSlice(...args),
// minimal mock of other state needed
nodes: [],
edges: [],
}));
```
</action>
<verify>npm test passes with new slice tests, coverage for group and persistence slices</verify>
<done>Unit tests added for both slices, all tests pass, slice functionality verified</done>
</task>
</tasks> </tasks>
<verification> <verification>
Before declaring plan complete: Before declaring plan complete:
- [ ] `npm run build` succeeds without errors - [ ] `npm run build` succeeds without errors
- [ ] `npm test` passes all tests - [ ] `npm test` passes all tests (existing + new slice tests)
- [ ] workflowStore.ts reduced from ~2800 to ~1500 lines - [ ] workflowStore.ts reduced from ~2800 to ~1500 lines
- [ ] Group operations work (create, lock, delete) - [ ] Group operations work (create, lock, delete)
- [ ] Save/load workflow works - [ ] Save/load workflow works
- [ ] Auto-save works - [ ] Auto-save works
- [ ] All exports maintained for backward compatibility - [ ] All exports maintained for backward compatibility
- [ ] groupSlice has test coverage for all operations
- [ ] persistenceSlice has test coverage for save/load/auto-save
</verification> </verification>
<success_criteria> <success_criteria>
@ -203,6 +248,7 @@ Before declaring plan complete:
- All verification checks pass - All verification checks pass
- Store properly composed from slices - Store properly composed from slices
- Each slice is focused and cohesive - Each slice is focused and cohesive
- All slices have comprehensive test coverage
- No regression in any store functionality - No regression in any store functionality
- Phase 16 complete: Store Modularization achieved - Phase 16 complete: Store Modularization achieved
</success_criteria> </success_criteria>

Loading…
Cancel
Save