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

nordisk/facett

facett-jobview/tests/robot.rs

//! **Robot JSON-drive scenario for the job/task-list viewer**, 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_jobview::{JobEntry, JobList, JobStatus};

#[test]
fn robot_json_drive_scenario() {
    let mut view = JobList::new("Jobs");
    view.set_jobs(vec![
        JobEntry::new("a", "bench_run", JobStatus::Done),
        JobEntry::new("b", "docs_book_svg", JobStatus::Running),
        JobEntry::new("c", "bench_run", JobStatus::Failed),
    ]);

    // Select a row, then clear — the exact JSON a headless robot sends through the
    // `update_json` seam (serde-tagged, no concrete Msg type at the call site).
    let script = [
        r#"{"select":"b"}"#,     // row-click select
        r#""clear_selection""#, // clear the selection
    ];

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

    // The initial render drew real geometry (row tree) over non-empty state.
    assert!(probe.drew(), "the job tree must tessellate to vertices");
    assert!(probe.cardinality() > 0, "state_json reports the job 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 select lands in `selected`, the clear removes it.
    assert_eq!(probe.steps[0].state["selected"], "b", "select pins the row id");
    assert!(probe.steps[0].changed, "select moved state");
    assert_eq!(probe.final_state["selected"], serde_json::Value::Null, "clear_selection cleared it");
}