test: Created snapshot tests for all Radarr UI modules

This commit is contained in:
Dark-Alex-17 committed 2025-12-15 20:17:09 -07:00
1 parent 7084ca1be2
commit 316ed64315
273 files changed
+8859 -2031

No files matched your search

+4 -1
View File
@@ -1,6 +1,9 @@
use std::ops::Sub;
#[cfg(not(test))]
use chrono::Utc;
#[cfg(test)]
use crate::ui::ui_test_utils::test_utils::Utc;
use ratatui::layout::Layout;
use ratatui::style::Style;
use ratatui::text::{Span, Text};
@@ -125,7 +128,7 @@ pub(super) fn draw_queued_events(f: &mut Frame<'_>, app: &mut App<'_>, area: Rec
};
let duration = if event.duration.is_some() {
&event.duration.as_ref().unwrap()[..8]
event.duration.as_ref().map_or("", |it| &it[..8])
} else {
""
};
@@ -0,0 +1,48 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Log Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│2025-12-15 16:14:45 UTC|INFO|DownloadDecisionMaker|Processing 545 releases │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,44 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Queued Events ────────────────────────────────────────────────────────────────────────────────╮
│Trigger Status Name Queued Started Duration │
│manual completed Refresh Monitored Downlo 4 minutes ago 4 minutes ago 00:03:03 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Name Interval Last Execution Last Duration Next Execution │
│=> Backup 1 hour now 00:00:17 59 minutes │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ ╭────────────────────── Start Task ───────────────────────╮ │
│ │ Do you want to manually start this task: Backup? │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │╭────────────────────────────╮╭───────────────────────────╮│ │
│ ││ Yes ││ No ││ │
│ │╰────────────────────────────╯╰───────────────────────────╯│ │
│ ╰───────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Name Interval Last Execution Last Duration Next Execution │
│=> Backup 1 hour now 00:00:17 59 minutes │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Updates ───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│The latest version of Radarr is already installed │
│ │
│4.3.2.1 - 2023-04-15 02:02:53 UTC (Currently Installed) │
│--------------------------------------------------------------------------------------------------------------------------│
│New: │
│ * Cool new thing │
│Fixed: │
│ * Some bugs killed │
│ │
│ │
│3.2.1.0 - 2023-04-15 02:02:53 UTC (Previously Installed) │
│--------------------------------------------------------------------------------------------------------------------------│
│New: │
│ * Cool new thing (old) │
│ * Other cool new thing (old) │
│ │
│ │
│2.1.0 - 2023-04-15 02:02:53 UTC │
│--------------------------------------------------------------------------------------------------------------------------│
│Fixed: │
│ * Killed bug 1 │
│ * Fixed bug 2 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Log Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│2025-12-15 16:14:45 UTC|INFO|DownloadDecisionMaker|Processing 545 releases │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,44 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Queued Events ────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -1,30 +0,0 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Tasks ───────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────╯
@@ -1,30 +0,0 @@
---
source: src/ui/radarr_ui/system/system_details_ui_tests.rs
expression: output
---
╭ Log Details ─────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/radarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Last Duration Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 00:00:17 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│2025-12-15 16:14:45 UTC|INFO|DownloadDecisionMaker|Processing 545 releases │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/radarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/radarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│ ││ │
│ ││ │
│ Loading ... ││ Loading ... │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/radarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│ ││ │
│ ││ │
│ Loading ... ││ Loading ... │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│2025-12-15 16:14:45 UTC|INFO|DownloadDecisionMaker|Processing 545 releases │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,54 @@
---
source: src/ui/radarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ────────────────────────────────────────────────────────────────────────╮╭ Queued Events ───────────────────────────────────────────────────────────────╮
│Name Interval Last Execution Last Duration Next Execution ││Trigger Status Name Queued Started Duration │
│Backup 1 hour now 00:00:17 59 minutes ││manual completed Refresh Monitored D 4 minutes ago 4 minutes a 00:03:03 │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────────────────────────────────────────╯
╭ Logs ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -1,34 +0,0 @@
---
source: src/ui/radarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────╮╭ Queued Events ─────────────────────────────────────────╮
│ ││ │
│ ││ │
│ Loading ... ││ Loading ... │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰──────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────╯
╭ Logs ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -1,34 +0,0 @@
---
source: src/ui/radarr_ui/system/system_ui_tests.rs
expression: output
---
╭ Tasks ─────────────────────────────────────────────────╮╭ Queued Events ─────────────────────────────────────────╮
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰──────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────╯
╭ Logs ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -9,7 +9,7 @@ mod tests {
use crate::ui::DrawUi;
use crate::ui::radarr_ui::system::system_details_ui::SystemDetailsUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
use crate::ui::ui_test_utils::test_utils::{TerminalSize, render_to_string_with_app};
#[test]
fn test_system_details_ui_accepts() {
@@ -22,36 +22,67 @@ mod tests {
});
}
#[test]
fn test_system_details_ui_renders_loading_tasks() {
let mut app = App::test_default();
app.is_loading = true;
app.push_navigation_stack(ActiveRadarrBlock::SystemTasks.into());
mod snapshot_tests {
use rstest::rstest;
use super::*;
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
#[rstest]
fn test_system_details_ui_renders_tasks(
#[values(
ActiveRadarrBlock::SystemLogs,
ActiveRadarrBlock::SystemQueuedEvents,
ActiveRadarrBlock::SystemTasks,
ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
ActiveRadarrBlock::SystemUpdates,
)] active_radarr_block: ActiveRadarrBlock
) {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(active_radarr_block.into());
insta::assert_snapshot!(output);
}
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
#[test]
fn test_system_details_ui_renders_logs() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::SystemLogs.into());
app.data.radarr_data.logs.set_items(vec![
"2023-01-01T12:00:00Z | Info | Test log message 1"
.to_owned()
.into(),
"2023-01-01T12:01:00Z | Warn | Test warning message"
.to_owned()
.into(),
]);
insta::assert_snapshot!(active_radarr_block.to_string(), output);
}
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
#[test]
fn test_system_details_ui_renders_tasks_loading() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.push_navigation_stack(ActiveRadarrBlock::SystemTasks.into());
insta::assert_snapshot!(output);
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_system_details_ui_renders_queued_events_loading() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.push_navigation_stack(ActiveRadarrBlock::SystemQueuedEvents.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_system_details_ui_renders_logs_loading() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.push_navigation_stack(ActiveRadarrBlock::SystemLogs.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemDetailsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
}
}
+69 -19
View File
@@ -8,7 +8,7 @@ mod tests {
};
use crate::ui::DrawUi;
use crate::ui::radarr_ui::system::SystemUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
use crate::ui::ui_test_utils::test_utils::{TerminalSize, render_to_string_with_app};
#[test]
fn test_system_ui_accepts() {
@@ -25,28 +25,78 @@ mod tests {
});
}
#[test]
fn test_system_ui_renders_loading_state() {
let mut app = App::test_default();
app.is_loading = true;
app.push_navigation_stack(ActiveRadarrBlock::System.into());
mod snapshot_tests {
use super::*;
use crate::models::stateful_list::StatefulList;
use crate::models::stateful_table::StatefulTable;
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
#[test]
fn test_radarr_ui_renders_system_tab_loading() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::System.into());
app.is_loading = true;
insta::assert_snapshot!(output);
}
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
#[test]
fn test_system_ui_renders_system_menu() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::System.into());
insta::assert_snapshot!(output);
}
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
#[test]
fn test_radarr_ui_renders_system_tab_loading_logs() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveRadarrBlock::System.into());
app.data.radarr_data.logs = StatefulList::default();
insta::assert_snapshot!(output);
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_radarr_ui_renders_system_tab_loading_events_and_tasks() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveRadarrBlock::System.into());
app.is_loading = true;
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_radarr_ui_renders_system_tab() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveRadarrBlock::System.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_radarr_ui_renders_system_tab_empty() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveRadarrBlock::System.into());
{
let radarr_data = &mut app.data.radarr_data;
radarr_data.logs = StatefulList::default();
radarr_data.tasks = StatefulTable::default();
radarr_data.queued_events = StatefulTable::default();
}
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
}
}