test(usage-aggregator): fix timeout flake by building against an empty HOME#503
Merged
Conversation
…meout flake
buildMenubarPayloadForRange('today') parsed the developer's real on-disk
session data under a fixed 5s timeout, so on a heavy-usage day the test
timed out locally (it stayed green on CI, which has no real data). Point
HOME and the config dirs at an empty temp dir so the payload is built from
an empty dataset: deterministic and fast (~0.3s) while still asserting the
payload shape and the optimize:false short-circuit.
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.
Problem
tests/usage-aggregator.test.tscallsbuildMenubarPayloadForRange(getDateRange('today'), ...), which parses the developer's real on-disk session data for today against a fixed 5s timeout. On a heavy-usage day this exceeds the timeout and the test fails locally. It stays green on CI because CI has no real session data.Fix
Point
HOME,CLAUDE_CONFIG_DIR,XDG_CONFIG_HOME, andCODEBURN_CACHE_DIRat an empty temp dir for this test so the payload is built from an empty dataset. The test still asserts the payload shape and theoptimize:falseshort-circuit, but now runs deterministically in ~0.3s (was timing out at 5s). Env is saved/restored in beforeAll/afterAll; vitest's default forks pool isolates the file in its own process, and the daily-cache test already uses the same env-override pattern.Verification
usage-aggregatortest now passes; no other test regressed (the env override is confined to this file).