refactor(sync): split engine.test.ts into 4 domain files + shared utils (Phase 3.2) - #233
Merged
Merged
Conversation
h4yfans
force-pushed
the
debt/phase-3-u2-engine-test-split
branch
2 times, most recently
from
April 16, 2026 14:20
2ce7c69 to
8389e7b
Compare
…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
force-pushed
the
debt/phase-3-u2-engine-test-split
branch
from
April 16, 2026 14:28
8389e7b to
3e3c137
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sync/engine.test.ts(74 describe blocks, 85 tests) by domain.engine.test-utils.ts.engine.ts) is untouched — this is pure test-file reorganization.Per
.claude/plans/tech-debt-remediation.mdPhase 3.2.Split
engine.test-utils.tscreateMockNetwork,createMockWs,createMockDeps— shared by every split fileengine-pull.test.tsengine-push.test.tsbuildPushPayload, duplicate queue, replay detectionengine-crdt.test.tscrdtProviderCREATE/UPDATE note + task, snapshot-fails, mixed batchengine-retries.test.tsengine.test.ts(residual)Total: 85 tests — unchanged. Duplicate describe titles at L177 / L569 disambiguated in the split.
tsconfig.node.jsonadds**/*.test-utils.tsto the exclude list, mirroring the existing**/*.test.tspattern (vitest handles test-adjacent files with its own tsconfig).Why
Test plan
pnpm typecheck:nodepassessync/enginescope)