Skip to content

Add unit tests for critical UI-layer pure functions #49

Description

@zntznt

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

  1. 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.

  2. 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.

  3. 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).

  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions