Repository navigation
test: make the unit and integration lanes reliable - #98
Merged
Merged
Conversation
Vitest's five second default was below what these lanes need. The unit lane builds real Git repositories in temporary folders and spawns around a dozen Git processes per case, and the integration lane renders the whole workbench in jsdom. On a loaded machine both lanes failed a changing set of tests, each one a timeout with a clean assertion trail. Carry the budget at config level, the way the Electron e2e lane already does, and drop the per-case overrides in the workbench tests so one number governs the lane. Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Node 24 and later define their own localStorage accessor on the global. Vitest only copies window properties across when the key is missing from the Node global, so window.localStorage resolved to Node's accessor, which returns undefined. The setup then installed undefined and six integration tests failed with a TypeError. Read the jsdom window instead. Its storage works on every Node version, and the new guard test proves the renderer receives a usable Storage. Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Contributor
Author
|
Verified the merged main commit
Sweep merged one green agent PR and closed zero dead PRs. Issue #97 is closed, no open issues remain, and roadmap parents #1-#5 are completed. Release-please #31 is the only open PR and was left for the release workflow. The scheduled automation remains enabled because the PR list is not clear. |
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.
The unit and integration lanes were failing for reasons that had nothing to do with the code under test. This slice makes both gates reliable: an explicit timeout budget for each project, and a jsdom storage read that survives Node's own localStorage accessor.
Closes #97
This slice has no parent issue. The five roadmap parents are closed, so the improvement was filed on its own as #97, following the fallback in the work loop.
What changed
vitest.unit.config.tsandvitest.integration.config.tscarry a timeout budget. The unit lane gets 120 seconds, the same budget the Electron e2e lane already uses, because its cases build real Git repositories in temporary folders and spawn around a dozen Git processes each. The integration lane gets 60 seconds. The three per-case overrides intests/unit/workbench.test.tsare gone, so one number governs the lane.tests/integration/setup.tsnow reads storage from the jsdom window instead of fromwindow.localStorage. Node 24 and later define their own localStorage accessor on the global, and Vitest only copies window properties across when the key is missing from the Node global, so on those versionswindow.localStorageresolved to Node's accessor, which returns undefined. The setup then installed undefined and six integration tests failed withTypeError: Cannot read properties of undefined (reading 'clear'). The jsdom window is still reachable asglobalThis.jsdom.windowand its storage works on every Node version.tests/integration/storage.test.tsis new. It asserts the renderer receives a usable Storage, and it fails on Node 26 without the setup fix.What the failure looked like before
On a loaded machine the unit lane failed between 3 and 9 tests and the integration lane failed around 10, every one of them a timeout with a clean assertion trail, and the failing set changed from run to run.
How it was verified
Every gate ran on this branch with the repo toolchain from
mise(Node 22.23.0, Bun 1.3.14).bun install --frozen-lockfilebun run lintoxlint src testsbun run typecheckbun run test:unitbun run test:integrationmise run buildThe unit and integration lanes were also run against Node 26.13.1, the Node that exposed the storage problem, and both lanes passed there too.
Proof
This slice changes test infrastructure only. Nothing in
src/moves, so there is no screen to capture and no screenshot is offered.Terminal transcript from
mise run build, which runs lint, typecheck, both test lanes and the bundle:The same two lanes run directly against Node 26.13.1:
The new guard test, listed by name:
The same test against the old setup file, which shows the guard earns its place:
For the reviewer
No user-facing behaviour changes.
src/is untouched, so the e2e lane has no new behaviour to reach and the hosted macOS runner covers the Electron suites as usual.The timeout budget is deliberately generous because the unit lane does real Git work. A reviewer who prefers a tighter number should look at
tests/unit/workbench.test.tsfirst, since that lane spawns around a dozen Git processes per case and is the reason the budget is 120 seconds rather than 10.Two things worth knowing. The unit lane already carried per-case budgets of 15 and 30 seconds, so the change here is mostly about the cases that were left on the five second default, and moving the budget to config level so one number governs the lane. And the storage fix only changes behaviour on Node 24 and later, which is why hosted CI on Node 22.23.0 was already green and the problem was invisible until a local run on a newer Node.
Follow-up worth considering: the unit lane could stop spawning a dozen Git processes per case by folding the workspace inspection into fewer Git calls. That would be a change to
src/main/workbench.tsrather than to the tests.