|
|
@ -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> |
|
|
|