use super::super::{Column, render};
use crate::paint_probe::frame::{Window, press};
use crate::test_support::window::{click, seated, wall};
use crate::ui::{Enrolling, Model, chat, composer, roster};
fn phone() -> Window {
Window::sized(400.0, 800.0)
}
#[test]
fn the_narrow_window_paints_one_column_and_a_bar_naming_both() {
let mut model = seated();
let shown = phone().text(|ctx| render(ctx, &mut model));
for word in [roster::HEADING, chat::HEADING] {
assert!(shown.contains(word), "the bar names {word:?}:\n{shown}");
}
assert!(
shown.contains("port it"),
"the conversation column is the one on the glass:\n{shown}"
);
assert!(
!shown.contains(&roster::line(&wall("home"))),
"and the roster is not beside it:\n{shown}"
);
}
#[test]
fn a_gesture_on_the_bar_brings_that_column_to_the_glass() {
let mut model = seated();
let window = phone();
click(&window, roster::HEADING, |ctx| render(ctx, &mut model));
assert_eq!(model.column, Column::Engines);
let shown = window.text(|ctx| render(ctx, &mut model));
assert!(
shown.contains(&roster::line(&wall("home"))),
"the engines column is on the glass:\n{shown}"
);
assert!(
!shown.contains("port it"),
"and the conversation is not:\n{shown}"
);
}
#[test]
fn the_composer_stands_with_its_conversation_and_nowhere_else() {
let mut model = seated();
let window = phone();
assert!(
window
.text(|ctx| render(ctx, &mut model))
.contains(composer::SEND),
"the box is under the conversation"
);
model.column = Column::Engines;
assert!(
!window
.text(|ctx| render(ctx, &mut model))
.contains(composer::SEND),
"and not under the list"
);
}
#[test]
fn a_covering_pane_takes_the_bar_with_the_columns_and_its_close_brings_it_back() {
let aim = seated()
.aim
.unwrap_or_else(|| panic!("the fixture is aimed"));
let mut model = Model {
enroll: Some(Enrolling::at(aim)),
..seated()
};
let window = phone();
let covered = window.text(|ctx| render(ctx, &mut model));
assert!(
covered.contains(crate::ui::enroll::HEADING),
"the pane covers the window:\n{covered}"
);
assert!(
!covered.contains(roster::HEADING),
"and the bar is not standing under it:\n{covered}"
);
click(&window, crate::ui::enroll::CLOSE, |ctx| {
render(ctx, &mut model);
});
let back = window.text(|ctx| render(ctx, &mut model));
assert!(back.contains(roster::HEADING), "the bar is back:\n{back}");
}
#[test]
fn the_side_keys_step_the_column_and_stop_at_the_ends() {
let mut model = seated();
let window = phone();
for (key, column) in [
(egui::Key::ArrowLeft, Column::Engines),
(egui::Key::ArrowLeft, Column::Engines),
(egui::Key::ArrowRight, Column::Conversation),
(egui::Key::ArrowRight, Column::Conversation),
] {
window.frame(vec![press(key)], |ctx| render(ctx, &mut model));
assert_eq!(model.column, column, "after {key:?}");
}
}
#[test]
fn an_arrow_walks_the_one_list_in_the_narrow_shape_too() {
let mut model = Model {
column: Column::Engines,
conversation: None,
..seated()
};
phone().frame(vec![press(egui::Key::ArrowDown)], |ctx| {
render(ctx, &mut model);
});
assert_eq!(
model.conversation,
Some("20260830T051200Z-a1b2".to_owned()),
"the walk landed on the aimed wall's first conversation"
);
}