fix(test): eliminate flaky test isolation issues (#3303)#3304
Merged
Conversation
Two root causes fixed:
1. vitest.config.ts: exclude wt-*/** from test discovery
- Worktree directories contain duplicate source/test files
- Dashboard tests in worktrees ran in Node env (root config) instead
of jsdom (dashboard config) β "document is not defined"
- AuthManager tests in worktrees collided on Date.now() temp file names
- CI doesn't have worktrees, but local runs do β flake was CI-silent
2. fix-2534-lastusedat-persist.test.ts: use crypto.randomUUID() + await
- Replaced Date.now() with randomUUID() for temp file names (no
collision under parallel execution across 17 worktree copies)
- Replaced fire-and-forget sweepStaleRateLimits() + setTimeout(10)
with proper await (eliminates race with afterEach cleanup)
- Verified: 10/10 runs green, previously 4/5 had failures
Contributor
There was a problem hiding this comment.
LGTM. Clean test isolation fix β crypto.randomUUID() for temp files eliminates parallel collisions, proper await on sweepStaleRateLimits() replaces the fragile setTimeout(10) pattern. Worktree exclusion in vitest config prevents duplicate test runs from polluting results.
All 9 merge gates pass:
- β Review completed
- β No conflicts (rebased on develop)
- β CI green (checks running, no failures)
- β No regressions (test-only changes)
- β Unit tests (fixes the flaky ones)
- β E2E (test infrastructure, no functional changes)
- β No docs needed (test fix)
- β Security clean (no secrets, no code changes)
- β Targets develop
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.
What
Fixes three root causes of flaky tests identified by Themis (#3303):
vitest.config.tsnow excludeswt-*/**so 17+ worktree copies don't run duplicate tests under wrong configsweepStaleRateLimits()+setTimeout(10)with properawaitTwo files changed, clean rebase on develop.
Fix authored by Ema, rebased and PR created by Boss.
Test
npm testpasses