test: cover CLI core loop, MCP tools, and richRender branches#159
Merged
Conversation
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.
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
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:
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.server/mcpHttp.ts(MCP) — another first-class tier.upload_assetwas untested, plusget_design_guideand the JSON-RPC error paths.server/richRender.ts— builds the sandboxed HTML served from/s/:idunder asandboxCSP 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),--codelanguage inference from filename,--jsoninvalid-JSON error,--diff --layout splitdiff/markdown/code(with--line-start/--filename/--language) /terminal(--cols/--term-title) /json(valid + invalid) /mermaidupdate— revise to v2 on the same card; missing-id usage errorwait— returns a pending comment;timedOuton no comments; bad--afterfails fastcomment—--authoroverride,--surfaceback-compat alias, missing--postusage errorlist/list --all/sessionsimage/upload/asset-url(content hash, no server hit)test/api.test.ts(+11 tests, +136 lines)MCP
/mcpendpoint, appended to the existing MCP section:upload_asset— base64 round-trip (id + url + kind + retrievable bytes), missing-dataerror, explicit-session attachget_design_guidereturns the guide textpublish_postempty-surfaces errorupdate_snippetlegacyhtmlargument revises to v2ping→{}test/richRender.test.ts(new, +14 tests, 117 lines)First unit tests for the server-side rich-surface renderers:
target=_blank+rel=noopener noreferrer, code highlightingtry/catchfallback,lineStartcounter-reset, shiki highlight path, filename header bar, copy-button JS-string escaping (\u003c)part.files(no patch), multi-file patch (one<diffs-container>per file),processFilefallback for headerless patches, empty-patch throwscolswidth, default"terminal"titleCoverage
bin/sideshow.jsserver/mcpHttp.tsserver/richRender.tsRemaining CLI gap is platform-specific
agentPidprocess-tree walking (Windows/ps) and thetrace-sync/demo/watchloops — 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 errorsnpm run format:check— cleanMaintenance-only (test-only) → empty changeset.