Skip to content

test(sync): add scenario tests for mgw:sync drift detection and auto-sync#266

Merged
snipcodeit merged 1 commit intomainfrom
issue/255-write-scenario-tests-for-mgw-sync-drift-
Mar 6, 2026
Merged

test(sync): add scenario tests for mgw:sync drift detection and auto-sync#266
snipcodeit merged 1 commit intomainfrom
issue/255-write-scenario-tests-for-mgw-sync-drift-

Conversation

@snipcodeit
Copy link
Owner

Summary

Closes #255

Milestone Context

Changes

Test Plan

  • npx vitest run test/sync-drift.test.js passes all 28 tests
  • Scenario 1 (no-drift-baseline): GH_EPOCH <= LOCAL_MTIME → no sync, no state mutation
  • Scenario 2 (stale-auto-sync): backdated mtime → sync fires, title updated, console.warn called
  • Scenario 3 (comment-delta-drift): delta > 0 detected, pipeline_stage NOT mutated
  • Scenario 4 (pr-merged-stage-pr-created): MERGED PR → pipeline_stage = done
  • Integration: sync report structure verified across all drift signals
  • No live GitHub API calls (mock-github.cjs intercepts all gh commands)

Notes

This PR depends on PR #265 for the full test infrastructure. The vitest config, mock-github.cjs, and base fixtures are duplicated here to keep this branch runnable independently. Once PR #265 merges, the duplicate infrastructure in this branch will be superseded by the merged versions.

@github-actions github-actions bot added the core Changes to core library label Mar 6, 2026
@snipcodeit
Copy link
Owner Author

Testing Procedures

Run the full sync-drift test suite:

```bash
npx vitest run test/sync-drift.test.js
```

Expected output:
```
✓ test/sync-drift.test.js (28 tests)

Test Files 1 passed (1)
Tests 28 passed (28)
```

Scenario-by-Scenario Checks

Scenario 1 (no-drift-baseline):

  • Verify 5 tests pass: GH epoch <= local mtime → no mutation, no warning

Scenario 2 (stale-auto-sync):

  • Verify 6 tests pass: backdated mtime triggers sync, title updated, console.warn called

Scenario 3 (comment-delta-drift):

  • Verify 6 tests pass: delta computed correctly, null stored count skips check, pipeline_stage NOT mutated

Scenario 4 (pr-merged-stage-pr-created):

  • Verify 7 tests pass: MERGED PR → done, archival to .mgw/completed/, open PR keeps pr-created

Integration:

  • Verify 4 tests pass: sync report aggregates all drift signals

…sync

Covers four scenarios from issue #255:
- No-drift baseline: GH updatedAt <= local mtime → no sync fires
- Stale auto-sync: GH updatedAt > local mtime → state refreshed, console.warn logged
- Comment delta drift: current count > stored count → flagged in report
- PR merged but stage=pr-created → pipeline_stage transitions to done

28 tests across 5 describe blocks (plus integration sync report verification).
Uses mock-github.cjs for gh CLI interception and fs.utimesSync for mtime control.

Also includes vitest infrastructure (vitest.config.js, test/setup.js,
test/loadFixture.js, lib/mock-github.cjs, test/fixtures/github/) carried
forward from PR #265 dependency.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@snipcodeit snipcodeit force-pushed the issue/255-write-scenario-tests-for-mgw-sync-drift- branch from 432796e to 92946cc Compare March 6, 2026 11:22
@snipcodeit snipcodeit merged commit ee15709 into main Mar 6, 2026
@snipcodeit snipcodeit deleted the issue/255-write-scenario-tests-for-mgw-sync-drift- branch March 6, 2026 11:22
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:sync drift detection and auto-sync

1 participant