nornir-demo/tests/zone_demo_robot.rs
//! **Robot JSON-drive scenario for nornir's zone/jera showcase surface** ([`ZoneDemo`]).
//!
//! Driven through the SHARED generic-`dyn Facet` probe in `facett_core::testmatrix`
//! (the same probe facett-zoneui's own robot test uses): it headless-renders the
//! surface (proving it drew real geometry) then plays a scripted `update_json` list,
//! snapshotting `state_json` after each (proving the input surface is LIVE). This
//! drives the EXACT surface the wasm/native harness mounts — no hand-rolled render.
//!
//! Asserts the three framework guarantees: the Tools-menu pane OPENS, a zone SELECT
//! lands in `state_json`, the central [`JeraCentral`] lists a job WITH its zone, and
//! there is **NO bare demo button** (RED if one reappears).
// The whole crate is a binary (`main.rs`); pull the module in directly for the test.
#[path = "../src/panel.rs"]
mod panel;
#[path = "../src/zone_demo.rs"]
mod zone_demo;
use zone_demo::ZoneDemo;
#[test]
fn zone_demo_robot_json_drive_scenario() {
let mut app = ZoneDemo::new();
// The exact JSON a headless robot sends: open the Tools-menu pane, pick the test
// zone, then press Generate.
let script = [
r#"{"app":"open_zone_pane"}"#,
r#"{"select_zone":"test"}"#,
r#""generate""#,
];
let probe = facett_core::testmatrix::probe_and_emit("nornir-zone-demo", &mut app, &script);
// It drew real geometry (menu + central panel + pane), reports domain data, and
// the input surface is live (a scripted message moved state).
assert!(
probe.drew(),
"the zone/jera surface must tessellate to vertices"
);
assert!(probe.cardinality() > 0, "state_json reports domain data");
assert!(
probe.responded(),
"update_json must drive state — a dead seam is a regression"
);
// 1) The Tools-menu pane opened.
assert_eq!(
probe.steps[0].state["zone_pane_open"], true,
"Tools → Demo/Zone opened the pane"
);
// 2) Selecting the zone landed in state_json (default was demo).
assert_eq!(
probe.steps[1].state["zone_pane"]["zone"], "test",
"select pins the zone"
);
assert!(probe.steps[1].changed, "select moved state");
// 3) The central JeraCentral panel lists a nornir job WITH its zone column.
let jobs = probe.final_state["jera"]["jobs"]
.as_array()
.expect("jobview jobs[] present");
assert!(
jobs.iter().any(|r| r["id"] == "release-wave-3"),
"the seeded nornir job is listed in the central panel",
);
assert_eq!(
probe.final_state["jera"]["zones"]["release-wave-3"], "demo",
"listed with its zone"
);
assert_eq!(
probe.final_state["jera"]["zones"]["gate-test"], "test",
"the zone column varies"
);
// 4) Generate is nornir's honest no-op (a single "(no infra)" status, not faked
// FalkorDB/Spark), and there is NO bare demo button anywhere.
let containers = probe.final_state["zone_pane"]["containers"]
.as_array()
.expect("containers[]");
assert_eq!(
containers.len(),
1,
"the no-op status, not 2 faked containers"
);
assert_eq!(containers[0]["name"], "(no infra)");
assert_eq!(
probe.final_state["has_demo_button"], false,
"NO bare demo button — the guard"
);
assert_eq!(
probe.final_state["zone_pane"]["has_demo_button"], false,
"the pane pins it too"
);
}