molecule-core/canvas/src/lib
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
..
__tests__ test(canvas): cover utils.cn + runtime-names.runtimeDisplayName (0% → 100%) (#1815) 2026-04-26 23:45:51 -07:00
api feat(canvas): SaaS cross-origin — slug header + cookie credentials (Phase F) 2026-04-14 20:08:39 -07:00
validation fix(ci): handle merge_group + shallow-clone BASE in secret-scan 2026-04-26 14:08:19 -07:00
api.ts Merge branch 'staging' into fix/canvas-multilevel-layout-ux 2026-04-26 00:36:54 -07:00
auth.ts fix(auth): redirect to app.moleculesai.app for login, not tenant subdomain 2026-04-23 11:16:22 -07:00
billing.ts fix(canvas): apply flat-rate pricing copy for Phase 34 launch (Issue #1833) 2026-04-24 17:54:23 +00:00
canvas-actions.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
credits.ts feat(canvas): Phase 5 — credit balance pill + low-balance banner 2026-04-19 07:27:29 -07:00
deploy-preflight.ts feat(canvas+org): env preflight, EmptyState parity, shared useTemplateDeploy hook 2026-04-24 15:15:33 -07:00
design-tokens.ts fix(canvas): address all code review findings on PR #482 2026-04-16 07:48:47 -07:00
hydrate.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
runtime-names.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
runtimeProfiles.ts refactor(canvas): remove RUNTIME_PROFILES.hermes — value flows server-side now (#2054 phase 3) 2026-04-26 07:12:44 -07:00
services.ts refactor(secrets): strip Service dropdown from Add-Key form 2026-04-22 16:41:43 -07:00
tenant.ts feat(canvas): default tier T3 and hide T1/T2 on SaaS 2026-04-22 17:02:48 -07:00
utils.ts chore(canvas): initialize shadcn/ui — components.json + cn utility 2026-04-18 07:57:17 -07:00
ws-close.ts fix(canvas): Legend avoids TemplatePalette + silence WS handshake races 2026-04-23 16:03:01 -07:00
ws-url.ts fix: code review findings — token UI, auth hardening, WS dedup 2026-04-16 10:42:26 -07:00