tests/the_console_speaks_plainly.rs
//! ★ **The console speaks plainly** (HCON-2, HCON-3, HCON-4; owner 2026-10-27), held on the
//! page sources so a later edit cannot bring the internals back:
//!
//! * HCON-2: the Overview (where a login lands) shows the estate board and no session card:
//! the session's details are the Account page's only, in plain words (`util::session_words`,
//! `util::read_gate_words`), never a raw "Subject", "Global role" or "Read gate" field.
//! * HCON-3: the header names holger ONCE: the mark is decorative (`alt=""`), the word is text.
//! * HCON-4: every uptime goes through the one formatter, `util::uptime_words`; no page prints
//! raw seconds ("up 56305s").
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_overview_shows_no_session_internals() {
let o = code("src/pages/dashboard.rs");
for internal in ["<h3>\"Session\"</h3>", "id.subject", "session_note", "global_role", "read_gate"] {
assert!(!o.contains(internal), "the Overview shows a session internal again: {internal}");
}
}
#[test]
fn the_account_page_says_the_session_in_plain_words() {
let a = code("src/pages/login.rs");
// HCON-5: what is open is the server's words (access_words), the read gate's sentence its fallback.
assert!(a.contains("session_words(") && a.contains("access_words("), "the Account page says the session through the plain-word formatters");
for field in ["<dt>\"Credential\"</dt>", "<dt>\"Global role\"</dt>", "<dt>\"Read gate\"</dt>", "<dt>\"Method\"</dt>"] {
assert!(!a.contains(field), "a raw field on the Account page: {field}");
}
}
#[test]
fn the_header_names_holger_once() {
let app = code("src/app.rs");
let at = app.find("class=\"brand\"").expect("the brand");
let brand = &app[at..at + app[at..].find("</a>").expect("the brand closes")];
assert!(brand.contains(r#"alt="""#), "the mark is decorative: its alt text would say holger a second time: {brand}");
assert_eq!(brand.matches("\"holger\"").count(), 1, "the word holger once: {brand}");
}
#[test]
fn every_uptime_goes_through_the_one_formatter() {
for page in ["src/app.rs", "src/pages/dashboard.rs", "src/pages/admin.rs"] {
let c = code(page);
assert!(!c.contains("up {}s") && !c.contains("up {} s"), "{page} prints raw seconds");
if c.contains("uptime_seconds") {
assert!(c.contains("uptime_words("), "{page} shows an uptime without util::uptime_words");
}
}
}