Skip to content

test(project): add scenario tests for all six mgw:project STATE_CLASS paths#264

Merged
snipcodeit merged 1 commit intomainfrom
issue/253-write-scenario-tests-for-mgw-project-sta
Mar 6, 2026
Merged

test(project): add scenario tests for all six mgw:project STATE_CLASS paths#264
snipcodeit merged 1 commit intomainfrom
issue/253-write-scenario-tests-for-mgw-project-sta

Conversation

@snipcodeit
Copy link
Owner

Summary

Closes #253

Milestone Context

Changes

lib/state.cjs — add detectProjectState()

  • New exported function with signature detectProjectState({ repoRoot?, githubMilestoneCount? })
  • Reads P/R/S/M signals from filesystem; G signal passed as parameter (caller owns gh api)
  • Classification: Extend → Aligned/Diverged → GSD-Mid-Exec/GSD-Only/Fresh
  • Consistency check uses count proximity (|local - G| <= 1) instead of live name-overlap API call

test/project-state-detection.test.js (new)

  • 19 tests across 7 describe blocks
  • Isolation: fs.mkdtempSync() tmp dirs, file seeding helpers, afterAll cleanup
  • Fixture-based project.json loading via seedProjectJson()

test/fixtures/project-state/ (new)

  • aligned.json — 2 milestones, current_milestone=1 (not all done)
  • diverged.json — 5 milestones, current_milestone=1 (count diff > 1 vs G=2)
  • extend.json — 2 milestones, current_milestone=3 (all done)

Vitest infrastructure (from PR chain #247#252, included since not yet on main)

  • vitest.config.js, lib/mock-github.cjs, lib/mock-gsd-agent.cjs
  • test/loadFixture.js, test/setup.js
  • test/checkpoint.test.js, test/pipeline-transitions.test.js
  • test/fixtures/github/ (16 fixtures), test/fixtures/agents/ (5 fixtures)
  • Updated package.json: test script → vitest run, added vitest ^2.1.9 devDep

Test Plan

  • npx vitest run test/project-state-detection.test.js → 19 tests pass
  • npx vitest run → 83 total tests pass (19 + 28 pipeline-transitions + 36 checkpoint)
  • Fresh: empty tmpDir, all signals false → stateClass === 'Fresh'
  • GSD-Only: only .planning/PROJECT.md seeded, G=0 → stateClass === 'GSD-Only'
  • GSD-Mid-Exec: PROJECT.md + ROADMAP.md + STATE.md, G=0 → stateClass === 'GSD-Mid-Exec'
  • Aligned: 2-milestone project.json, G=2 → stateClass === 'Aligned'
  • Diverged: 5-milestone project.json, G=2 (diff=3 > 1) → stateClass === 'Diverged'
  • Extend: project.json current_milestone=3 > milestones.length=2, G=2 → stateClass === 'Extend'
  • detectProjectState exported from lib/state.cjs module.exports

🤖 Generated with Claude Code

… paths (closes #253)

- Extract detectProjectState() into lib/state.cjs with five-signal classification
  (P/R/S/M/G signals from workflows/detect-state.md) and export it
- Write test/project-state-detection.test.js with 19 vitest tests:
  one describe block per STATE_CLASS (Fresh, GSD-Only, GSD-Mid-Exec,
  Aligned, Diverged, Extend) plus return-shape contract tests
- Add test/fixtures/project-state/{aligned,diverged,extend}.json fixtures
  for pre-seeded .mgw/project.json scenarios
- Include vitest infrastructure from PR chain (#247-#252): vitest.config.js,
  mock-github.cjs, mock-gsd-agent.cjs, loadFixture.js, setup.js,
  checkpoint.test.js, pipeline-transitions.test.js, all fixture files
- Update package.json scripts (test→vitest run, test:node→node --test) and
  add vitest ^2.1.9 to devDependencies

All 83 tests pass (19 new + 28 pipeline-transitions + 36 checkpoint).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write scenario tests for mgw:project state detection all six STATE_CLASS paths

1 participant