use super::idiom::{head, prose, result, with, working};
use crate::paint_probe::frame::Window;
use crate::paint_probe::seen_of;
use crate::test_support::window::{click, numbered, said};
use crate::ui::Model;
use crate::ui::theme::glyph;
fn runs(window: &Window, model: &mut Model) -> Vec<String> {
let output = window.frame(Vec::new(), |ctx| crate::ui::render(ctx, model));
seen_of(&output).into_iter().map(|run| run.text).collect()
}
fn whole(seen: &[String]) -> bool {
seen.iter().any(|t| t.contains("line 003"))
}
#[test]
fn a_toggle_is_remembered_per_conversation() {
let mut model = with(vec![
said("op", "port it"),
working(),
result(&numbered(12), false),
prose("the seam is real"),
]);
let first = model.conversation.clone();
let window = Window::sized(1400.0, 900.0);
runs(&window, &mut model);
click(&window, &head(false, 1, 1), |ctx| {
crate::ui::render(ctx, &mut model);
});
let call = format!("{} read(src/ui.rs)", glyph::DONE);
click(&window, &call, |ctx| {
crate::ui::render(ctx, &mut model);
});
assert!(whole(&runs(&window, &mut model)), "opened in the first");
model.conversation = Some("20260830T051200Z-b2c3".to_owned());
let second = runs(&window, &mut model);
assert!(second.contains(&head(false, 1, 1)), "{second:?}");
click(&window, &head(false, 1, 1), |ctx| {
crate::ui::render(ctx, &mut model);
});
let compact = runs(&window, &mut model);
assert!(compact.contains(&call), "{compact:?}");
assert!(!whole(&compact), "in its stage: {compact:?}");
model.conversation = first;
let back = runs(&window, &mut model);
assert!(back.contains(&head(true, 1, 1)), "{back:?}");
assert!(whole(&back), "still open: {back:?}");
}