use super::fixture::{world, world_empty};
use super::screen::{Screen, command_shift, press};
use crate::keymap::CenterTab;
use crate::names::DEFAULT_NAME;
#[test]
fn the_empty_world_reaches_a_populated_roster_from_inside_the_box() {
let mut world = world_empty();
let screen = Screen::new();
assert!(
screen.idle(&mut world),
"the empty world opens with the keyboard in the bootstrap box"
);
assert!(
world.model.focused_workspace().is_none(),
"and with nothing focused, or this is not the state under test"
);
screen.frame(&mut world, vec![press(egui::Key::Num3, command_shift())]);
assert_eq!(
world.state.center,
CenterTab::Login,
"Ctrl+Shift+3 focuses the Login tab without the box letting go first"
);
let painted = screen.text(&mut world);
let rows = world.state.wall.login.rows.clone();
assert!(
!rows.is_empty(),
"the roster is the newborn wall's, and brazen's shipped table is not empty"
);
for row in &rows {
assert!(
painted.contains(&row.name) && painted.contains(&row.fact),
"every row reaches the glass with its credential fact:\n{painted}"
);
}
assert!(
!painted.contains("brazen listed no provider rows"),
"the empty-roster sentence is the answer to a different question:\n{painted}"
);
assert!(
painted.contains(DEFAULT_NAME),
"and the pane names the sphere a sign-in here lands in:\n{painted}"
);
}
#[test]
fn the_roster_names_whichever_sphere_the_window_is_pointed_at() {
let mut world = world();
let screen = Screen::new();
screen.idle(&mut world);
crate::shell::center::focus(&world.model, &mut world.state, CenterTab::Login);
let painted = screen.text(&mut world);
let leaf = world
.ws
.file_name()
.expect("the fixture workspace has a leaf")
.to_string_lossy()
.into_owned();
assert_ne!(leaf, DEFAULT_NAME, "the fixture must not be named `home`");
assert!(
painted.contains(&format!("belong to the workspace {leaf}")),
"the focused sphere is the one named:\n{painted}"
);
}
#[test]
fn the_newborn_rosters_wall_is_the_one_the_first_message_will_use() {
let mut world = world_empty();
let screen = Screen::new();
screen.idle(&mut world);
let holder = &world.state.wall.login;
assert_eq!(
holder.workspace.as_deref(),
Some(world.model.start_workspace().as_path()),
"the roster belongs to the sphere §3.4 says the next Enter lands in"
);
let wall = holder
.wall
.iter()
.find(|(key, _)| key == crate::world::wall::YOG_WALL)
.map(|(_, value)| std::path::PathBuf::from(value))
.expect("the spawn layer names the wall");
assert_eq!(
wall.file_name().map(std::ffi::OsStr::to_string_lossy),
Some(DEFAULT_NAME.into()),
"and it is `<world>/walls/home` — the name IS the wall (§16.2), so the \
credential written here is the one the founded `home` reads"
);
}