tests/the_topbar_names_the_domain.rs
//! ★ **The topbar names the security domain** (lane HOL-CDS, owner 2026-10-30): a Holger's
//! RON `domain: "<label>"` rides on every answer as `X-Holger-Domain` (holger
//! `server/lib/src/boundary.rs`), and the console shows it in the topbar, beside the server
//! it talks to, so an operator always sees which side of the boundary this console is on.
//! Held over the source: the topbar mounts the chip, the chip is the header's value from
//! holger's own answer (never a value typed into the console), and the label is cleaned by
//! one pure function (`util::domain_label`, unit-tested beside it).
const ROOT: &str = env!("CARGO_MANIFEST_DIR");
fn code(path: &str) -> String {
let text = std::fs::read_to_string(format!("{ROOT}/{path}")).unwrap_or_else(|e| panic!("{path}: {e}"));
text.lines().filter(|l| !l.trim_start().starts_with("//")).collect::<Vec<_>>().join("\n")
}
#[test]
fn the_topbar_mounts_the_domain_chip_from_holgers_answer() {
let app = code("src/app.rs");
let topbar = &app[app.find(r#"<header class="topbar">"#).expect("the topbar")..];
let topbar = &topbar[..topbar.find("</header>").expect("the topbar ends")];
assert!(topbar.contains(r#"class="domainchip""#), "the topbar shows no domain chip");
assert!(code("src/grpc.rs").contains("x-holger-domain"), "the chip is not read from holger's X-Holger-Domain");
assert!(code("assets/console.css").contains(".domainchip"), "the chip has no style");
}
#[test]
fn the_label_is_cleaned_by_one_pure_function_with_its_own_tests() {
let util = code("src/util.rs");
assert!(util.contains("pub fn domain_label(header: Option<&str>) -> Option<String>"), "no util::domain_label");
assert!(util.contains("fn a_domain_label_is_holgers_trimmed_or_nothing()"), "domain_label has no unit test");
}