refactor: cleanup and test fixes - #13
Merged
Merged
Conversation
…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
…UserPromptFromParts
…d active-rules-state
…ildFilterContextOptions
… can handle errors
…eConditionChecks helper
… in SidebarContent
…ation, document exception contracts
…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.
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.
No description provided.