molecule-core/canvas
Hongming Wang bfbbe57610 test(canvas): cover utils.cn + runtime-names.runtimeDisplayName (0% → 100%) (#1815)
[Molecule-Platform-Evolvement-Manager]

Closes two of the 0%-coverage files surfaced by the baseline run in
PR #2147 (vitest coverage instrumentation). Both files are tiny
utility helpers with high-touch read paths.

## utils.cn (8 cases)

Wraps `twMerge(clsx(inputs))` — every conditionally-styled component
flows through here. The load-bearing case is the **last-wins
Tailwind dedup**: `cn("p-2", "p-4")` → "p-4". A regression that lost
twMerge would silently double-apply utilities (cosmetically broken,
breaks `:where()` rules + theme overrides).

Cases:
  - single class unchanged
  - multiple positional classes joined
  - array input flattening (clsx)
  - object syntax with truthy/falsy keys
  - last-wins dedup on conflicting Tailwind utilities (the
    regression-locked guarantee)
  - non-conflicting utilities both survive (p-2 + m-4)
  - mixed input shapes (string + array + object + string)
  - nullish / empty inputs don't throw

## runtime-names.runtimeDisplayName (4 it.each cases + 3 it())

Friendly-name lookup that surfaces the workspace runtime in the chat
indicator, details tab, and a few component labels.

Cases:
  - known runtimes map to display strings
    (claude-code → Claude Code, langgraph → LangGraph, etc.)
  - unknown runtime falls back to input string verbatim
    (a NEW runtime not yet in the lookup still renders something
    operator-debuggable rather than a generic placeholder)
  - empty string falls back to "agent" (final default)
  - case-sensitivity pinned: "Claude-Code" / "LANGGRAPH" miss the
    lookup. The upstream slug is already normalized lowercase, so a
    future refactor that lowercases input "for safety" would
    silently change behavior — pinning the contract here.

## Test plan

- [x] All 17 cases pass locally (~129ms)
- [x] No SUT changes — pure additive coverage
- [ ] CI green

## #1815 progress

- [x] Step 1+2: coverage instrumentation + script (#2147)
- [x] 0%-file gaps utils.ts + runtime-names.ts (this PR)
- [ ] More 0%/low-coverage files: lib/canvas-actions.ts (25%),
      store/classNames.ts (17%) — separate PRs
- [ ] Step 3b: thresholds + CI gate once baseline catches up

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 23:45:51 -07:00
..
e2e chore(simplify): trim SHA-rot comments + harden TENANT_HOST scheme/port stripping 2026-04-26 11:44:54 -07:00
public chore: replace brand icon and add HANDOFF.md 2026-04-13 13:03:40 -07:00
src test(canvas): cover utils.cn + runtime-names.runtimeDisplayName (0% → 100%) (#1815) 2026-04-26 23:45:51 -07:00
.env.example fix(canvas): close 4 gaps in WS status indicator (env, toast, tests) 2026-04-14 08:26:38 +00:00
.gitignore feat(canvas): SaaS cross-origin — slug header + cookie credentials (Phase F) 2026-04-14 20:08:39 -07:00
components.json chore(canvas): initialize shadcn/ui — components.json + cn utility 2026-04-18 07:57:17 -07:00
Dockerfile chore(canvas): upgrade node:20-alpine → node:22-alpine 2026-04-24 18:54:30 +00:00
next.config.ts fix(canvas,dotenv): review-driven hardening of fit gate + parser parity 2026-04-24 22:23:51 -07:00
package-lock.json fix(canvas): cascade-delete UX — require checkbox before Delete All (#1314) 2026-04-21 07:06:45 +00:00
package.json fix(quickstart): make README cp-paste flow bugless end-to-end (#1871) 2026-04-23 19:53:43 +00:00
playwright.config.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
playwright.staging.config.ts feat(e2e): canary + canvas Playwright workflows; delegation mechanics 2026-04-21 04:15:10 -07:00
postcss.config.js initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
tailwind.config.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
tsconfig.json initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
vitest.config.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00