//! Integration guard: the `aura graph` viewer decorates a ganged param slot
//! with its public gang name, and leaves a gang-free scope's slots bare.
//!
//! The property lives in JavaScript (`cellLabel`'s `gangFor` lookup in
//! assets/graph-viewer.js), so this shells out to `node` running the headless
//! guard `tests/viewer_gang_param.mjs`, which loads the real viewer module and
//! drives the exported `genDot` over two minimal models (one ganged, one not).
//!
//! `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_annotates_a_ganged_param_slot() {
    let script = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
        .join("tests")
        .join("viewer_gang_param.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 gang-param 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 gang-param guard failed (exit {:?}).\n--- node stdout ---\n{stdout}\n--- node stderr ---\n{stderr}",
        out.status.code()
    );
}
