Skip to content

refactor: cleanup and test fixes - #13

Merged
frap129 merged 31 commits into
devfrom
desloppify/code-health
May 3, 2026
Merged

frap129 merged 31 commits into
devfrom
desloppify/code-health

Conversation

@frap129

@frap129 frap129 commented May 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

frap129 added 30 commits May 3, 2026 13:33
…promises

The "serializes concurrent writes" test was flaky in CI because it
relied on a 100ms timeout to drain the write queue. On slow CI
runners, 3 sequential atomic writes (mkdir + writeFile + rename)
could exceed 100ms, causing the test to read intermediate state.

Changes:
- writeActiveRulesState now returns Promise<void> so tests can await
the exact completion of chained writes instead of polling + sleeping
- _resetWriteQueues helper added and called in afterEach to keep
the module-level Map clean between tests
- All fire-and-forget patterns in active-rules-state.test.ts replaced
with deterministic awaits; waitForFile helper removed
…ding dependency injection

Bun's vi.mock() factory functions were poisoning the module cache globally,
causing cascading failures across consecutive test runs:
- vi.mock('node:fs/promises') broke readAndFormatRules in integration tests
- vi.mock('node:child_process') caused hangs and timeouts
- toHaveProperty('a.b.c') triggered Bun's dotted-key handling bug

Solution:
- git-branch.ts: add optional execFn param for DI
- project-fingerprint.ts: add ProjectTagFs interface + nodeFs adapter
- git-branch.test.ts: pass inline vi.fn() mocks directly to getGitBranch
- project-fingerprint.test.ts: pass inline mock fs objects directly
- index.runtime.test.ts: replace toHaveProperty dotted-keys with bracket notation

No global module mocks = no inter-run cache pollution.
330/330 tests pass on bun test --run, stable across consecutive runs.
@frap129
frap129 merged commit 8966c7c into dev May 3, 2026
1 check passed
@frap129
frap129 deleted the desloppify/code-health branch May 3, 2026 17:39
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