dwarves-gui/tests/robot_binary_room.rs
//! **ROBOT-UI: the Binary tab draws the binary half of the SELECTED workspace's code room.**
//!
//! The shipped shell, given only the forge; the forge proxies `CodeRoom.Answer` to a mock
//! nornir answering `Viz.Binary` in the reader's own shape (`common::binary`). Every
//! assertion is a VALUE from the pane's `state_json` compared with that answer:
//!
//! 1. the artifact, its bytes by crate (the treemap) and its size per release (the ledger);
//! 2. NO hardening badge — the binary layer does not grade the ELF;
//! 3. it asked `Viz.Binary` of the selected workspace, through the forge — and no pre-v2
//! binary table;
//! 4. a room with no linked artifact: the state and its sentence, no treemap.
mod common;
use common::*;
use facett_core::Facet;
use serde_json::json;
const NO_ARTIFACT: &str = "the room [shop@2] holds no linked symbol: shop: no_artifact — no linked artifact of this commit — looked in /srv/ws/builds/mimir_v2/artifacts/shop/0123456789abcdef0123; no Build Thing run has filed an artifact with this server either (`Coderoom.Artifacts` is empty)";
const NO_BINARY: &str = "the room [shop@2] holds no linked symbol: the binary stream of its repos was not consumed — there is no binary to show, and that is not an empty binary";
#[test]
fn the_binary_tab_draws_the_rooms_binary_half_through_the_forge() {
let st = stand(full_room());
let mut app = shell(&st.host);
Facet::update_json(&mut app, &json!({ "set_tab": "Binary" }).to_string());
Facet::update_json(&mut app, r#"{"wait":true}"#);
let s = Facet::state_json(&app);
let b = &s["binary"];
// 1. the reader's figures
let want = binary();
assert_eq!(b["from_room"], true, "{b}");
assert_eq!(b["artifact"], want["artifact"]);
assert_eq!(b["crate_count"].as_u64(), Some(2));
assert_eq!(
(
b["treemap"][0]["crate"].as_str(),
b["treemap"][0]["bytes"].as_u64()
),
(Some("shop"), Some(4100))
);
assert_eq!(b["history"], json!([88000, 91000]));
assert_eq!(
b["artifacts"],
json!([
"shop@x86_64-unknown-linux-gnu:release",
"shopctl@x86_64-unknown-linux-gnu:release"
])
);
assert_eq!(b["room"]["room"], ROOM_LINE);
// 2. no badge from a layer that does not grade the ELF
assert!(b["checksec"].is_null(), "{b}");
// 3. what was asked, of which workspace — through the forge
let asked = asked(&st.room);
assert!(
asked.contains(&(WS.to_string(), "Viz.Binary".to_string())),
"{asked:?}"
);
assert!(
!s.to_string().contains("binary_facts"),
"no pre-v2 binary table is named: {s}"
);
// 4. no linked artifact
st.room
.set("Viz.Binary", refusal("not_consumed", NO_BINARY));
Facet::update_json(&mut app, &json!({ "set_workspace": WS }).to_string());
Facet::update_json(&mut app, r#"{"wait":true}"#);
let s = Facet::state_json(&app);
let b = &s["binary"];
assert_eq!(
(b["from_room"].as_bool(), b["room"]["state"].as_str()),
(Some(false), Some("not_consumed")),
"{b}"
);
assert!(
b["room"]["evidence"]
.as_str()
.unwrap_or("")
.contains("binary stream"),
"{b}"
);
assert!(
b.get("treemap").is_none() && b.get("crate_count").is_none(),
"no treemap: {b}"
);
// 5. no linked artifact (what dwarf's live room answers): a state the tab knows
st.room
.set("Viz.Binary", refusal("no_artifact", NO_ARTIFACT));
Facet::update_json(&mut app, &json!({ "set_workspace": WS }).to_string());
Facet::update_json(&mut app, r#"{"wait":true}"#);
let s = Facet::state_json(&app);
let b = &s["binary"];
assert_eq!(
(b["room"]["state"].as_str(), b["room"]["evidence"].as_str()),
(Some("no_artifact"), Some(NO_ARTIFACT)),
"{b}"
);
assert!(
b["plain"]
.as_str()
.unwrap_or("")
.starts_with("No linked artifact in the room yet"),
"{b}"
);
matrix("binary_tab_reads_the_rooms_binary_half", true, "Binary tab: Viz.Binary through the forge's CodeRoom.Answer — treemap by crate, size per release, no checksec; not_consumed drawn as its state");
}