Skip to content

test: cover CLI core loop, MCP tools, and richRender branches#159

Merged
benvinegar merged 1 commit into
mainfrom
test/coverage-cli-mcp-richrender
Jun 26, 2026
Merged

test: cover CLI core loop, MCP tools, and richRender branches#159
benvinegar merged 1 commit into
mainfrom
test/coverage-cli-mcp-richrender

Conversation

@benvinegar

Copy link
Copy Markdown
Member

What

Adds 53 tests across the three highest-risk coverage gaps identified by node --experimental-test-coverage. No source changes — tests only.

Why

A coverage audit (274 tests, all green) surfaced three gaps ranked by product invariant, not raw line count:

  1. bin/sideshow.js (CLI) — a first-class integration tier ("agents with only a shell can use this") sat at 63.7% lines / 44% branches. The core publish → comment → revise loop — the product's central flow — was entirely untested.
  2. server/mcpHttp.ts (MCP) — another first-class tier. upload_asset was untested, plus get_design_guide and the JSON-RPC error paths.
  3. server/richRender.ts — builds the sandboxed HTML served from /s/:id under a sandbox CSP header (a load-bearing isolation invariant). 61.5% branch coverage with zero unit tests (only e2e).

The feedback cursor / exactly-once delivery (the #1 guarded invariant) was already well covered — no action needed there.

Changes

test/cli.test.ts (+38 tests, +527 lines)

The CLI core loop, pinned to a real in-process server via SIDESHOW_URL/SIDESHOW_SESSION:

  • publish — file + stdin (-), combined surfaces (--md/--code/--terminal/--mermaid), --code language inference from filename, --json invalid-JSON error, --diff --layout split
  • diff / markdown / code (with --line-start/--filename/--language) / terminal (--cols/--term-title) / json (valid + invalid) / mermaid
  • update — revise to v2 on the same card; missing-id usage error
  • wait — returns a pending comment; timedOut on no comments; bad --after fails fast
  • comment--author override, --surface back-compat alias, missing --post usage error
  • list / list --all / sessions
  • image / upload / asset-url (content hash, no server hit)
  • error paths: unreachable server (one-line error, no stack trace), server error surfaced

test/api.test.ts (+11 tests, +136 lines)

MCP /mcp endpoint, appended to the existing MCP section:

  • upload_asset — base64 round-trip (id + url + kind + retrievable bytes), missing-data error, explicit-session attach
  • get_design_guide returns the guide text
  • publish_post empty-surfaces error
  • update_snippet legacy html argument revises to v2
  • JSON-RPC: malformed body → −32700 (400), batch → −32600 (400), notification → 202, ping{}

test/richRender.test.ts (new, +14 tests, 117 lines)

First unit tests for the server-side rich-surface renderers:

  • markdown: link target=_blank + rel=noopener noreferrer, code highlighting
  • code: empty-language plain fallback, unknown-language try/catch fallback, lineStart counter-reset, shiki highlight path, filename header bar, copy-button JS-string escaping (\u003c)
  • diff: explicit part.files (no patch), multi-file patch (one <diffs-container> per file), processFile fallback for headerless patches, empty-patch throws
  • terminal: ANSI → colored spans, cols width, default "terminal" title

Coverage

Area Lines Branches Functions
Overall 94.2% → 96.8% 85.6% → 87.3% 90.9% → 93.3%
bin/sideshow.js 63.7% → 78.9% 44.0% → 45.7% 54.6% → 66.3%
server/mcpHttp.ts 85.1% → 100% 67.1% → 80.7% 81.8% → 81.8%
server/richRender.ts 92.7% → 100% 61.5% → 87.5% 78.3% → 95.8%

Remaining CLI gap is platform-specific agentPid process-tree walking (Windows/ps) and the trace-sync/demo/watch loops — lower-risk than the core loop.

Validation

  • npm test — 327 pass, 0 fail (was 274)
  • npm run typecheck — clean (all three tsc programs)
  • npm run lint — 0 warnings, 0 errors
  • npm run format:check — clean

Maintenance-only (test-only) → empty changeset.

Add 53 tests across the three highest-risk coverage gaps (no source
changes — tests only):

- bin/sideshow.js (63.7% → 78.9% lines): publish (file/stdin/combined
  surfaces/lang inference), update, wait, comment, list/sessions,
  diff/markdown/code/terminal/json/mermaid, image/upload/asset-url,
  and error paths (unreachable server, server error, usage errors).
- server/mcpHttp.ts (85.1% → 100% lines, 67% → 80.7% branches):
  upload_asset, get_design_guide, publish_post empty-surfaces error,
  update_snippet legacy html, JSON-RPC parse/batch errors, ping,
  notifications.
- server/richRender.ts (92.7% → 100% lines, 61.5% → 87.5% branches,
  new test/richRender.test.ts): markdown link attrs, code lineStart
  counter + plain fallback + copy escaping, diff part.files path +
  multi-file patch + processFile fallback, terminal ANSI + cols.

Overall: 94.2/85.6/90.9 → 96.8/87.3/93.3 (lines/branches/functions).
274 → 327 tests, all green; lint, typecheck, and format clean.
@benvinegar benvinegar merged commit 3c26e37 into main Jun 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant