//! Integration guard: the `aura graph` viewer's tooltip INFO maps (INFO.B for a
//! node body, INFO.C for an expanded composite's cluster frame, INFO.P for a
//! port) and the md() markdown-to-HTML step keep their current exact shape.
//!
//! The property lives in JavaScript (`addInfo`/`genDot`/`md` in
//! assets/graph-viewer.js), so this shells out to `node` running the headless
//! guard `tests/viewer_tooltip.mjs`, which loads the real viewer module and
//! drives the exported `genDot`/`md` over a minimal collapsed+expanded
//! composite / primitive fixture.
//!
//! `node` is REQUIRED: if it is not on PATH this test FAILS (a skipped guard is
//! not a guard).

use std::path::PathBuf;
use std::process::Command;

#[test]
fn viewer_tooltip_info_and_markdown_shapes_are_pinned() {
    let script = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
        .join("tests")
        .join("viewer_tooltip.mjs");
    assert!(script.exists(), "guard script missing at {}", script.display());

    let out = match Command::new("node").arg(&script).output() {
        Ok(out) => out,
        Err(e) => panic!(
            "node is required for the viewer tooltip guard but could not be run \
             ({e}); install Node.js or ensure `node` is on PATH"
        ),
    };

    let stdout = String::from_utf8_lossy(&out.stdout);
    let stderr = String::from_utf8_lossy(&out.stderr);
    assert!(
        out.status.success(),
        "viewer tooltip guard failed (exit {:?}).\n--- node stdout ---\n{stdout}\n--- node stderr ---\n{stderr}",
        out.status.code()
    );
}
