Problem
The entire UI layer (app.js, renderer.js, editor.js, charts.js, app-*.js) has zero unit tests. All UI testing relies on a single Playwright smoke test (test/smoke.js) — a 1000-line monolithic script tightly coupled to DOM structure. A typo in an element ID, a broken undo restore, or a corrupted clipboard paste can go undetected.
Plan
Add unit tests for UI functions that are testable without a browser. These run under Node alongside the existing engine tests.
Test targets
-
Undo/redo stack integrity — after N edits, undo returns to exact prior state; redo restores; committing after undo clears redo stack; stack capped at 100 entries.
-
Copy/paste ID remapping — copied nodes get new IDs; connection endpoints remapped; clipboard offset advances on repeated paste; only internal connections between selected nodes are preserved.
-
Share URL encode/decode round-trip — encodeURIComponent + btoa / atob + decodeURIComponent pair correctly for diagrams with Unicode labels, special characters, and edge cases (empty diagram, single node).
-
Assertion parsing edge cases — parseAssertion handles: missing expression, whitespace-only, unclosed quotes, multiple colons, step zero, negative step, non-integer step.
What's NOT included
- DOM-dependent tests (renderer, editor interaction, charts) — these remain in the Playwright smoke test
- CSS/layout regression tests
Effort
~4 hours. 1 file (test/run.js additions or a new test/ui-tests.js). ~150 lines.
Problem
The entire UI layer (
app.js,renderer.js,editor.js,charts.js,app-*.js) has zero unit tests. All UI testing relies on a single Playwright smoke test (test/smoke.js) — a 1000-line monolithic script tightly coupled to DOM structure. A typo in an element ID, a broken undo restore, or a corrupted clipboard paste can go undetected.Plan
Add unit tests for UI functions that are testable without a browser. These run under Node alongside the existing engine tests.
Test targets
Undo/redo stack integrity — after N edits, undo returns to exact prior state; redo restores; committing after undo clears redo stack; stack capped at 100 entries.
Copy/paste ID remapping — copied nodes get new IDs; connection endpoints remapped; clipboard offset advances on repeated paste; only internal connections between selected nodes are preserved.
Share URL encode/decode round-trip —
encodeURIComponent+btoa/atob+decodeURIComponentpair correctly for diagrams with Unicode labels, special characters, and edge cases (empty diagram, single node).Assertion parsing edge cases —
parseAssertionhandles: missing expression, whitespace-only, unclosed quotes, multiple colons, step zero, negative step, non-integer step.What's NOT included
Effort
~4 hours. 1 file (
test/run.jsadditions or a newtest/ui-tests.js). ~150 lines.