use super::{HEADING, WORD};
use crate::paint_probe::frame::{Window, press};
use crate::test_support::window::{click, escape, painted, seated};
use crate::ui::Model;
fn ctrl_x(window: &Window, model: &mut Model) {
window.frame(
vec![egui::Event::Key {
key: egui::Key::X,
physical_key: None,
pressed: true,
repeat: false,
modifiers: egui::Modifiers::COMMAND,
}],
|ctx| crate::ui::render(ctx, model),
);
}
#[test]
fn ctrl_x_toggles_it_and_the_word_opens_it() {
let mut model = seated();
let window = Window::new();
ctrl_x(&window, &mut model);
assert!(model.switching);
window.focus(egui::Id::new(crate::ui::keys::BOX_ID));
ctrl_x(&window, &mut model);
assert!(!model.switching);
assert!(crate::ui::slash::fire(&mut model, WORD, ""));
assert!(model.switching);
}
#[test]
fn the_roster_stands_in_it() {
let mut model = seated();
model.switching = true;
let text = painted(&mut model);
for word in [HEADING, "home", "port the paint probe"] {
assert!(text.contains(word), "{word:?}:\n{text}");
}
assert!(!text.contains(crate::ui::composer::HINT), "{text}");
}
#[test]
fn walking_keeps_it_open_and_choosing_closes_it() {
let mut model = seated();
model.switching = true;
let window = Window::new();
window.frame(vec![press(egui::Key::ArrowDown)], |ctx| {
crate::ui::render(ctx, &mut model);
});
assert!(model.switching, "the walk keeps it");
window.frame(vec![press(egui::Key::Enter)], |ctx| {
crate::ui::render(ctx, &mut model);
});
assert!(!model.switching, "Enter on the selection chooses");
let mut model = seated();
model.switching = true;
let label = crate::ui::convs::headline(&model.convs[0]);
click(&window, &label, |ctx| crate::ui::render(ctx, &mut model));
assert!(!model.switching, "a click chooses");
assert_eq!(model.conversation.as_deref(), Some("20260830T051200Z-a1b2"));
let mut model = seated();
model.switching = true;
escape(&window, |ctx| crate::ui::render(ctx, &mut model));
assert!(!model.switching, "Esc leaves");
}
#[test]
fn the_plus_closes_it_on_the_way_to_the_box() {
let mut model = seated();
model.switching = true;
let window = Window::new();
click(&window, "+", |ctx| crate::ui::render(ctx, &mut model));
assert!(!model.switching);
assert_eq!(model.conversation, None);
}
#[test]
fn the_walk_brings_the_standing_engine_into_view() {
let mut model = seated();
model.switching = true;
model.standing = Some("(this box's own engine)".to_owned());
model.reveal = true;
let text = painted(&mut model);
assert!(text.contains("(this box's own engine)"), "{text}");
}