use super::{chapter, guide, Place}; use crate::render::{escape, Renderer, StatusFacts, StatusSegment, Voice}; use luxe_core::guided_review::{ ChapterReading, GuidedReview, ItemNote, ReviewBrief, ReviewFile, TurnProvenance, }; /// Prose marked so a test can tell it went through the markdown hook, and code by language. struct Marked; impl Renderer for Marked { fn markdown(&self, text: &str, _voice: Voice) -> String { format!("
md:{}
", escape(text)) } fn tool_glyph(&self, _tool: &str) -> String { String::new() } fn status(&self, _facts: &StatusFacts) -> Vecmd:Clients see a new frame
nothing here needs you
"), "{quiet}"); } /// A chapter the host said nothing about is one to read. /// /// The break this catches: a missing reading folding the chapter away, so a stale or partial /// frame hides work. #[test] fn a_chapter_without_a_reading_is_one_to_read() { let (review, _) = captured(); let open = section(&guide_of(&review, &[]), &review, 2); assert!(open.contains("rv-files") && !open.contains("rv-reason")); } /// The summary leads: its intent, then its claims as a list. /// /// The break this catches: the brief left out, or its claims run together as one paragraph. #[test] fn the_summary_leads_the_guide() { let (mut review, reading) = captured(); let account = vec!["Adds a frame".into(), "Pins it".into()]; review.brief = Some(ReviewBrief { intent: "Let a phone join".into(), account }); let html = guide_of(&review, &reading); let brief = "md:Let a phone join
md:Adds a \ frame
md:Pins it
crates/luxe-cli/src/cli.rs
").count(), 1); let path = html.find("rv-file\">crates/luxe-cli/src/cli.rs").expect("the path"); let hunks: VecReads the flag
").expect("the note"); let hunks: Vecrun_rpc
").expect("the symbol"); assert!(named < html.find("The new icon
").expect("the note"); let why = html.find("isn't text").or_else(|| html.find("isn't text")); assert!(why.is_some_and(|why| note < why), "{html}"); } /// A file with no lines to count says what changed in the guide's row instead. /// /// The break this catches: a binary file's row with no figures and no words. #[test] fn a_file_without_lines_says_what_changed() { let review = with_a_binary_file(); let row = section(&guide_of(&review, &[]), &review, 2); assert!(row.contains("binary, 4 KiB"), "{row}"); } /// An item whose file the app didn't send is left out rather than failing the chapter. /// /// The break this catches: one missing file blanking the whole chapter. #[test] fn an_item_without_its_file_is_left_out() { let (review, _) = captured(); let place = Place { number: 1, total: 3, walked: false }; let html = chapter(&Marked, &review.chapters[0], &[], &place, None, &[]); assert!(html.contains(&escape(&review.chapters[0].title)) && !html.contains("hunk")); }