use super::module_customer_context;
use crate::i18n::I18n;
use renderreport::components::Component;
fn text(i18n: &I18n, module: &str, score: u32, interp: &str) -> String {
module_customer_context(i18n, module, Some(score), interp)
.to_data()
.to_string()
}
#[test]
fn module_customer_context_varies_by_module() {
let i18n = I18n::new("de").expect("de locale");
assert_ne!(
text(&i18n, "performance", 60, ""),
text(&i18n, "ai_visibility", 60, "")
);
}
#[test]
fn module_customer_context_reflects_score_band() {
let i18n = I18n::new("de").expect("de locale");
let critical = text(&i18n, "performance", 40, "");
let mid = text(&i18n, "performance", 60, "");
let good = text(&i18n, "performance", 90, "");
assert_ne!(critical, mid);
assert_ne!(mid, good);
assert_ne!(critical, good);
}
#[test]
fn content_visibility_has_no_score_band_weakness_clause() {
let i18n = I18n::new("de").expect("de locale");
assert_eq!(
text(&i18n, "content_visibility", 40, ""),
text(&i18n, "content_visibility", 90, "")
);
assert_ne!(
text(&i18n, "performance", 40, ""),
text(&i18n, "performance", 90, "")
);
}
#[test]
fn module_customer_context_is_localized() {
let de = I18n::new("de").expect("de locale");
let en = I18n::new("en").expect("en locale");
assert_ne!(
text(&de, "performance", 60, ""),
text(&en, "performance", 60, "")
);
}
#[test]
fn module_customer_context_excludes_caller_interpretation() {
let i18n = I18n::new("de").expect("de locale");
let sentinel = "XZ_SENTINEL_INTERPRETATION_42";
let out = text(&i18n, "performance", 60, sentinel);
assert!(
!out.contains(sentinel),
"customer passage must not echo the technical interpretation"
);
assert!(
out.contains("Besucher"),
"expected the plain performance customer text, got: {out}"
);
}
#[cfg(test)]
mod journey_label_tests {
use super::super::accessibility::journey_label;
#[test]
fn internal_journey_ids_are_not_printed_verbatim() {
assert_eq!(journey_label("tab_walk", false), "Tab-Durchlauf");
assert_eq!(journey_label("disclosure_0", false), "Aufklapp-Menü 1");
assert_eq!(journey_label("skip_link_2", true), "Skip link 3");
}
#[test]
fn unknown_journey_id_falls_back_to_the_raw_id() {
assert_eq!(journey_label("something_new_7", false), "something_new_7");
}
}