test: coverage gate + unit tests for main-process stores - #30
Merged
Conversation
Adds @vitest/coverage-v8 and a v8 coverage report (text/html/lcov) gating the suite via thresholds that sit just below the measured baseline and only move up. portalIntegration.ts is excluded: it is a DW_PORTALCLI / DW_PORTALLINK integration harness driving a real socket + PTY + browser, not unit-testable code. Baseline caribeedu#1 (2026-08-13): stmts 28.5 / branches 24.4 / funcs 25.3 / lines 29.1
Characterization tests (no production changes) covering shimDir, DraftStore, SettingsStore, seedFirstRun, NoteStore and PortalManager: 87 new tests. Extends the electron mock with FakeWebContents / WebContentsView fakes (backwards-compatible) so PortalManager's browser lifecycle is testable. Suite: 32 files, 209 tests passing.
The thresholds were configured but never enforced: the CI ran plain vitest without --coverage. Adds a test:coverage script and switches the check job to it, so a PR that drops coverage below the ratcheting thresholds now fails.
caribeedu
self-requested a review
August 13, 2026 19:00
- broker.ts to 100% lines: extractJsonObjects edge cases, ask timeouts clamp, wire/note/portal verbs, authorization denials, ask --contract validate-until-valid loop (budget/rejection/fallback), team asks, walker verbs (82 tests total) - workspaceStore: bootstrap, list/divider/reorder edge cases (46 tests) - presets: presetCommand + defaultShell (6 tests) - renderer: terminalService degradation ladder (tiers, webgl budget, overflow/resync) + Hud, DevBar, GroupNode, HistoryPanel, PreviewNode, CanvasMenu, Sidebar (63 tests) Suite: 41 files, 388 tests passing. No production changes.
Baseline after waves 2+3: stmts 44.6 / branches 42.5 / funcs 39.0 / lines 45.7 (was 33.2/27.9/29.3/34.2 after wave 1).
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 & why
Adds a Vitest coverage gate (v8 provider, text/html/lcov reports, ratcheting thresholds) and three waves of unit tests taking the suite from 126 to 388 tests. No production code was modified — only test files, the electron test mock, and test infra.
Coverage gate
@vitest/coverage-v8+vitest.config.mtscoverage config;test:coveragescript; the CIcheckjob now runs it, so a PR dropping coverage below the thresholds fails.portalIntegration.tsis excluded from the report: it is aDW_PORTALCLI/DW_PORTALLINKintegration harness driving a real socket + PTY + browser, not unit-testable code.Wave 1 — main-process stores/managers at 0% (87 tests)
shimDir,DraftStore,SettingsStore,seedFirstRun,NoteStore,PortalManager. Extends the electron test mock withFakeWebContents/WebContentsViewfakes (backwards-compatible).Wave 2 — broker + stores (134 tests)
broker.tsto 100% lines (82 tests):extractJsonObjectsedge cases,asktimeout clamp (1s–1h), wire/note/portal verbs, authorization denials,ask --contractvalidate-until-valid loop (attempt budget / rejection prompt / fallback), team asks (--all), Walker verbs.workspaceStore.ts: bootstrap, list/divider/reorder edge cases, corrupted-JSON handling (46 tests).presets.ts:presetCommand+defaultShell(6 tests).Wave 3 — renderer (63 tests)
terminalService.ts: the degradation ladder — tier 1/2/3 writes, tier-2 250ms flush, tier-3 queue cap + overflow + resync viadw.serialize, WebGL context budget (8), context-loss release, theme/tierOf/stats/dispose.Hud,DevBar,GroupNode,HistoryPanel,PreviewNode,CanvasMenu,Sidebar.Checklist
npm run typecheckandnpm run lintpass (0 errors; 2 pre-existing warnings inCanvas.tsxuntouched)Known gap (future work)
Canvas.tsx(2.2k lines),App.tsx,FileTreeNode.tsx,FloorBar.tsxremain unit-untested — they are e2e territory. A future PR could run the existing Playwright suite in CI (Linux/xvfb) to cover them.