facett-markdown/tests/matrix.rs
//! **The functional matrix cell for facett-markdown** — the pane emitted NO
//! testmatrix row of either aspect before this file (see
//! `.nornir/docs/test-matrix-inventory-history.md`, "~10 panes emit no cell").
//!
//! ONE call: the shared generic-`Facet` probe in `facett_core::harness` renders
//! the pane headlessly, drives the JSON robot seam, and
//! `facett_core::testmatrix::probe_and_emit` turns the result into the
//! `headless_render` + `responds_to_input` rows. No bespoke harness (L5).
use facett_markdown::Markdown;
#[test]
fn markdown_probe_emits_render_and_input_cells() {
let mut view = Markdown::local();
let script = [
r#""preview""#, // flip to the render lane
r#"{"set_text":"@ada owns #kernel and #driver"}"#, // retype the source
r#""edit""#,
];
let probe = facett_core::testmatrix::probe_and_emit("facett-markdown", &mut view, &script);
assert!(probe.drew(), "the note must tessellate to vertices");
assert!(probe.cardinality() > 0, "state_json reports mentions/tags");
assert!(probe.responded(), "update_json must drive state — a dead seam is a regression");
// EXACT transitions: the mode toggle and the derived mention/tag extraction.
assert_eq!(probe.initial_state["mode"], "Edit");
assert_eq!(probe.initial_state["mentions"], serde_json::json!(["maria", "johan"]));
assert_eq!(probe.initial_state["tags"], serde_json::json!(["frist", "bygglov"]));
assert_eq!(probe.steps[0].state["mode"], "Preview");
assert_eq!(probe.steps[1].state["mentions"], serde_json::json!(["ada"]));
assert_eq!(probe.steps[1].state["tags"], serde_json::json!(["kernel", "driver"]));
assert_eq!(probe.steps[1].state["chars"], 29);
assert_eq!(probe.steps[2].state["mode"], "Edit");
}
/// RED-when-broken: the copy/paste capability must actually round-trip the source
/// (a `copyable()` cap that hands back nothing is a lie the deck would act on).
#[test]
fn copy_paste_round_trips_the_source() {
use facett_core::Facet;
let mut a = Markdown::local();
let text = a.copy().expect("copyable");
assert_eq!(text, a.text());
let mut b = Markdown::new("Empty");
assert_eq!(b.state_json()["chars"], 0);
assert!(b.paste(&text));
assert_eq!(b.text(), a.text());
assert_eq!(b.state_json()["mentions"], a.state_json()["mentions"]);
}