Skip to content

test(visual-ide): add unit tests for stdoutParser.js marker formats #51

Description

@ax1s-x1zz

Summary

The visual IDE (visual-ide/) has a stdout marker parser (src/transpiler/stdoutParser.js) that parses [xazz:*] markers, but there is no unit test for it, and the contract tests (visual-ide/tests/contract.mjs) don't cover the parser. Recently the [xazz:chart] and [xazz:dp] markers changed from a two-line format to a single-line self-contained format (with the old two-line form kept as a fallback). This is untested and worth locking down.

Context

  • Parser: visual-ide/src/transpiler/stdoutParser.jsparseStdout(lines) returns ExecutionEvent[]; helpers getChartEvents, getErrorEvents, getTextEvents.
  • New single-line formats:
    • [xazz:chart] {JSON} (and legacy: [xazz:chart] then JSON on next line)
    • [xazz:dp] {JSON}
  • The repo has no JS test runner for this file (no vitest/jest configured). visual-ide/package.json scripts use node tests/*.mjs for contract tests.

Task

Add a lightweight test harness for stdoutParser.js:

  1. A visual-ide/tests/stdoutParser.mjs (plain Node, no new deps) that imports parseStdout from the transpiler and asserts:
    • single-line [xazz:chart] {json} produces a chart event with transformed data (bar/line with x/y; pie with label/value).
    • legacy two-line [xazz:chart] + JSON still parses (fallback).
    • [xazz:dp] {json} is ignored as a text/unknown event (the parser doesn't emit dp events — assert it doesn't crash and yields a text event).
    • [xazz:result] {json} yields a text event (current behavior).
    • [xazz:error] + AI_SUGGESTION: legacy block yields an error event with suggestion.
    • random/non-marker lines yield text events.
  2. Wire it into package.json as "test:stdout": "node tests/stdoutParser.mjs".
  3. Document in the test file how to run it.

Definition of Done

  • cd visual-ide && npm run test:stdout passes (requires no server, no browser).
  • The existing npm run build still works.
  • Assertions cover both the new single-line and legacy two-line marker forms.

Notes

  • Pure JS, no React/DOM — can run in plain Node with the ESM import.
  • Do not rename or restructure parseStdout; only add tests (fix any bug you find, but note it clearly in the PR).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions