Skip to content

refactor(sync): split engine.test.ts into 4 domain files + shared utils (Phase 3.2) - #233

Merged
h4yfans merged 1 commit into
mainfrom
debt/phase-3-u2-engine-test-split
Apr 16, 2026
Merged

refactor(sync): split engine.test.ts into 4 domain files + shared utils (Phase 3.2)#233
h4yfans merged 1 commit into
mainfrom
debt/phase-3-u2-engine-test-split

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Splits the 3,136-line sync/engine.test.ts (74 describe blocks, 85 tests) by domain.
  • Lifts shared scaffolding into engine.test-utils.ts.
  • Source code (engine.ts) is untouched — this is pure test-file reorganization.

Per .claude/plans/tech-debt-remediation.md Phase 3.2.

Split

File LOC Tests Scope
engine.test-utils.ts 73 createMockNetwork, createMockWs, createMockDeps — shared by every split file
engine-pull.test.ts 528 9 Pull, decrypt, unknown-signer cases
engine-push.test.ts 983 22 Push, clock skew, buildPushPayload, duplicate queue, replay detection
engine-crdt.test.ts 330 6 crdtProvider CREATE/UPDATE note + task, snapshot-fails, mixed batch
engine-retries.test.ts 542 21 Online/offline transitions, device revoked, extended-offline container
engine.test.ts (residual) 599 27 Lifecycle, fullSync, manifest, remote-wipe T245k

Total: 85 tests — unchanged. Duplicate describe titles at L177 / L569 disambiguated in the split.

tsconfig.node.json adds **/*.test-utils.ts to the exclude list, mirroring the existing **/*.test.ts pattern (vitest handles test-adjacent files with its own tsconfig).

Why

  • Single file had 74 describe blocks. Navigation was painful.
  • Splitting by domain lets engineers open only the file they're working in; CPU/IO overhead drops because vitest can parallelize across the 5 files.

Test plan

  • pnpm typecheck:node passes
  • Full vitest run: no in-scope engine-test failures (the handful of failures are pre-existing renderer UI timeouts under 3-way CPU contention — not in sync/engine scope)
  • All 85 engine tests accounted for across 5 files

@h4yfans
h4yfans force-pushed the debt/phase-3-u2-engine-test-split branch 2 times, most recently from 2ce7c69 to 8389e7b Compare April 16, 2026 14:20
…ts/utils/engine-mocks.ts

Per .claude/plans/tech-debt-remediation.md Phase 3.2. The 3,136-line
engine.test.ts (74 describe blocks, 85 tests) is split by domain. Shared
scaffolding moves into tests/utils/engine-mocks.ts (follows existing
convention alongside test-db.ts, test-vault.ts, etc.). engine.ts source
is untouched.

- tests/utils/engine-mocks.ts (73 LOC): createMockNetwork, createMockWs,
  createMockDeps, setupTestDb — shared by every split file
- engine-pull.test.ts (528 LOC): pull + decrypt + unknown signer (9 tests)
- engine-push.test.ts (983 LOC): push + clock skew + buildPushPayload +
  duplicate queue + replay detection (22 tests; disambiguated duplicate titles)
- engine-crdt.test.ts (330 LOC): crdtProvider CREATE/UPDATE note + task,
  snapshot-fails, mixed batch (6 tests)
- engine-retries.test.ts (542 LOC): online/offline transitions, device
  revoked, extended offline container (21 tests)
- engine.test.ts (residual 599 LOC): lifecycle, fullSync, manifest,
  remote-wipe T245k (27 tests)

Total 85 tests preserved. Runtime behavior unchanged — this is pure
test-file reorganization. Location in tests/utils/ (rather than next to
engine.ts) keeps the helper in the tests/ tsconfig project so external
imports (e.g. @tests/utils/test-db for TestDatabaseResult) resolve
without needing tsconfig exclude workarounds.
@h4yfans
h4yfans force-pushed the debt/phase-3-u2-engine-test-split branch from 8389e7b to 3e3c137 Compare April 16, 2026 14:28
@h4yfans
h4yfans merged commit a68d4f7 into main Apr 16, 2026
2 checks passed
h4yfans added a commit that referenced this pull request May 6, 2026
…ts/utils/engine-mocks.ts (#233)

Per .claude/plans/tech-debt-remediation.md Phase 3.2. The 3,136-line
engine.test.ts (74 describe blocks, 85 tests) is split by domain. Shared
scaffolding moves into tests/utils/engine-mocks.ts (follows existing
convention alongside test-db.ts, test-vault.ts, etc.). engine.ts source
is untouched.

- tests/utils/engine-mocks.ts (73 LOC): createMockNetwork, createMockWs,
  createMockDeps, setupTestDb — shared by every split file
- engine-pull.test.ts (528 LOC): pull + decrypt + unknown signer (9 tests)
- engine-push.test.ts (983 LOC): push + clock skew + buildPushPayload +
  duplicate queue + replay detection (22 tests; disambiguated duplicate titles)
- engine-crdt.test.ts (330 LOC): crdtProvider CREATE/UPDATE note + task,
  snapshot-fails, mixed batch (6 tests)
- engine-retries.test.ts (542 LOC): online/offline transitions, device
  revoked, extended offline container (21 tests)
- engine.test.ts (residual 599 LOC): lifecycle, fullSync, manifest,
  remote-wipe T245k (27 tests)

Total 85 tests preserved. Runtime behavior unchanged — this is pure
test-file reorganization. Location in tests/utils/ (rather than next to
engine.ts) keeps the helper in the tests/ tsconfig project so external
imports (e.g. @tests/utils/test-db for TestDatabaseResult) resolve
without needing tsconfig exclude workarounds.
@h4yfans
h4yfans deleted the debt/phase-3-u2-engine-test-split branch May 6, 2026 16:36
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.

1 participant