use super::fixture::{World, world};
use super::screen::{Screen, click};
use crate::keymap::CenterTab;
#[test]
fn the_provider_roster_has_one_seat_and_the_config_pane_references_it() {
let mut world = world();
let ws = world.ws.clone();
world.model.focus_agent(&ws, "c-1");
let screen = Screen::new();
screen.idle(&mut world);
crate::shell::center::focus(&world.model, &mut world.state, CenterTab::Config);
let rows = world.state.wall.brazen.providers.len();
assert!(
rows > 0,
"the linked brazen answers the pane with its built-in table, or this \
proves nothing"
);
let config = screen.text(&mut world);
assert!(
config.contains(&format!(
"{rows} provider rows are effective in this workspace"
)),
"the config pane states the effect the file has, counted from brazen's \
own answer:\n{config}"
);
for said in [
"no credential needed",
"not signed in",
"signed in",
"api-key provider — set the key in Config",
] {
assert!(
!config.contains(said),
"the roster's own words must not paint in the config pane: {said:?}\n{config}"
);
}
crate::shell::center::focus(&world.model, &mut world.state, CenterTab::Login);
let login = screen.text(&mut world);
assert!(
login.contains("no credential needed") || login.contains("signed in"),
"and the Login tab is where a row states its credential:\n{login}"
);
}
#[test]
fn the_config_panes_roster_reference_focuses_the_login_tab() {
let mut world = world();
let ws = world.ws.clone();
world.model.focus_agent(&ws, "c-1");
let screen = Screen::new();
screen.idle(&mut world);
screen.release(&mut world);
crate::shell::center::focus(&world.model, &mut world.state, CenterTab::Config);
let shapes = screen.shapes(&mut world, Vec::new());
let seat = below_the_heading(&shapes, "Login").expect("the config pane paints its route");
click(&screen, &mut world, seat);
assert_eq!(
world.state.center,
CenterTab::Login,
"the config pane's Login control spends the one tab-focus gesture"
);
}
fn below_the_heading(shapes: &[egui::epaint::ClippedShape], text: &str) -> Option<egui::Pos2> {
let mut painted = Vec::new();
for clipped in shapes {
crate::paint_probe::collect(&clipped.shape, &mut painted);
}
let heading = painted
.iter()
.find(|(said, _)| said == "brazen config.toml")?
.1
.top();
painted
.iter()
.find(|(said, rect)| said == text && rect.top() > heading)
.map(|(_, rect)| rect.center())
}
#[test]
fn the_live_activity_class_has_one_seat_and_the_strip_carries_only_what_it_adds() {
let (_, _, says) = crate::theme::flight_badge(crate::nav::convs::Flight::Inference);
let painted = in_flight_frame();
let runs: Vec<&String> = painted.iter().map(|(text, _)| text).collect();
assert_eq!(
runs.iter().filter(|run| run.contains(says)).count(),
1,
"the class's words paint once on this surface, not once per seat:\n{runs:#?}"
);
let strip = runs
.iter()
.find(|run| run.contains("chars streamed"))
.expect("the in-flight strip reaches the paint layer");
assert!(
!strip.contains(says),
"the strip carries the characteristics, never the sentence: {strip}"
);
for name in ["hello", "c-1"] {
assert!(
!strip.contains(name),
"nor the conversation's own name, which the pane's heading two lines \
above already carries: {strip}"
);
}
}
fn in_flight_frame() -> Vec<crate::paint_probe::Painted> {
let (lernie, bl, bz) = (
crate::cli_outbound::Cli::new("/yog-absent-lernie"),
crate::cli_outbound::Cli::new("/yog-absent-bl"),
crate::cli_outbound::Cli::new("/yog-absent-bz"),
);
let mut world = super::inbox_composer::quick(world());
let ws = world.ws.clone();
world.model.focus_agent(&ws, "c-1");
let _lock = std::fs::File::open(ws.join("inbox/c-1")).expect("the inbox dir");
let _writer = std::fs::OpenOptions::new()
.append(true)
.open(ws.join("steps/c-1/001/response.json"))
.expect("the step's response record");
super::inbox_composer::converge_ws(&mut world);
let ctx = egui::Context::default();
let frame = |world: &mut World| {
ctx.run(super::input(), |ctx| {
crate::shell::render(ctx, &mut world.model, &mut world.state, &lernie, &bl, &bz);
})
};
let _ = frame(&mut world);
let _ = frame(&mut world);
world.drain(&mut |world| {
let _ = frame(world);
});
for _ in 0..4 {
let _ = frame(&mut world);
}
crate::paint_probe::painted_of(&frame(&mut world))
}