openclaw - 💡(How to fix) Fix No unit tests for core `viewer-client.ts` logic: toolbar state machine, `hydrateViewer`, and `syncAllControllers` [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#83915Fetched 2026-05-20 03:46:47
View on GitHub
Comments
1
Participants
2
Timeline
13
Reactions
1
Timeline (top)
labeled ×5mentioned ×3subscribed ×3commented ×1

Fix Action

Fix / Workaround

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


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.

Code Example

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"');
  });
RAW_BUFFERClick to expand / collapse

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)

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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix No unit tests for core `viewer-client.ts` logic: toolbar state machine, `hydrateViewer`, and `syncAllControllers` [1 comments, 2 participants]