Severity: medium / Confidence: high / Category: test-gap
Triage: test-gap
Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18)
Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol
Evidence
it("serves the runtime bundle body", async () => {
const runtime = await getServedViewerAsset(VIEWER_RUNTIME_PATH);
expect(runtime?.contentType).toBe("text/javascript; charset=utf-8");
expect(String(runtime?.body)).toContain("openclawDiffsReady");
expect(String(runtime?.body)).toContain('style.width="24px"');
expect(String(runtime?.body)).toContain('style.gap="6px"');
});
Reasoning
viewer-client.ts owns the entire client-side diff viewer: payload parsing, shadow-root attachment, toolbar construction, theme/layout toggle state, and multi-card synchronization. The only test coverage it receives is a bundle-content grep in config.test.ts that checks for three minified style string literals. This means: (1) the viewerState singleton's initial-value seeding from firstPayload is untested; (2) toolbar button toggle logic is untested; (3) the ensureShadowRoot fallback path (no template present) is untested; (4) the getHydrateProps branching between fileDiff and oldFile/newFile payloads is untested. A regression in any of these would only be caught at screenshot/E2E level.
Recommendation
Add a viewer-client.test.ts using jsdom (Vitest's default environment) that mocks @pierre/diffs (FileDiff, preloadHighlighter) and exercises: card discovery via getCards, hydrateViewer initial state seeding, toolbar button click toggling viewerState and calling syncAllControllers, and ensureShadowRoot template-clone path.
Why existing tests miss this
No test file targets viewer-client.ts. The associated test list in the feature metadata contains only server-side plugin tests (store, render, config, browser, manifest).
Suggested regression test
Create extensions/diffs/src/viewer-client.test.ts with jsdom environment. Mock @pierre/diffs to expose a FileDiff spy. Set document.readyState to 'complete', inject two .oc-diff-card elements with valid payload scripts and shadow host templates, import the module, and assert (a) controllers has length 2, (b) clicking the layout toggle button updates all controllers via setOptions.
Minimum fix scope
New test file extensions/diffs/src/viewer-client.test.ts covering at minimum: initial viewerState seeding, toolbar toggle round-trip, and the per-card hydration loop.
Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-1f351e9797-_80cde1830b.
Severity: medium / Confidence: high / Category: test-gap
Triage: test-gap
Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18)
Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol
Evidence
extensions/diffs/src/viewer-client.ts:1-330(None)extensions/diffs/src/config.test.ts:383-394(serves the runtime bundle body)Reasoning
viewer-client.tsowns the entire client-side diff viewer: payload parsing, shadow-root attachment, toolbar construction, theme/layout toggle state, and multi-card synchronization. The only test coverage it receives is a bundle-content grep inconfig.test.tsthat checks for three minified style string literals. This means: (1) theviewerStatesingleton's initial-value seeding fromfirstPayloadis untested; (2) toolbar button toggle logic is untested; (3) theensureShadowRootfallback path (no template present) is untested; (4) thegetHydratePropsbranching betweenfileDiffandoldFile/newFilepayloads is untested. A regression in any of these would only be caught at screenshot/E2E level.Recommendation
Add a
viewer-client.test.tsusing jsdom (Vitest's default environment) that mocks@pierre/diffs(FileDiff,preloadHighlighter) and exercises: card discovery viagetCards,hydrateViewerinitial state seeding, toolbar button click togglingviewerStateand callingsyncAllControllers, andensureShadowRoottemplate-clone path.Why existing tests miss this
No test file targets
viewer-client.ts. The associated test list in the feature metadata contains only server-side plugin tests (store, render, config, browser, manifest).Suggested regression test
Create
extensions/diffs/src/viewer-client.test.tswith jsdom environment. Mock@pierre/diffsto expose aFileDiffspy. Setdocument.readyStateto'complete', inject two.oc-diff-cardelements with valid payload scripts and shadow host templates, import the module, and assert (a)controllershas length 2, (b) clicking the layout toggle button updates all controllers viasetOptions.Minimum fix scope
New test file
extensions/diffs/src/viewer-client.test.tscovering at minimum: initialviewerStateseeding, toolbar toggle round-trip, and the per-card hydration loop.Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID:
fnd_sig-feat-cli-command-1f351e9797-_80cde1830b.