Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

facett-matrix/tests/robot.rs

//! **Robot JSON-drive scenario for the test-matrix grid**, 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_matrix::MatrixView;

#[test]
fn robot_json_drive_scenario() {
    let mut view = MatrixView::local();

    // Drill into a repo's red cases, then clear — the exact JSON a headless robot
    // sends through the `update_json` seam (serde-tagged, no concrete Msg type).
    let script = [
        r#"{"select_repo":"nornir"}"#, // repo-row drill-in
        r#""clear_selection""#,        // clear the selection
    ];

    let probe = facett_core::testmatrix::probe_and_emit("facett-matrix", &mut view, &script);

    // The initial render drew real geometry (coloured cells) over non-empty state.
    assert!(probe.drew(), "the matrix grid must tessellate to vertices");
    assert!(probe.cardinality() > 0, "state_json reports the grid rows");
    // 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 drill-in lands in `selected`, the clear removes it.
    assert_eq!(probe.steps[0].state["selected"], "nornir", "select_repo pins the repo");
    assert!(probe.steps[0].changed, "select_repo moved state");
    assert_eq!(probe.final_state["selected"], serde_json::Value::Null, "clear_selection cleared it");
}