Skip to content

test: checkpoint read/write and resume detection tests#262

Merged
snipcodeit merged 1 commit intomainfrom
issue/251-write-tests-for-checkpoint-read-write-an
Mar 6, 2026
Merged

test: checkpoint read/write and resume detection tests#262
snipcodeit merged 1 commit intomainfrom
issue/251-write-tests-for-checkpoint-read-write-an

Conversation

@snipcodeit
Copy link
Owner

Summary

Closes #251

Milestone Context

Changes

  • test/checkpoint.test.js — 36 vitest ESM tests, 5 groups
  • test/setup.js — global vitest setup with conditional mock loading
  • vitest.config.js — vitest config (node env, .test.js include, .test.cjs exclude)
  • package.json — vitest ^2.1.9 devDependency; test/test:node/test:watch scripts

Test Coverage Detail

Group Tests What is verified
updateCheckpoint() merge semantics 9 null init via initCheckpoint, pipeline_step overwrite, step_progress shallow merge (existing keys preserved), artifacts append-only, step_history append-only, resume full-replace, last_agent_output overwrite, updated_at always updated, throws for missing file
detectCheckpoint() null-return semantics 7 no state file → null, null checkpoint → null, triage-only → null, plan/execute/verify/pr → non-null with correct fields
resumeFromCheckpoint() action→stage mapping 11 null for triage-only, all 6 documented actions (run-plan-checker→planning, spawn-executor→executing, continue-execution→executing, spawn-verifier→verifying, create-pr→pr-pending, begin-execution→planning), null→unknown/planning, unrecognized→planning, completedSteps from step_history, empty completedSteps, checkpoint nested in result
clearCheckpoint() reset 5 cleared:true when non-null, cleared:false when already null, other fields preserved, no .tmp leftover (atomic), throws for missing file
Forward-compat round-trip 4 unknown top-level checkpoint fields preserved on updateCheckpoint, unknown step_progress keys preserved on shallow merge, detectCheckpoint returns unknown step_progress keys intact

Test Plan

  • npx vitest run test/checkpoint.test.js — 36/36 pass, 0 failures
  • No modifications to lib/state.cjs
  • No modifications to existing test/*.test.cjs files
  • package-lock.json updated for vitest dependency

Adds test/checkpoint.test.js (36 tests, 5 groups) covering all 4 checkpoint
functions in lib/state.cjs via vitest ESM format:

- updateCheckpoint(): null init, step_progress shallow merge, artifacts/
  step_history append-only, resume full-replace, updated_at always set
- detectCheckpoint(): null for missing/null/triage-only checkpoints; non-null
  for plan/execute/verify/pr steps
- resumeFromCheckpoint(): all 6 documented action→resumeStage mappings;
  null/unknown action defaults to 'planning'; completedSteps from step_history
- clearCheckpoint(): reset to null, cleared:true/false, atomic (no .tmp),
  preserves other state fields
- Forward-compat: unknown top-level and step_progress fields preserved on
  read-modify-write round-trip

Also adds vitest.config.js, test/setup.js, and vitest ^2.1.9 devDependency
(same pattern as PR #250 branch) to enable the vitest test runner.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write tests for checkpoint read/write and resume detection

1 participant