Skip to content

test: coverage gate + unit tests for main-process stores - #30

Merged
RVerdiF merged 5 commits into
caribeedu:mainfrom
RVerdiF:feat/coverage-setup
Aug 13, 2026
Merged

test: coverage gate + unit tests for main-process stores#30
RVerdiF merged 5 commits into
caribeedu:mainfrom
RVerdiF:feat/coverage-setup

Conversation

@RVerdiF

@RVerdiF RVerdiF commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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.mts coverage config; test:coverage script; the CI check job now runs it, so a PR dropping coverage below the thresholds fails.
  • Thresholds are ratcheting: they sit just below the last measured baseline and only move up.
Baseline Stmts Branches Funcs Lines
Before (2026-08-13) 28.5% 24.4% 25.3% 29.1%
After wave 1 33.2% 27.9% 29.3% 34.2%
After waves 2+3 44.6% 42.5% 39.0% 45.7%
Thresholds now 41 39 36 42

portalIntegration.ts is excluded from the report: it is a DW_PORTALCLI / DW_PORTALLINK integration 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 with FakeWebContents / WebContentsView fakes (backwards-compatible).

Wave 2 — broker + stores (134 tests)

  • broker.ts to 100% lines (82 tests): extractJsonObjects edge cases, ask timeout clamp (1s–1h), wire/note/portal verbs, authorization denials, ask --contract validate-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 via dw.serialize, WebGL context budget (8), context-loss release, theme/tierOf/stats/dispose.
  • Components: Hud, DevBar, GroupNode, HistoryPanel, PreviewNode, CanvasMenu, Sidebar.

Checklist

  • npm run typecheck and npm run lint pass (0 errors; 2 pre-existing warnings in Canvas.tsx untouched)
  • Behavior verified: suite is 388 tests / 41 files green; coverage gate enforces 41/39/36/42 in CI
  • No AGENTS.md invariant violated — test-only + test infra changes, no production code touched
  • Docs updated if behavior or architecture changed — N/A: no user-facing behavior change

Known gap (future work)

Canvas.tsx (2.2k lines), App.tsx, FileTreeNode.tsx, FloorBar.tsx remain unit-untested — they are e2e territory. A future PR could run the existing Playwright suite in CI (Linux/xvfb) to cover them.

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
caribeedu self-requested a review August 13, 2026 19:00

@caribeedu caribeedu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

- 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).
@RVerdiF
RVerdiF merged commit 274d6c3 into caribeedu:main Aug 13, 2026
3 checks passed
@RVerdiF RVerdiF added the tests Test coverage, CI and quality-gate changes (no user-facing behavior) label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test coverage, CI and quality-gate changes (no user-facing behavior)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants