Skip to content

Refactor tests#30

Merged
cephalization merged 10 commits intomainfrom
refactor-tests
Jan 30, 2026
Merged

Refactor tests#30
cephalization merged 10 commits intomainfrom
refactor-tests

Conversation

@cephalization
Copy link
Owner

No description provided.

Base automatically changed from dex to main January 30, 2026 02:50
@cephalization cephalization marked this pull request as ready for review January 30, 2026 02:51
- Added DexClient interface to dex.ts for dependency injection
- Created defaultDexClient that wraps real dex CLI functions
- Updated LoopOptions to accept optional dexClient parameter
- Modified runLoop to use injected dexClient (defaults to real CLI)
- Updated loop.test.ts mock.module to include defaultDexClient
- All tests now passing (189 pass, 0 fail)
Addressed easy-to-fix flakiness patterns identified in audit:

1. migration.test.ts:
   - FIXED: Hardcoded TEST_DIR → now uses mkdtemp for unique temp directories
   - FIXED: Test isolation → each test gets isolated directory, no collision risk
   - Updated audit comments to reflect fixes

2. prune.test.ts:
   - FIXED: Hardcoded TEST_DIR → now uses mkdtempSync for unique temp directories
   - FIXED: Test isolation → each test gets isolated directory, no collision risk
   - Updated audit comments to reflect fixes

3. server.test.ts:
   - FIXED: WebSocket cleanup → added connection tracking and explicit cleanup
   - Added 100ms drain period in afterEach to ensure connections close properly
   - Updated audit comments to reflect fixes

All tests still passing (189 pass, 0 fail).

Remaining documented risks (process.chdir, timing dependencies) are acceptable
and documented for future consideration.
Fixes TypeScript error TS2532 where readyTasks[0] could be undefined.
Added explicit check for readyTasks[0] existence alongside length check.
@cephalization cephalization merged commit ebe1846 into main Jan 30, 2026
1 check passed
@cephalization cephalization deleted the refactor-tests branch January 30, 2026 03:22
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