use super::fixtures::{self, flock_of, sample};
use super::testing::draw_to;
use crate::lookout::app::{App, KeyPress, Msg};
fn watching_build_01(mut app: App) -> App {
app.set_remote_host("build-01");
app
}
#[test]
fn a_host_dashboard_names_the_host_and_draws_no_strip_and_no_feed() {
let app = watching_build_01(fixtures::with_host(sample(), flock_of(3, 0)));
let frame = draw_to(&app, 160, 46);
let title = frame.lines().next().unwrap_or_default();
assert!(title.contains("shep lookout build-01"), "{frame}");
assert!(!title.contains("/home/ada/.shep"), "{frame}");
assert!(!frame.contains("host load"), "{frame}");
assert!(!frame.contains("unsupported"), "{frame}");
assert!(!frame.contains("out then err"), "{frame}");
assert!(frame.contains("not available over --host"), "{frame}");
}
#[test]
fn a_local_dashboard_still_draws_its_strip() {
let app = fixtures::with_host(sample(), flock_of(3, 0));
let frame = draw_to(&app, 160, 46);
let title = frame.lines().next().unwrap_or_default();
assert!(frame.contains("host load"), "{frame}");
assert!(title.contains("shep lookout /home/ada/.shep"), "{frame}");
}
#[test]
fn the_full_screen_bleats_pane_says_it_is_not_available_over_a_host() {
let app = watching_build_01(fixtures::bleats_pane_with_lines(5));
let frame = draw_to(&app, 120, 30);
assert!(frame.contains("not available over --host"), "{frame}");
assert!(!frame.contains("line-0"), "{frame}");
}
#[test]
fn a_sheep_panes_feed_column_says_it_is_not_available_over_a_host() {
let mut app = watching_build_01(fixtures::app_with(flock_of(2, 0), fixtures::plain()));
app.update(Msg::Key(KeyPress::Confirm));
let frame = draw_to(&app, 160, 46);
assert!(frame.contains("not available over --host"), "{frame}");
assert!(!frame.contains("out then err"), "{frame}");
}
#[test]
fn the_full_screen_pane_over_a_host_keeps_to_the_rows_it_is_given() {
let app = watching_build_01(fixtures::bleats_pane_with_lines(5));
for rows in 0..=2 {
let lines = crate::lookout::view::bleats_full::draw_lines(&app, 80, rows);
assert_eq!(lines.len(), rows.min(2), "{rows} rows");
}
}