Files
managarr/src/ui/ui_tests.rs
T
Dark-Alex-17 ee6035c75d test(readarr): cover the top level UI dispatch for Readarr
The top level ui() dispatch had no Readarr coverage, so removing its match arm let every test in the suite pass while the Readarr views rendered nothing at all.

Mirrors the Radarr set, which is the most complete of the three: it is the only one that also covers the notification failure popup.
2026-09-08 16:18:00 -06:00

267 lines
7.8 KiB
Rust

#[cfg(test)]
mod snapshot_tests {
use crate::app::App;
use crate::handlers::populate_keymapping_table;
use crate::models::servarr_data::Notification;
use crate::models::servarr_data::lidarr::lidarr_data::ActiveLidarrBlock;
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
use crate::models::servarr_data::readarr::readarr_data::ActiveReadarrBlock;
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
use crate::ui;
use crate::ui::ui_test_utils::test_utils::{TerminalSize, render_to_string_with_app};
#[test]
fn test_radarr_ui_renders_library_tab() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveRadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_radarr_ui_renders_library_tab_with_error() {
let mut app = App::test_default_fully_populated();
app.error = "Some error".into();
app.push_navigation_stack(ActiveRadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_radarr_ui_renders_library_tab_error_popup() {
let mut app = App::test_default_fully_populated();
populate_keymapping_table(&mut app);
app.push_navigation_stack(ActiveRadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_radarr_ui_renders_notification_success_popup() {
let mut app = App::test_default_fully_populated();
app.notification = Some(Notification::new(
"Download Result".to_owned(),
"Download request sent successfully".to_owned(),
true,
));
app.push_navigation_stack(ActiveRadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_radarr_ui_renders_notification_failure_popup() {
let mut app = App::test_default_fully_populated();
app.notification = Some(Notification::new(
"Download Failed".to_owned(),
"Request failed. Received 500 response code".to_owned(),
false,
));
app.push_navigation_stack(ActiveRadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_sonarr_ui_renders_library_tab() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_sonarr_ui_renders_library_tab_with_error() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::default().into());
app.error = "Some error".into();
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_sonarr_ui_renders_library_tab_error_popup() {
let mut app = App::test_default_fully_populated();
populate_keymapping_table(&mut app);
app.push_navigation_stack(ActiveSonarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_sonarr_ui_renders_notification_success_popup() {
let mut app = App::test_default_fully_populated();
app.notification = Some(Notification::new(
"Download Result".to_owned(),
"Download request sent successfully".to_owned(),
true,
));
app.push_navigation_stack(ActiveSonarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_lidarr_ui_renders_library_tab() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveLidarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_lidarr_ui_renders_library_tab_with_error() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveLidarrBlock::default().into());
app.error = "Some error".into();
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_lidarr_ui_renders_notification_success_popup() {
let mut app = App::test_default_fully_populated();
app.notification = Some(Notification::new(
"Download Result".to_owned(),
"Download request sent successfully".to_owned(),
true,
));
app.push_navigation_stack(ActiveLidarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_lidarr_ui_renders_library_tab_error_popup() {
let mut app = App::test_default_fully_populated();
populate_keymapping_table(&mut app);
app.push_navigation_stack(ActiveLidarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_readarr_ui_renders_library_tab() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveReadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_readarr_ui_renders_library_tab_with_error() {
let mut app = App::test_default_fully_populated();
app.error = "Some error".into();
app.push_navigation_stack(ActiveReadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_readarr_ui_renders_library_tab_error_popup() {
let mut app = App::test_default_fully_populated();
populate_keymapping_table(&mut app);
app.push_navigation_stack(ActiveReadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_readarr_ui_renders_notification_success_popup() {
let mut app = App::test_default_fully_populated();
app.notification = Some(Notification::new(
"Download Result".to_owned(),
"Download request sent successfully".to_owned(),
true,
));
app.push_navigation_stack(ActiveReadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
#[test]
fn test_readarr_ui_renders_notification_failure_popup() {
let mut app = App::test_default_fully_populated();
app.notification = Some(Notification::new(
"Download Failed".to_owned(),
"Request failed. Received 500 response code".to_owned(),
false,
));
app.push_navigation_stack(ActiveReadarrBlock::default().into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
ui(f, app);
});
insta::assert_snapshot!(output);
}
}