test: Created snapshot tests for all Radarr UI modules

This commit is contained in:
2025-12-15 20:17:09 -07:00
parent 7084ca1be2
commit 316ed64315
273 changed files with 8859 additions and 2031 deletions
@@ -21,6 +21,8 @@ mod tests {
}
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use super::*;
#[test]
@@ -30,7 +32,7 @@ mod tests {
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into());
app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default());
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
AddSeriesUi::draw(f, app, f.area());
});
@@ -43,7 +45,7 @@ mod tests {
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into());
app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default());
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
AddSeriesUi::draw(f, app, f.area());
});
@@ -25,6 +25,8 @@ mod tests {
}
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use super::*;
#[test]
@@ -40,7 +42,7 @@ mod tests {
app.data.sonarr_data.selected_block =
BlockSelectionState::new(DELETE_SERIES_SELECTION_BLOCKS);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
DeleteSeriesUi::draw(f, app, f.area());
});
@@ -27,6 +27,8 @@ mod tests {
}
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use super::*;
#[test]
@@ -48,7 +50,7 @@ mod tests {
app.data.sonarr_data.selected_block = BlockSelectionState::new(EDIT_SERIES_SELECTION_BLOCKS);
app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal::from(&app.data.sonarr_data));
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EditSeriesUi::draw(f, app, f.area());
});
@@ -25,6 +25,8 @@ mod tests {
}
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use super::*;
#[test]
@@ -41,7 +43,7 @@ mod tests {
..Series::default()
}]);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EpisodeDetailsUi::draw(f, app, f.area());
});
@@ -67,7 +69,7 @@ mod tests {
season_details_modal.episode_details_modal = Some(EpisodeDetailsModal::default());
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EpisodeDetailsUi::draw(f, app, f.area());
});
@@ -95,7 +97,7 @@ mod tests {
season_details_modal.episode_details_modal = Some(episode_details_modal);
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EpisodeDetailsUi::draw(f, app, f.area());
});
@@ -123,7 +125,7 @@ mod tests {
season_details_modal.episode_details_modal = Some(episode_details_modal);
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EpisodeDetailsUi::draw(f, app, f.area());
});
+76 -3
View File
@@ -254,7 +254,7 @@ mod tests {
use crate::models::stateful_table::StatefulTable;
use crate::ui::DrawUi;
use crate::ui::sonarr_ui::library::LibraryUi;
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_library_ui_renders_loading_state() {
@@ -262,7 +262,7 @@ mod tests {
app.is_loading = true;
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
LibraryUi::draw(f, app, f.area());
});
@@ -275,7 +275,80 @@ mod tests {
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.data.sonarr_data.series = StatefulTable::default();
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
LibraryUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_library_ui_renders_with_series() {
use crate::models::sonarr_models::{Series, SeriesStatus, SeriesType};
use crate::models::stateful_table::StatefulTable;
use bimap::BiMap;
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
// Set up quality profile and language profile maps
let mut quality_profile_map = BiMap::new();
quality_profile_map.insert(1, "HD-1080p".to_owned());
quality_profile_map.insert(2, "Any".to_owned());
app.data.sonarr_data.quality_profile_map = quality_profile_map;
let mut language_profiles_map = BiMap::new();
language_profiles_map.insert(1, "English".to_owned());
language_profiles_map.insert(2, "Any".to_owned());
app.data.sonarr_data.language_profiles_map = language_profiles_map;
// Create series with data
let mut series_table = StatefulTable::default();
series_table.set_items(vec![
Series {
id: 1,
title: "Breaking Bad".into(),
year: 2008,
network: Some("AMC".to_owned()),
status: SeriesStatus::Ended,
monitored: true,
series_type: SeriesType::Standard,
quality_profile_id: 1,
language_profile_id: 1,
seasons: Some(vec![]),
..Series::default()
},
Series {
id: 2,
title: "The Wire".into(),
year: 2002,
network: Some("HBO".to_owned()),
status: SeriesStatus::Continuing,
monitored: true,
series_type: SeriesType::Standard,
quality_profile_id: 2,
language_profile_id: 1,
seasons: Some(vec![]),
..Series::default()
},
]);
app.data.sonarr_data.series = series_table;
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
LibraryUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_library_ui_renders_update_all_series_prompt() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.push_navigation_stack(ActiveSonarrBlock::UpdateAllSeriesPrompt.into());
app.data.sonarr_data.series = StatefulTable::default();
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
LibraryUi::draw(f, app, f.area());
});
@@ -29,6 +29,8 @@ mod tests {
}
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use super::*;
#[test]
@@ -42,7 +44,7 @@ mod tests {
..Series::default()
}]);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SeasonDetailsUi::draw(f, app, f.area());
});
@@ -59,7 +61,7 @@ mod tests {
..Series::default()
}]);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SeasonDetailsUi::draw(f, app, f.area());
});
@@ -98,7 +100,7 @@ mod tests {
.set_items(vec![SonarrRelease::default()]);
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SeasonDetailsUi::draw(f, app, f.area());
});
@@ -137,7 +139,7 @@ mod tests {
.set_items(vec![SonarrHistoryItem::default()]);
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SeasonDetailsUi::draw(f, app, f.area());
});
@@ -29,6 +29,8 @@ mod tests {
}
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use super::*;
#[test]
@@ -49,7 +51,7 @@ mod tests {
}]);
app.data.sonarr_data.series_history = Some(StatefulTable::default());
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SeriesDetailsUi::draw(f, app, f.area());
});
@@ -2,28 +2,46 @@
source: src/ui/sonarr_ui/library/add_series_ui_tests.rs
expression: output
---
╭──────────────────────────────────── Add Series ────────────────────────────────────╮
│ │
──────────────────────────────────────────────────────────────────────────────────────
╭──────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────── Add Series ─────────────────────────────────────────────────────
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,28 +2,46 @@
source: src/ui/sonarr_ui/library/add_series_ui_tests.rs
expression: output
---
╭──────────────────────────────────── Add Series ────────────────────────────────────╮
│ │
──────────────────────────────────────────────────────────────────────────────────────
╭──────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────── Add Series ─────────────────────────────────────────────────────
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,23 +2,37 @@
source: src/ui/sonarr_ui/library/delete_series_ui_tests.rs
expression: output
---
╭───────────── Delete Series ─────────────╮
│ Do you really want to delete the series: │
│ Test Series? │
│ │
│ ╭───╮ │
│ Delete Series File: │ │ │
│ ╰───╯ │
───╮
│ Add List Exclusion: │
╰───╯
╰───────────────────────────────────────────╯
╭───────────────────── Delete Series ─────────────────────╮
│ Do you really want to delete the series:
Test Series?
│ │
│ │
│ ╭───╮ │
│ Delete Series File: │ │ │
│ ╰───╯ │
│ ╭───╮ │
│ Add List Exclusion: │ │ │
│ ╰───╯ │
│ │
│ │
│ │
│╭────────────────────────────╮╭───────────────────────────╮│
││ Yes ││ No ││
│╰────────────────────────────╯╰───────────────────────────╯│
╰───────────────────────────────────────────────────────────╯
@@ -2,29 +2,47 @@
source: src/ui/sonarr_ui/library/edit_series_ui_tests.rs
expression: output
---
╭─────────────────────────── Edit - Test Series ───────────────────────────╮
│ │
│ │
╭───╮
Monitored: ╰───╯
╭───╮
Season Folder: │
╰───╯
╭───────────────────────────────────╮ │
Quality Profile: ╰───────────────────────────────────╯ │
╭───────────────────────────────────╮ │
Language Profile: │English ▼ │ │
│ ╰───────────────────────────────────╯ │
╭───────────────────────────────────╮ │
Series Type: ╰───────────────────────────────────
│ ╭───────────────────────────────────╮ │
Path: │/tv/test
───────────────────────────────────
│ ╭───────────────────────────────────╮ │
Tags: ╰───────────────────────────────────╯
╰────────────────────────────────────────────────────────────────────────────
╭───────────────────────────────────────── Edit - Test Series ──────────────────────────────────────────╮
╭───╮ │
Monitored: │ │ │
╰───╯ │
╭───╮ │
│ Season Folder: │ │ │
╰───╯ │
╭─────────────────────────────────────────────────
│ Quality Profile: │HD-1080p ▼ │ │
╰─────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────
│ Language Profile: │English ▼ │ │
╰─────────────────────────────────────────────────╯
│ ╭─────────────────────────────────────────────────╮ │
│ Series Type: │Standard ▼ │ │
│ ╰─────────────────────────────────────────────────╯ │
│ ╭─────────────────────────────────────────────────╮ │
│ Path: │/tv/test │ │
│ ╰─────────────────────────────────────────────────╯ │
│ ╭─────────────────────────────────────────────────╮ │
│ Tags: │ │ │
│ ╰─────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
│ │
│╭───────────────────────────────────────────────────╮╭──────────────────────────────────────────────────╮│
││ Save ││ Cancel ││
│╰───────────────────────────────────────────────────╯╰──────────────────────────────────────────────────╯│
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,29 +2,47 @@
source: src/ui/sonarr_ui/library/episode_details_ui_tests.rs
expression: output
---
╭ Episode Details ─────────────────────────────────────────────────────────────────────╮
│ Details │ History │ File │ Manual Search │
────────────────────────────────────────────────────────────────────────────────────────
│ │
╰────────────────────────────────────────────────────────────────────────────────────────╯
╭ Episode Details ───────────────────────────────────────────────────────────────────────────────────────────────────────
│ Details │ History │ File │ Manual Search
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,29 +2,47 @@
source: src/ui/sonarr_ui/library/episode_details_ui_tests.rs
expression: output
---
╭ Episode Details ─────────────────────────────────────────────────────────────────────╮
│ Details │ History │ File │ Manual Search │
────────────────────────────────────────────────────────────────────────────────────────
│ │
╰────────────────────────────────────────────────────────────────────────────────────────╯
╭ Episode Details ───────────────────────────────────────────────────────────────────────────────────────────────────────
│ Details │ History │ File │ Manual Search
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,29 +2,47 @@
source: src/ui/sonarr_ui/library/episode_details_ui_tests.rs
expression: output
---
╭ Episode Details ─────────────────────────────────────────────────────────────────────╮
│ Details │ History │ File │ Manual Search │
────────────────────────────────────────────────────────────────────────────────────────
│ │
│ Loading ...
╰────────────────────────────────────────────────────────────────────────────────────────╯
╭ Episode Details ───────────────────────────────────────────────────────────────────────────────────────────────────────
│ Details │ History │ File │ Manual Search
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ Loading ...
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,4 +2,4 @@
source: src/ui/sonarr_ui/library/library_ui_tests.rs
expression: output
---
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@@ -2,7 +2,7 @@
source: src/ui/sonarr_ui/library/library_ui_tests.rs
expression: output
---
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Loading ...
@@ -0,0 +1,38 @@
---
source: src/ui/sonarr_ui/library/library_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
╭─────────────────── Update All Series ───────────────────╮
│ Do you want to update info and scan your disks for all of │
│ your series? │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│╭────────────────────────────╮╭───────────────────────────╮│
││ Yes ││ No ││
│╰────────────────────────────╯╰───────────────────────────╯│
╰───────────────────────────────────────────────────────────╯
@@ -0,0 +1,8 @@
---
source: src/ui/sonarr_ui/library/library_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Title Year Network Status Rating Type Quality Profile Language Size Monitored Tags
=> Breaking Bad 2008 AMC Ended Standard HD-1080p English 0.00 GB 🏷
The Wire 2002 HBO Continuin Standard Any English 0.00 GB 🏷
@@ -2,30 +2,49 @@
source: src/ui/sonarr_ui/library/season_details_ui_tests.rs
expression: output
---
╭ Season 0 Details ─────────────────────────────────────────────────────────────────────────────╮
│ Episodes │ History │ Manual Search │
─────────────────────────────────────────────────────────────────────────────────────────────────
│ Source Age ⛔ Title Indexer Size Peers Languag Quality│
│=> 0 days 0.0 GB │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
╭ Season 0 Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Episodes │ History │ Manual Search │
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
Source Age Title Indexer Size Peers Language Quality
│=> 0 days 0.0 GB │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,30 +2,49 @@
source: src/ui/sonarr_ui/library/season_details_ui_tests.rs
expression: output
---
╭ Season 0 Details ─────────────────────────────────────────────────────────────────────────────╮
│ Episodes │ History │ Manual Search │
─────────────────────────────────────────────────────────────────────────────────────────────────
Source Title Event Type Language Quality Date
│=> unknown 1970-01-01 00:00:00│
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
╭ Season 0 Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Episodes │ History │ Manual Search
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
Source Title Event Type Language Quality Date
│=> unknown 1970-01-01 00:00:00 UTC │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -2,32 +2,51 @@
source: src/ui/sonarr_ui/library/series_details_ui_tests.rs
expression: output
---
╭ Test Series ───────────────────────────────────────────────────────────────────────────────────────────╮
│Title: Test Series
│Overview:
│Network:
│Status: Continuing
│Genres:
│Rating: 0%
│Year: 0
│Runtime: 0 minutes
│Path:
│╭ Series Details ──────────────────────────────────────────────────────────────────────────────────────╮│
││ Seasons │ History
││────────────────────────────────────────────────────────────────────────────────────────────────────────││
││
││
││
││
││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
│╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯│
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Test Series ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│Title: Test Series
│Overview:
│Network:
│Status: Continuing
│Genres:
│Rating: 0%
│Year: 0
│Runtime: 0 minutes
│Path: │
│Quality Profile: HD-1080p
│Language Profile: English │
│Monitored: No
│╭ Series Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│
││ Seasons │ History ││
││─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
││ ││
│╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯│
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯