facett-git/tests/robot.rs
//! **Robot JSON-drive scenario for the git browser**, driven through the SHARED
//! generic-Facet probe in `facett_core::harness` (no hand-rolled render+emit
//! boilerplate). The pane's `update_json` robot seam was a **dead no-op** — the
//! `impl_facet_via_elm!` bridge does not generate one and the pane never overrode
//! `Facet::update_json`, so a headless robot could not drive it (only the in-view
//! `ui_render` self-cell existed). This test (a) proves the now-LIVE seam
//! end-to-end — feed a scripted message list, watch `state_json` transition — and
//! (b) adds the shared probe's `headless_render` + `responds_to_input` functional
//! cells via `facett_core::testmatrix::probe_and_emit` (a no-op unless built with
//! `--features testmatrix`). The `responds_to_input` aspect is NEW coverage: it
//! would go RED if the JSON drive seam regressed back to a no-op. See
//! `.nornir/facett-platform-gaps.md`.
use facett_git::GitView;
#[test]
fn robot_json_drive_scenario() {
let mut view = GitView::demo();
// Open a tree path, then switch the middle pane to the commit log — the exact
// JSON a headless robot sends through the `update_json` seam (serde-tagged, no
// concrete Msg type; the `Pane` payload rides in as a lowercase string).
let script = [
r#"{"select_path":"src/lib.rs"}"#, // tree-entry click
r#"{"show_pane":"log"}"#, // tab to the commit log
];
let probe = facett_core::testmatrix::probe_and_emit("facett-git", &mut view, &script);
// The initial render drew real geometry (branch list + tree) over non-empty state.
assert!(probe.drew(), "the git browser must tessellate to vertices");
assert!(probe.cardinality() > 0, "state_json reports branches / commits / tree");
// The input surface is LIVE: at least one scripted message moved state.
assert!(probe.responded(), "update_json must drive state — a dead seam is a regression");
// Pane-specific: the path opens into `selected_path`, the pane flips to `log`.
assert_eq!(probe.steps[0].state["selected_path"], "src/lib.rs", "select_path opens the path");
assert!(probe.steps[0].changed, "select_path moved state");
assert_eq!(probe.final_state["pane"], "log", "show_pane switched to the commit log");
}