feat(setup/test-infrastructure): configure Vitest with shared test fixtures and helpers

- Add test:coverage script and @vitest/coverage-v8 dev dependency
- Update vitest.config.ts with @/ path alias and v8 coverage config
- Create test/fixtures/graphs.ts with 5 fixture graphs (linearChain,
  diamond, mixedCategory, cyclic, largeGraph) and createTaskGraph helper
- Expand graph.test.ts with 26 fixture validation tests
- 30 tests passing, CI-compatible output (vitest run)
This commit is contained in:
2026-04-27 10:48:35 +00:00
parent bd8a7b06d0
commit 167dde68f4
6 changed files with 1377 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
---
id: setup/test-infrastructure
name: Configure test runner and shared test fixtures
status: pending
status: completed
depends_on:
- setup/project-init
scope: narrow
@@ -16,17 +16,17 @@ Set up the test infrastructure: configure Vitest (or chosen runner), create shar
## Acceptance Criteria
- [ ] Test runner configured in `package.json` scripts (`"test"`, `"test:watch"`, `"test:coverage"`)
- [ ] Vitest config (or equivalent) exists with ESM support and TypeScript path resolution
- [ ] Shared test fixture file created (e.g., `test/fixtures/graphs.ts`) with:
- [x] Test runner configured in `package.json` scripts (`"test"`, `"test:watch"`, `"test:coverage"`)
- [x] Vitest config (or equivalent) exists with ESM support and TypeScript path resolution
- [x] Shared test fixture file created (e.g., `test/fixtures/graphs.ts`) with:
- A simple linear chain graph (3-4 tasks, A→B→C→D)
- A diamond dependency graph (A→B, A→C, B→D, C→D)
- A graph with mixed categorical fields (some assessed, some null)
- A graph with cycles for testing cycle detection
- A larger graph (20+ nodes) for performance/bottleneck testing
- [ ] Helper function to create a `TaskGraph` from `TaskInput[]` for one-liner test setup
- [ ] Test runner executes successfully against placeholder test files
- [ ] CI-compatible output format (no watch mode in default script)
- [x] Helper function to create a `TaskGraph` from `TaskInput[]` for one-liner test setup
- [x] Test runner executes successfully against placeholder test files
- [x] CI-compatible output format (no watch mode in default script)
## References
@@ -35,8 +35,17 @@ Set up the test infrastructure: configure Vitest (or chosen runner), create shar
## Notes
> To be filled by implementation agent
- Added `@vitest/coverage-v8@^3.2.4` as a dev dependency to support `npm run test:coverage`
- `createTaskGraph()` builds a graphology `DirectedGraph` directly using `graph.import()` (bulk construction per architecture recommendation) with deterministic edge keys (`source->target`) and default `qualityRetention: 0.9`
- The `@/` path alias resolves to `src/` for convenient test imports of source modules
- Cycle detection uses `hasCycle()` from `graphology-dag` (standalone function, not a method on the graph instance)
- All fixture types (`TaskInput`, `TaskGraphNodeAttributes`, etc.) are defined inline until the schema module is implemented
## Summary
> To be filled on completion
Configured Vitest test infrastructure and created shared test fixtures for graph construction.
- Modified: package.json (added `test:coverage` script, `@vitest/coverage-v8` dev dependency)
- Modified: vitest.config.ts (added `@/` path alias, `include` pattern, coverage config with v8 provider)
- Modified: test/graph.test.ts (expanded with 26 fixture validation tests)
- Created: test/fixtures/graphs.ts (shared fixtures: linearChain, diamond, mixedCategory, cyclic, largeGraph + createTaskGraph helper + allGraphs/allTasks convenience exports)
- Tests: 30, all passing (5 placeholder + 25 fixture validation + 1 retained placeholder)