test: Wrote snapshot tests for all Sonarr UI

This commit is contained in:
2025-12-16 14:12:10 -07:00
parent e0fcbc71e1
commit 0532d59746
257 changed files with 8089 additions and 1029 deletions
+2 -176
View File
@@ -19,23 +19,6 @@ use crate::models::servarr_models::KeybindingItem;
use crate::models::stateful_table::StatefulTable;
use crate::models::{HorizontallyScrollableText, Route, TabRoute, TabState};
use crate::network::NetworkEvent;
#[cfg(test)]
use {
crate::models::ScrollableText,
crate::models::radarr_models,
crate::models::radarr_models::MinimumAvailability,
crate::models::radarr_models::MovieMonitor,
crate::models::servarr_data::modals::EditIndexerModal,
crate::models::servarr_data::radarr::modals::AddMovieModal,
crate::models::servarr_data::radarr::modals::{
EditCollectionModal, EditMovieModal, MovieDetailsModal,
},
crate::models::stateful_table::SortOption,
crate::network::radarr_network::radarr_network_test_utils::test_utils::*,
chrono::DateTime,
std::fmt::Debug,
strum::IntoEnumIterator,
};
#[cfg(test)]
mod app_tests;
@@ -45,16 +28,6 @@ mod key_binding_tests;
pub mod radarr;
pub mod sonarr;
#[cfg(test)]
macro_rules! sort_option {
($field:ident) => {
SortOption {
name: "Something",
cmp_fn: Some(|a, b| a.$field.cmp(&b.$field)),
}
};
}
pub struct App<'a> {
navigation_stack: Vec<Route>,
network_tx: Option<Sender<NetworkEvent>>,
@@ -287,157 +260,10 @@ impl App<'_> {
}
pub fn test_default_fully_populated() -> Self {
let quality_profile_name = "HD - 1080p".to_owned();
let mut add_movie_modal = AddMovieModal {
tags: "alex".into(),
..AddMovieModal::default()
};
add_movie_modal
.root_folder_list
.set_items(vec![root_folder()]);
add_movie_modal
.monitor_list
.set_items(MovieMonitor::iter().collect());
add_movie_modal
.minimum_availability_list
.set_items(MinimumAvailability::iter().collect());
add_movie_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
let mut add_movie_search_result_table = StatefulTable::default();
add_movie_search_result_table.set_items(vec![add_movie_search_result()]);
add_movie_search_result_table.sorting(vec![sort_option!(tmdb_id)]);
add_movie_search_result_table.search = Some("something".into());
add_movie_search_result_table.filter = Some("something".into());
let mut edit_movie_modal = EditMovieModal {
monitored: Some(true),
path: "/nfs/movies".into(),
tags: "alex".into(),
..EditMovieModal::default()
};
edit_movie_modal
.minimum_availability_list
.set_items(MinimumAvailability::iter().collect());
edit_movie_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
let mut edit_collection_modal = EditCollectionModal {
monitored: Some(true),
path: "/nfs/movies".into(),
search_on_add: Some(true),
..EditCollectionModal::default()
};
edit_collection_modal
.minimum_availability_list
.set_items(MinimumAvailability::iter().collect());
edit_collection_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
let edit_indexer_modal = EditIndexerModal {
name: "DrunkenSlug".into(),
enable_rss: Some(true),
enable_automatic_search: Some(true),
enable_interactive_search: Some(true),
url: "http://127.0.0.1:9696/1/".into(),
api_key: "someApiKey".into(),
seed_ratio: "ratio".into(),
tags: "25".into(),
priority: 1,
};
let indexer_settings = radarr_models::IndexerSettings {
allow_hardcoded_subs: true,
availability_delay: 0,
id: 1,
maximum_size: 1234,
minimum_age: 12,
prefer_indexer_flags: true,
retention: 30,
rss_sync_interval: 60,
whitelisted_hardcoded_subs: "eng".into(),
};
let mut indexer_test_results = StatefulTable::default();
indexer_test_results.set_items(vec![indexer_test_result()]);
indexer_test_results.sorting(vec![sort_option!(name)]);
indexer_test_results.search = Some("something".into());
indexer_test_results.filter = Some("something".into());
let mut movie_details_modal = MovieDetailsModal {
movie_details: ScrollableText::with_string("Some information".to_owned()),
file_details: "Some file info".to_owned(),
audio_details: "Some audio info".to_owned(),
video_details: "Some video info".to_owned(),
..MovieDetailsModal::default()
};
movie_details_modal
.movie_history
.set_items(vec![movie_history_item()]);
movie_details_modal
.movie_cast
.set_items(vec![cast_credit()]);
movie_details_modal
.movie_crew
.set_items(vec![crew_credit()]);
movie_details_modal
.movie_releases
.set_items(vec![torrent_release(), usenet_release()]);
movie_details_modal
.movie_releases
.sorting(vec![sort_option!(indexer_id)]);
let mut radarr_data = RadarrData {
disk_space_vec: vec![diskspace()],
version: "1.2.3.4".to_owned(),
quality_profile_map: quality_profile_map(),
tags_map: tags_map(),
updates: updates(),
start_time: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:29:16Z").unwrap()),
add_movie_search: Some("test".into()),
add_movie_modal: Some(add_movie_modal),
add_searched_movies: Some(add_movie_search_result_table),
edit_movie_modal: Some(edit_movie_modal),
edit_collection_modal: Some(edit_collection_modal),
edit_indexer_modal: Some(edit_indexer_modal),
edit_root_folder: Some("/nfs/movies".into()),
indexer_settings: Some(indexer_settings),
indexer_test_errors: Some("error".into()),
indexer_test_all_results: Some(indexer_test_results),
movie_details_modal: Some(movie_details_modal),
delete_movie_files: true,
..RadarrData::default()
};
radarr_data.root_folders.set_items(vec![root_folder()]);
radarr_data.movies.set_items(vec![movie()]);
radarr_data.movies.sorting(vec![sort_option!(id)]);
radarr_data.movies.search = Some("Something".into());
radarr_data.movies.filter = Some("Something".into());
radarr_data.collections.set_items(vec![collection()]);
radarr_data.collections.sorting(vec![sort_option!(id)]);
radarr_data.collections.search = Some("Something".into());
radarr_data.collections.filter = Some("Something".into());
radarr_data
.collection_movies
.set_items(vec![collection_movie()]);
radarr_data.downloads.set_items(vec![download_record()]);
radarr_data.blocklist.set_items(vec![blocklist_item()]);
radarr_data.blocklist.sorting(vec![sort_option!(id)]);
radarr_data.indexers.set_items(vec![indexer()]);
radarr_data.indexers.sorting(vec![sort_option!(id)]);
radarr_data.indexers.search = Some("Something".into());
radarr_data.indexers.filter = Some("Something".into());
radarr_data.logs.set_items(vec![log_line().into()]);
radarr_data.log_details.set_items(vec![log_line().into()]);
radarr_data.tasks.set_items(vec![task()]);
radarr_data.queued_events.set_items(vec![queued_event()]);
App {
data: Data {
radarr_data,
sonarr_data: SonarrData::default(),
radarr_data: RadarrData::test_default_fully_populated(),
sonarr_data: SonarrData::test_default_fully_populated(),
},
server_tabs: TabState::new(vec![
TabRoute {
@@ -0,0 +1,9 @@
#[macro_export]
macro_rules! sort_option {
($field:ident) => {
SortOption {
name: "Something",
cmp_fn: Some(|a, b| a.$field.cmp(&b.$field)),
}
};
}
+2 -1
View File
@@ -5,7 +5,8 @@ pub mod radarr;
pub mod sonarr;
#[cfg(test)]
#[path = "servarr_data_tests.rs"]
pub(in crate::models::servarr_data) mod data_test_utils;
#[cfg(test)]
mod servarr_data_tests;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
+171 -1
View File
@@ -26,7 +26,22 @@ use chrono::{DateTime, Utc};
use serde_json::Number;
use strum::EnumIter;
#[cfg(test)]
use strum_macros::{Display, EnumString};
use {
crate::models::radarr_models::{MinimumAvailability, MovieMonitor},
crate::models::stateful_table::SortOption,
crate::network::radarr_network::radarr_network_test_utils::test_utils::root_folder,
crate::network::radarr_network::radarr_network_test_utils::test_utils::{
add_movie_search_result, blocklist_item, cast_credit, collection, collection_movie,
crew_credit, download_record, indexer, log_line, movie, movie_history_item,
quality_profile_map, tags_map, task, torrent_release, updates, usenet_release,
},
crate::network::servarr_test_utils::diskspace,
crate::network::servarr_test_utils::indexer_test_result,
crate::network::servarr_test_utils::queued_event,
crate::sort_option,
strum::IntoEnumIterator,
strum_macros::{Display, EnumString},
};
#[cfg(test)]
#[path = "radarr_data_tests.rs"]
@@ -225,6 +240,161 @@ impl<'a> Default for RadarrData<'a> {
}
}
#[cfg(test)]
impl RadarrData<'_> {
pub fn test_default_fully_populated() -> Self {
let quality_profile_name = "HD - 1080p".to_owned();
let mut add_movie_modal = AddMovieModal {
tags: "alex".into(),
..AddMovieModal::default()
};
add_movie_modal
.root_folder_list
.set_items(vec![root_folder()]);
add_movie_modal
.monitor_list
.set_items(MovieMonitor::iter().collect());
add_movie_modal
.minimum_availability_list
.set_items(MinimumAvailability::iter().collect());
add_movie_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
let mut add_movie_search_result_table = StatefulTable::default();
add_movie_search_result_table.set_items(vec![add_movie_search_result()]);
add_movie_search_result_table.sorting(vec![sort_option!(tmdb_id)]);
add_movie_search_result_table.search = Some("something".into());
add_movie_search_result_table.filter = Some("something".into());
let mut edit_movie_modal = EditMovieModal {
monitored: Some(true),
path: "/nfs/movies".into(),
tags: "alex".into(),
..EditMovieModal::default()
};
edit_movie_modal
.minimum_availability_list
.set_items(MinimumAvailability::iter().collect());
edit_movie_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
let mut edit_collection_modal = EditCollectionModal {
monitored: Some(true),
path: "/nfs/movies".into(),
search_on_add: Some(true),
..EditCollectionModal::default()
};
edit_collection_modal
.minimum_availability_list
.set_items(MinimumAvailability::iter().collect());
edit_collection_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
let edit_indexer_modal = EditIndexerModal {
name: "DrunkenSlug".into(),
enable_rss: Some(true),
enable_automatic_search: Some(true),
enable_interactive_search: Some(true),
url: "http://127.0.0.1:9696/1/".into(),
api_key: "someApiKey".into(),
seed_ratio: "ratio".into(),
tags: "25".into(),
priority: 1,
};
let indexer_settings = IndexerSettings {
allow_hardcoded_subs: true,
availability_delay: 0,
id: 1,
maximum_size: 1234,
minimum_age: 12,
prefer_indexer_flags: true,
retention: 30,
rss_sync_interval: 60,
whitelisted_hardcoded_subs: "eng".into(),
};
let mut indexer_test_results = StatefulTable::default();
indexer_test_results.set_items(vec![indexer_test_result()]);
indexer_test_results.sorting(vec![sort_option!(name)]);
indexer_test_results.search = Some("something".into());
indexer_test_results.filter = Some("something".into());
let mut movie_details_modal = MovieDetailsModal {
movie_details: ScrollableText::with_string("Some information".to_owned()),
file_details: "Some file info".to_owned(),
audio_details: "Some audio info".to_owned(),
video_details: "Some video info".to_owned(),
..MovieDetailsModal::default()
};
movie_details_modal
.movie_history
.set_items(vec![movie_history_item()]);
movie_details_modal
.movie_cast
.set_items(vec![cast_credit()]);
movie_details_modal
.movie_crew
.set_items(vec![crew_credit()]);
movie_details_modal
.movie_releases
.set_items(vec![torrent_release(), usenet_release()]);
movie_details_modal
.movie_releases
.sorting(vec![sort_option!(indexer_id)]);
let mut radarr_data = RadarrData {
disk_space_vec: vec![diskspace()],
version: "1.2.3.4".to_owned(),
quality_profile_map: quality_profile_map(),
tags_map: tags_map(),
updates: updates(),
start_time: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:29:16Z").unwrap()),
add_movie_search: Some("test".into()),
add_movie_modal: Some(add_movie_modal),
add_searched_movies: Some(add_movie_search_result_table),
edit_movie_modal: Some(edit_movie_modal),
edit_collection_modal: Some(edit_collection_modal),
edit_indexer_modal: Some(edit_indexer_modal),
edit_root_folder: Some("/nfs/movies".into()),
indexer_settings: Some(indexer_settings),
indexer_test_errors: Some("error".into()),
indexer_test_all_results: Some(indexer_test_results),
movie_details_modal: Some(movie_details_modal),
delete_movie_files: true,
..RadarrData::default()
};
radarr_data.root_folders.set_items(vec![root_folder()]);
radarr_data.movies.set_items(vec![movie()]);
radarr_data.movies.sorting(vec![sort_option!(id)]);
radarr_data.movies.search = Some("Something".into());
radarr_data.movies.filter = Some("Something".into());
radarr_data.collections.set_items(vec![collection()]);
radarr_data.collections.sorting(vec![sort_option!(id)]);
radarr_data.collections.search = Some("Something".into());
radarr_data.collections.filter = Some("Something".into());
radarr_data
.collection_movies
.set_items(vec![collection_movie()]);
radarr_data.downloads.set_items(vec![download_record()]);
radarr_data.blocklist.set_items(vec![blocklist_item()]);
radarr_data.blocklist.sorting(vec![sort_option!(id)]);
radarr_data.indexers.set_items(vec![indexer()]);
radarr_data.indexers.sorting(vec![sort_option!(id)]);
radarr_data.indexers.search = Some("Something".into());
radarr_data.indexers.filter = Some("Something".into());
radarr_data.logs.set_items(vec![log_line().into()]);
radarr_data.log_details.set_items(vec![log_line().into()]);
radarr_data.tasks.set_items(vec![task()]);
radarr_data.queued_events.set_items(vec![queued_event()]);
radarr_data
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, EnumIter)]
#[cfg_attr(test, derive(Display, EnumString))]
pub enum ActiveRadarrBlock {
+182 -7
View File
@@ -1,8 +1,4 @@
use bimap::BiMap;
use chrono::{DateTime, Utc};
use serde_json::Number;
use strum::EnumIter;
use super::modals::{AddSeriesModal, EditSeriesModal, SeasonDetailsModal};
use crate::{
app::{
context_clues::{
@@ -27,8 +23,30 @@ use crate::{
},
network::sonarr_network::SonarrEvent,
};
use super::modals::{AddSeriesModal, EditSeriesModal, SeasonDetailsModal};
use bimap::BiMap;
use chrono::{DateTime, Utc};
use serde_json::Number;
use strum::EnumIter;
#[cfg(test)]
use {
super::modals::EpisodeDetailsModal,
crate::models::sonarr_models::{SeriesMonitor, SeriesType},
crate::models::stateful_table::SortOption,
crate::network::servarr_test_utils::diskspace,
crate::network::servarr_test_utils::indexer_test_result,
crate::network::servarr_test_utils::queued_event,
crate::network::sonarr_network::sonarr_network_test_utils::test_utils::{
add_series_search_result, blocklist_item, download_record, history_item, indexer,
indexer_settings, log_line, root_folder,
},
crate::network::sonarr_network::sonarr_network_test_utils::test_utils::{
episode, episode_file, language_profiles_map, quality_profile_map, season, series, tags_map,
task, torrent_release, updates, usenet_release,
},
crate::sort_option,
strum::IntoEnumIterator,
strum_macros::{Display, EnumString},
};
#[cfg(test)]
#[path = "sonarr_data_tests.rs"]
@@ -212,7 +230,164 @@ impl<'a> Default for SonarrData<'a> {
}
}
#[cfg(test)]
impl SonarrData<'_> {
pub fn test_default_fully_populated() -> Self {
let quality_profile_name = "Bluray-1080p".to_owned();
let language_profile_name = "English".to_owned();
let mut add_searched_series = StatefulTable::default();
add_searched_series.set_items(vec![add_series_search_result()]);
let mut add_series_modal = AddSeriesModal {
use_season_folder: true,
tags: "alex".into(),
..AddSeriesModal::default()
};
add_series_modal
.root_folder_list
.set_items(vec![root_folder()]);
add_series_modal
.monitor_list
.set_items(SeriesMonitor::iter().collect());
add_series_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
add_series_modal
.language_profile_list
.set_items(vec![language_profile_name.clone()]);
add_series_modal
.series_type_list
.set_items(SeriesType::iter().collect());
let edit_indexer_modal = EditIndexerModal {
name: "DrunkenSlug".into(),
enable_rss: Some(true),
enable_automatic_search: Some(true),
enable_interactive_search: Some(true),
url: "http://127.0.0.1:9696/1/".into(),
api_key: "someApiKey".into(),
seed_ratio: "ratio".into(),
tags: "25".into(),
priority: 1,
};
let mut edit_series_modal = EditSeriesModal {
monitored: Some(true),
use_season_folders: Some(true),
path: "/nfs/tv".into(),
tags: "alex".into(),
..EditSeriesModal::default()
};
edit_series_modal
.series_type_list
.set_items(SeriesType::iter().collect());
edit_series_modal
.quality_profile_list
.set_items(vec![quality_profile_name.clone()]);
edit_series_modal
.language_profile_list
.set_items(vec![language_profile_name.clone()]);
let mut indexer_test_all_results = StatefulTable::default();
indexer_test_all_results.set_items(vec![indexer_test_result()]);
let mut episode_details_modal = EpisodeDetailsModal {
episode_details: ScrollableText::with_string("Some episode details".into()),
file_details: "Some file details".to_owned(),
audio_details: "Some audio details".to_owned(),
video_details: "Some video details".to_owned(),
..EpisodeDetailsModal::default()
};
episode_details_modal
.episode_history
.set_items(vec![history_item()]);
episode_details_modal
.episode_releases
.set_items(vec![torrent_release(), usenet_release()]);
episode_details_modal
.episode_releases
.sorting(vec![sort_option!(indexer_id)]);
let mut season_details_modal = SeasonDetailsModal {
episode_details_modal: Some(episode_details_modal),
..SeasonDetailsModal::default()
};
season_details_modal.episodes.set_items(vec![episode()]);
season_details_modal.episodes.search = Some("episode search".into());
season_details_modal
.episode_files
.set_items(vec![episode_file()]);
season_details_modal
.season_history
.set_items(vec![history_item()]);
season_details_modal.season_history.search = Some("season history search".into());
season_details_modal.season_history.filter = Some("season history filter".into());
season_details_modal
.season_history
.sorting(vec![sort_option!(id)]);
season_details_modal
.season_releases
.set_items(vec![torrent_release(), usenet_release()]);
season_details_modal
.season_releases
.sorting(vec![sort_option!(indexer_id)]);
let mut series_history = StatefulTable::default();
series_history.set_items(vec![history_item()]);
series_history.sorting(vec![sort_option!(id)]);
series_history.search = Some("series history search".into());
series_history.filter = Some("series history filter".into());
let mut sonarr_data = SonarrData {
add_list_exclusion: true,
add_searched_series: Some(add_searched_series),
add_series_modal: Some(add_series_modal),
add_series_search: Some("something".into()),
delete_series_files: true,
disk_space_vec: vec![diskspace()],
edit_indexer_modal: Some(edit_indexer_modal),
edit_root_folder: Some("/nfs/tv".into()),
edit_series_modal: Some(edit_series_modal),
indexer_settings: Some(indexer_settings()),
indexer_test_all_results: Some(indexer_test_all_results),
indexer_test_errors: Some("error".to_string()),
language_profiles_map: language_profiles_map(),
quality_profile_map: quality_profile_map(),
season_details_modal: Some(season_details_modal),
series_history: Some(series_history),
start_time: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:29:16Z").unwrap()),
tags_map: tags_map(),
updates: updates(),
version: "1.2.3.4".to_owned(),
..SonarrData::default()
};
sonarr_data.blocklist.set_items(vec![blocklist_item()]);
sonarr_data.blocklist.sorting(vec![sort_option!(id)]);
sonarr_data.downloads.set_items(vec![download_record()]);
sonarr_data.history.set_items(vec![history_item()]);
sonarr_data.history.sorting(vec![sort_option!(id)]);
sonarr_data.history.search = Some("test search".into());
sonarr_data.history.filter = Some("test filter".into());
sonarr_data.indexers.set_items(vec![indexer()]);
sonarr_data.queued_events.set_items(vec![queued_event()]);
sonarr_data.root_folders.set_items(vec![root_folder()]);
sonarr_data.seasons.set_items(vec![season()]);
sonarr_data.seasons.search = Some("season search".into());
sonarr_data.series.set_items(vec![series()]);
sonarr_data.series.sorting(vec![sort_option!(id)]);
sonarr_data.series.search = Some("series search".into());
sonarr_data.series.filter = Some("series filter".into());
sonarr_data.logs.set_items(vec![log_line().into()]);
sonarr_data.log_details.set_items(vec![log_line().into()]);
sonarr_data.tasks.set_items(vec![task()]);
sonarr_data
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, EnumIter)]
#[cfg_attr(test, derive(Display, EnumString))]
pub enum ActiveSonarrBlock {
AddRootFolderPrompt,
AddSeriesAlreadyInLibrary,
+2 -1
View File
@@ -26,8 +26,9 @@ pub mod sonarr_network;
mod utils;
#[cfg(test)]
#[path = "network_tests.rs"]
mod network_tests;
#[cfg(test)]
pub mod servarr_test_utils;
#[cfg_attr(test, automock)]
#[async_trait]
@@ -6,9 +6,8 @@ pub mod test_utils {
Movie, MovieCollection, MovieFile, MovieHistoryItem, RadarrRelease, RadarrTask, RadarrTaskName,
Rating, RatingsList,
};
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
use crate::models::servarr_models::{
DiskSpace, Indexer, IndexerField, Language, Quality, QualityWrapper, QueueEvent, RootFolder,
Indexer, IndexerField, Language, Quality, QualityWrapper, RootFolder,
};
use crate::models::{HorizontallyScrollableText, ScrollableText};
use bimap::BiMap;
@@ -108,13 +107,6 @@ pub mod test_utils {
}
}
pub fn diskspace() -> DiskSpace {
DiskSpace {
free_space: 6500,
total_space: 8675309,
}
}
pub fn log_line() -> &'static str {
"2025-12-15 16:14:45 UTC|INFO|DownloadDecisionMaker|Processing 545 releases"
}
@@ -130,23 +122,6 @@ pub mod test_utils {
}
}
pub fn queued_event() -> QueueEvent {
QueueEvent {
trigger: "manual".to_string(),
name: "Refresh Monitored Downloads".to_string(),
command_name: "Refresh Monitored Downloads".to_string(),
status: "completed".to_string(),
queued: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:25:16Z").unwrap()),
started: Some(DateTime::from(
DateTime::parse_from_rfc3339("2023-05-20T21:25:30Z").unwrap(),
)),
ended: Some(DateTime::from(
DateTime::parse_from_rfc3339("2023-05-20T21:28:33Z").unwrap(),
)),
duration: Some("00:03:03".to_owned()),
}
}
pub fn tags_map() -> BiMap<i64, String> {
BiMap::from_iter([(1, "alex".to_owned())])
}
@@ -490,14 +465,6 @@ pub mod test_utils {
))
}
pub fn indexer_test_result() -> IndexerTestResultModalItem {
IndexerTestResultModalItem {
name: "DrunkenSlug".to_owned(),
is_valid: false,
validation_failures: "Some failure".into(),
}
}
pub fn torrent_release() -> RadarrRelease {
RadarrRelease {
guid: "1234".to_string(),
+35
View File
@@ -0,0 +1,35 @@
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
use crate::models::servarr_models::{DiskSpace, QueueEvent};
use chrono::DateTime;
pub fn diskspace() -> DiskSpace {
DiskSpace {
free_space: 6500,
total_space: 8675309,
}
}
pub fn indexer_test_result() -> IndexerTestResultModalItem {
IndexerTestResultModalItem {
name: "DrunkenSlug".to_owned(),
is_valid: false,
validation_failures: "Some failure".into(),
}
}
pub fn queued_event() -> QueueEvent {
QueueEvent {
trigger: "manual".to_string(),
name: "Refresh Monitored Downloads".to_string(),
command_name: "Refresh Monitored Downloads".to_string(),
status: "completed".to_string(),
queued: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:25:16Z").unwrap()),
started: Some(DateTime::from(
DateTime::parse_from_rfc3339("2023-05-20T21:25:30Z").unwrap(),
)),
ended: Some(DateTime::from(
DateTime::parse_from_rfc3339("2023-05-20T21:28:33Z").unwrap(),
)),
duration: Some("00:03:03".to_owned()),
}
}
@@ -96,6 +96,7 @@ mod tests {
},
{
"seriesId": 2001,
"seriesTitle": "Test Series",
"episodeIds": [42018],
"sourceTitle": "A Series",
"languages": [{ "id": 1, "name": "English" }],
@@ -12,7 +12,7 @@ mod tests {
use crate::network::sonarr_network::SonarrEvent;
use crate::network::sonarr_network::library::episodes::get_episode_status;
use crate::network::sonarr_network::sonarr_network_test_utils::test_utils::{
EPISODE_JSON, episode, episode_file, history_item, release,
EPISODE_JSON, episode, episode_file, history_item, torrent_release,
};
use indoc::formatdoc;
use mockito::Matcher;
@@ -1124,9 +1124,9 @@ mod tests {
.unwrap()
.episode_releases
.items,
vec![release()]
vec![torrent_release()]
);
assert_eq!(releases_vec, vec![release()]);
assert_eq!(releases_vec, vec![torrent_release()]);
}
#[tokio::test]
@@ -1179,9 +1179,9 @@ mod tests {
.unwrap()
.episode_releases
.items,
vec![release()]
vec![torrent_release()]
);
assert_eq!(releases_vec, vec![release()]);
assert_eq!(releases_vec, vec![torrent_release()]);
}
#[tokio::test]
@@ -6,7 +6,7 @@ mod tests {
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
use crate::network::sonarr_network::SonarrEvent;
use crate::network::sonarr_network::sonarr_network_test_utils::test_utils::{
SERIES_JSON, history_item, release, season, series,
SERIES_JSON, history_item, season, series, torrent_release,
};
use mockito::Matcher;
use pretty_assertions::assert_eq;
@@ -101,16 +101,16 @@ mod tests {
]);
let expected_filtered_sonarr_release = SonarrRelease {
full_season: true,
..release()
..torrent_release()
};
let expected_raw_sonarr_releases = vec![
SonarrRelease {
full_season: true,
..release()
..torrent_release()
},
SonarrRelease {
guid: "4567".to_owned(),
..release()
..torrent_release()
},
];
let (mock, app, _server) = MockServarrApi::get()
@@ -197,7 +197,7 @@ mod tests {
]);
let expected_sonarr_release = SonarrRelease {
full_season: true,
..release()
..torrent_release()
};
let (mock, app, _server) = MockServarrApi::get()
.returns(release_json)
+1 -1
View File
@@ -19,7 +19,7 @@ mod sonarr_network_tests;
#[cfg(test)]
#[path = "sonarr_network_test_utils.rs"]
mod sonarr_network_test_utils;
pub mod sonarr_network_test_utils;
mod blocklist;
mod downloads;
@@ -1,6 +1,5 @@
#[cfg(test)]
pub(in crate::network::sonarr_network) mod test_utils {
use crate::models::HorizontallyScrollableText;
pub mod test_utils {
use crate::models::servarr_models::{
Indexer, IndexerField, Language, Quality, QualityWrapper, RootFolder,
};
@@ -8,9 +7,13 @@ pub(in crate::network::sonarr_network) mod test_utils {
AddSeriesSearchResult, AddSeriesSearchResultStatistics, BlocklistItem, DownloadRecord,
DownloadStatus, DownloadsResponse, Episode, EpisodeFile, IndexerSettings, MediaInfo, Rating,
Season, SeasonStatistics, Series, SeriesStatistics, SeriesStatus, SeriesType,
SonarrHistoryData, SonarrHistoryEventType, SonarrHistoryItem, SonarrRelease,
SonarrHistoryData, SonarrHistoryEventType, SonarrHistoryItem, SonarrRelease, SonarrTask,
SonarrTaskName,
};
use crate::models::{HorizontallyScrollableText, ScrollableText};
use bimap::BiMap;
use chrono::DateTime;
use indoc::formatdoc;
use serde_json::{Number, Value, json};
pub const SERIES_JSON: &str = r#"{
@@ -22,6 +25,7 @@ pub(in crate::network::sonarr_network) mod test_utils {
"seasons": [
{
"seasonNumber": 1,
"title": "Season title",
"monitored": true,
"statistics": {
"previousAiring": "2022-10-24T01:00:00Z",
@@ -120,7 +124,7 @@ pub(in crate::network::sonarr_network) mod test_utils {
BlocklistItem {
id: 1,
series_id: 1,
series_title: None,
series_title: Some("Test Series".to_owned()),
episode_ids: vec![Number::from(1)],
source_title: "Test Source Title".to_owned(),
languages: vec![Some(language())],
@@ -299,7 +303,7 @@ pub(in crate::network::sonarr_network) mod test_utils {
pub fn season() -> Season {
Season {
title: None,
title: Some("Season title".to_owned()),
season_number: 1,
monitored: true,
statistics: Some(season_statistics()),
@@ -364,7 +368,7 @@ pub(in crate::network::sonarr_network) mod test_utils {
]
}
pub fn release() -> SonarrRelease {
pub fn torrent_release() -> SonarrRelease {
SonarrRelease {
guid: "1234".to_owned(),
protocol: "torrent".to_owned(),
@@ -383,6 +387,25 @@ pub(in crate::network::sonarr_network) mod test_utils {
}
}
pub fn usenet_release() -> SonarrRelease {
SonarrRelease {
guid: "1234".to_owned(),
protocol: "usenet".to_owned(),
age: 1,
title: HorizontallyScrollableText::from("Test Release"),
indexer: "DrunkenSlug".to_owned(),
indexer_id: 1,
size: 1234,
rejected: true,
rejections: Some(rejections()),
seeders: None,
leechers: None,
languages: Some(vec![Some(language())]),
quality: quality_wrapper(),
full_season: false,
}
}
pub fn root_folder() -> RootFolder {
RootFolder {
id: 1,
@@ -399,4 +422,61 @@ pub(in crate::network::sonarr_network) mod test_utils {
"label": "testing"
})
}
pub fn log_line() -> &'static str {
"2025-12-16 16:40:59 UTC|INFO|ImportListSyncService|No list items to process"
}
pub fn language_profiles_map() -> BiMap<i64, String> {
let Language { id, name } = language();
BiMap::from_iter(vec![(id, name)])
}
pub fn quality_profile_map() -> BiMap<i64, String> {
BiMap::from_iter(vec![(6, quality().name)])
}
pub fn tags_map() -> BiMap<i64, String> {
BiMap::from_iter(vec![(1, "alex".to_owned())])
}
pub fn task() -> SonarrTask {
SonarrTask {
name: "Backup".to_owned(),
task_name: SonarrTaskName::Backup,
interval: 60,
last_execution: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T21:29:16Z").unwrap()),
next_execution: DateTime::from(DateTime::parse_from_rfc3339("2023-05-20T22:29:16Z").unwrap()),
}
}
pub fn updates() -> ScrollableText {
let line_break = "-".repeat(200);
ScrollableText::with_string(formatdoc!(
"
The latest version of Sonarr is already installed
4.3.2.1 - 2023-04-15 02:02:53 UTC (Currently Installed)
{line_break}
New:
* Cool new thing
Fixed:
* Some bugs killed
3.2.1.0 - 2023-04-15 02:02:53 UTC (Previously Installed)
{line_break}
New:
* Cool new thing (old)
* Other cool new thing (old)
2.1.0 - 2023-04-15 02:02:53 UTC
{line_break}
Fixed:
* Killed bug 1
* Fixed bug 2"
))
}
}
+3 -3
View File
@@ -202,9 +202,9 @@ impl Network<'_, '_> {
.map(|update| {
let install_status = if update.installed_on.is_some() {
if update.installed {
"(Currently Installed)".to_owned()
" (Currently Installed)".to_owned()
} else {
"(Previously Installed)".to_owned()
" (Previously Installed)".to_owned()
}
} else {
String::new()
@@ -218,7 +218,7 @@ impl Network<'_, '_> {
};
let mut update_info = formatdoc!(
"{} - {} {install_status}
"{} - {}{install_status}
{}",
update.version,
update.release_date,
@@ -1,14 +1,14 @@
#[cfg(test)]
mod tests {
use crate::models::HorizontallyScrollableText;
use crate::models::servarr_models::{
DiskSpace, HostConfig, LogResponse, QueueEvent, SecurityConfig, Update,
};
use crate::models::sonarr_models::{SonarrSerdeable, SonarrTask, SonarrTaskName, SystemStatus};
use crate::models::{HorizontallyScrollableText, ScrollableText};
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
use crate::network::sonarr_network::SonarrEvent;
use crate::network::sonarr_network::sonarr_network_test_utils::test_utils::updates;
use chrono::DateTime;
use indoc::formatdoc;
use pretty_assertions::{assert_eq, assert_str_eq};
use serde_json::json;
@@ -359,32 +359,7 @@ mod tests {
},
}]);
let response: Vec<Update> = serde_json::from_value(updates_json.clone()).unwrap();
let line_break = "-".repeat(200);
let expected_text = ScrollableText::with_string(formatdoc!(
"
The latest version of Sonarr is already installed
4.3.2.1 - 2023-04-15 02:02:53 UTC (Currently Installed)
{line_break}
New:
* Cool new thing
Fixed:
* Some bugs killed
3.2.1.0 - 2023-04-15 02:02:53 UTC (Previously Installed)
{line_break}
New:
* Cool new thing (old)
* Other cool new thing (old)
2.1.0 - 2023-04-15 02:02:53 UTC
{line_break}
Fixed:
* Killed bug 1
* Fixed bug 2"
));
let expected_text = updates();
let (mock, app, _server) = MockServarrApi::get()
.returns(updates_json)
.build_for(SonarrEvent::GetUpdates)
@@ -58,7 +58,12 @@ mod tests {
CollectionsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
insta::assert_snapshot!(
format!(
"is_loading_{is_loading}_empty_movies_{empty_movies}_empty_profile_{empty_profile_map}"
),
output
);
}
#[rstest]
@@ -81,7 +86,7 @@ mod tests {
CollectionsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(active_radarr_block.to_string(), output);
insta::assert_snapshot!(format!("collections_tab_{active_radarr_block}"), output);
}
#[test]
@@ -141,7 +146,7 @@ mod tests {
insta::assert_snapshot!(
format!(
"{}_{}",
"edit_collection_modal_{}_{}",
active_radarr_block.to_string(),
context_block.to_string()
),
+2 -2
View File
@@ -82,7 +82,7 @@ mod tests {
LibraryUi::draw(f, app, f.area());
});
insta::assert_snapshot!(active_radarr_block.to_string(), output);
insta::assert_snapshot!(format!("library_tab_{active_radarr_block}"), output);
}
#[rstest]
@@ -109,7 +109,7 @@ mod tests {
LibraryUi::draw(f, app, f.area());
});
insta::assert_snapshot!(active_radarr_block.to_string(), output);
insta::assert_snapshot!(format!("add_movie_ui_{active_radarr_block}"), output);
}
#[test]
@@ -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 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Log Details ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │2025-12-15 16:14:45 UTC|INFO|DownloadDecisionMaker|Processing 545 releases │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
╰───────────────────│ │────────────────────╯
╭ Logs ───────────│ │────────────────────╮
│2025-12-15 16:14:45│ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -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 │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Queued Events ────────────────────────────────────────────────────────────────────────────────╮ │
│ │Trigger Status Name Queued Started Duration │ │
│ │manual completed Refresh Monitored Downlo 4 minutes ago 4 minutes ago 00:03:03 │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
╰────────────────────────────────│ │────────────────────────────────╯
╭ Logs ────────────────────────│ │────────────────────────────────╮
│2025-12-15 16:14:45 UTC|INFO|Dow│ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -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 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ 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? │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
╰───────────────────│ │ │ │────────────────────╯
╭ Logs ───────────│ │ │ │────────────────────╮
│2025-12-15 16:14:45│ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │╭────────────────────────────╮╭───────────────────────────╮│ │ │
│ │ ││ Yes ││ No ││ │ │
│ │ │╰────────────────────────────╯╰───────────────────────────╯│ │ │
│ │ ╰───────────────────────────────────────────────────────────╯ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -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 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ Tasks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ Name Interval Last Execution Last Duration Next Execution │ │
│ │=> Backup 1 hour now 00:00:17 59 minutes │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
╰───────────────────│ │────────────────────╯
╭ Logs ───────────│ │────────────────────╮
│2025-12-15 16:14:45│ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -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 │
│ ││ │
│ ││ │
│ ││ │
│ ╭ 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 │────────────────────╯
╭ Logs ───────────│--------------------------------------------------------------------------------------------------------------------------│────────────────────╮
│2025-12-15 16:14:45│Fixed: │ │
│ │ * Killed bug 1 │ │
│ │ * Fixed bug 2 │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -27,7 +27,7 @@ mod tests {
use rstest::rstest;
#[rstest]
fn test_system_details_ui_renders_tasks(
fn test_system_details_ui_renders_popups(
#[values(
ActiveRadarrBlock::SystemLogs,
ActiveRadarrBlock::SystemQueuedEvents,
@@ -29,6 +29,7 @@ mod tests {
use super::*;
use crate::models::stateful_list::StatefulList;
use crate::models::stateful_table::StatefulTable;
use rstest::rstest;
#[test]
fn test_radarr_ui_renders_system_tab_loading() {
@@ -98,5 +99,29 @@ mod tests {
insta::assert_snapshot!(output);
}
#[rstest]
fn test_system_details_ui_renders_popups_over_system_tab(
#[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());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
SystemUi::draw(f, app, f.area());
});
insta::assert_snapshot!(
format!("system_details_over_system_tab_{active_radarr_block}"),
output
);
}
}
}
@@ -4,8 +4,6 @@ mod tests {
use crate::app::App;
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, BLOCKLIST_BLOCKS};
use crate::models::sonarr_models::BlocklistItem;
use crate::models::stateful_table::StatefulTable;
use crate::ui::DrawUi;
use crate::ui::sonarr_ui::blocklist::BlocklistUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
@@ -23,11 +21,12 @@ mod tests {
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use rstest::rstest;
use super::*;
#[test]
fn test_blocklist_ui_renders_loading_state() {
fn test_blocklist_ui_renders_loading() {
let mut app = App::test_default();
app.is_loading = true;
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
@@ -40,10 +39,9 @@ mod tests {
}
#[test]
fn test_blocklist_ui_renders_empty_blocklist() {
fn test_blocklist_ui_renders_empty() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
app.data.sonarr_data.blocklist = StatefulTable::default();
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
BlocklistUi::draw(f, app, f.area());
@@ -52,29 +50,25 @@ mod tests {
insta::assert_snapshot!(output);
}
#[test]
fn test_blocklist_ui_renders_with_blocklist_items() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
app.data.sonarr_data.blocklist = StatefulTable::default();
app.data.sonarr_data.blocklist.set_items(vec![
BlocklistItem {
id: 1,
source_title: "Test.Series.S01E01.1080p".to_owned(),
..BlocklistItem::default()
},
BlocklistItem {
id: 2,
source_title: "Another.Series.S02E05.720p".to_owned(),
..BlocklistItem::default()
},
]);
#[rstest]
fn test_blocklist_ui_renders(
#[values(
ActiveSonarrBlock::Blocklist,
ActiveSonarrBlock::BlocklistItemDetails,
ActiveSonarrBlock::DeleteBlocklistItemPrompt,
ActiveSonarrBlock::BlocklistClearAllItemsPrompt,
ActiveSonarrBlock::BlocklistSortPrompt
)]
active_sonarr_block: ActiveSonarrBlock,
) {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(active_sonarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
BlocklistUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
insta::assert_snapshot!(format!("blocklist_tab_{active_sonarr_block}"), output);
}
}
}
@@ -3,6 +3,5 @@ source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Series Title Source Title Language Quality Date
=> Test.Series.S01E01.1080p 1970-01-01 00:00:00 UTC
Another.Series.S02E05.720p 1970-01-01 00:00:00 UTC
Series Title Source Title Language Quality Date
=> Test Series Test Source Title English Bluray-1080p 2024-02-10 07:28:45 UTC
@@ -0,0 +1,34 @@
---
source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Series Title ▼ Source Title Language Quality Date
=> Test Series Test Source Title English Bluray-1080p 2024-02-10 07:28:45 UTC
╭────── Clear Blocklist ──────╮
│ Do you want to clear your │
│ blocklist? │
│ │
│ │
│ │
│╭──────────────╮╭─────────────╮│
││ Yes ││ No ││
│╰──────────────╯╰─────────────╯│
╰───────────────────────────────╯
@@ -0,0 +1,34 @@
---
source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Series Title ▼ Source Title Language Quality Date
=> Test Series Test Source Title English Bluray-1080p 2024-02-10 07:28:45 UTC
╭─────────────────────────────────── Details ───────────────────────────────────╮
│Name: Test Source Title │
│Protocol: usenet │
│Indexer: NZBgeek (Prowlarr) │
│Message: test message │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,42 @@
---
source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Series Title Source Title Language Quality Date
=> Test Series Test Source Title English Bluray-1080p 2024-02-10 07:28:45 UTC
╭───────────────────────────────╮
│Something │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────╯
@@ -0,0 +1,38 @@
---
source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Series Title ▼ Source Title Language Quality Date
=> Test Series Test Source Title English Bluray-1080p 2024-02-10 07:28:45 UTC
╭────────────── Remove Item from Blocklist ───────────────╮
│ Do you want to remove this item from your blocklist: │
│ Test Source Title? │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│╭────────────────────────────╮╭───────────────────────────╮│
││ Yes ││ No ││
│╰────────────────────────────╯╰───────────────────────────╯│
╰───────────────────────────────────────────────────────────╯
@@ -4,8 +4,6 @@ mod tests {
use crate::app::App;
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, DOWNLOADS_BLOCKS};
use crate::models::sonarr_models::DownloadRecord;
use crate::models::stateful_table::StatefulTable;
use crate::ui::DrawUi;
use crate::ui::sonarr_ui::downloads::DownloadsUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
@@ -23,11 +21,12 @@ mod tests {
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use rstest::rstest;
use super::*;
#[test]
fn test_downloads_ui_renders_loading_state() {
fn test_downloads_ui_renders_loading() {
let mut app = App::test_default();
app.is_loading = true;
app.push_navigation_stack(ActiveSonarrBlock::Downloads.into());
@@ -43,7 +42,6 @@ mod tests {
fn test_downloads_ui_renders_empty_downloads() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Downloads.into());
app.data.sonarr_data.downloads = StatefulTable::default();
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
DownloadsUi::draw(f, app, f.area());
@@ -52,35 +50,23 @@ mod tests {
insta::assert_snapshot!(output);
}
#[test]
fn test_downloads_ui_renders_with_downloads() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Downloads.into());
app.data.sonarr_data.downloads = StatefulTable::default();
app.data.sonarr_data.downloads.set_items(vec![
DownloadRecord {
id: 1,
title: "Test Series Download".to_owned(),
status: Default::default(),
size: 1024.0 * 1024.0 * 1024.0,
sizeleft: 512.0 * 1024.0 * 1024.0,
..DownloadRecord::default()
},
DownloadRecord {
id: 2,
title: "Another Series Download".to_owned(),
status: Default::default(),
size: 2048.0 * 1024.0 * 1024.0,
sizeleft: 0.0,
..DownloadRecord::default()
},
]);
#[rstest]
fn test_downloads_ui_renders(
#[values(
ActiveSonarrBlock::Downloads,
ActiveSonarrBlock::DeleteDownloadPrompt,
ActiveSonarrBlock::UpdateDownloadsPrompt
)]
active_sonarr_block: ActiveSonarrBlock,
) {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(active_sonarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
DownloadsUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
insta::assert_snapshot!(format!("downloads_ui_{active_sonarr_block}"), output);
}
}
}
@@ -0,0 +1,38 @@
---
source: src/ui/sonarr_ui/downloads/downloads_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Title Percent Complete Size Output Path Indexer Download Client
=> Test Download Title 50% 3.30 GB /nfs/tv/Test show/season 1/ kickass torrents transmission
╭──────────────────── Cancel Download ────────────────────╮
│ Do you really want to delete this download: │
│ Test Download Title? │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│╭────────────────────────────╮╭───────────────────────────╮│
││ Yes ││ No ││
│╰────────────────────────────╯╰───────────────────────────╯│
╰───────────────────────────────────────────────────────────╯
@@ -4,5 +4,4 @@ expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Title Percent Complete Size Output Path Indexer Download Client
=> Test Series Download 50% 1.00 GB
Another Series Download 100% 2.00 GB
=> Test Download Title 50% 3.30 GB /nfs/tv/Test show/season 1/ kickass torrents transmission
@@ -0,0 +1,38 @@
---
source: src/ui/sonarr_ui/downloads/downloads_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Title Percent Complete Size Output Path Indexer Download Client
=> Test Download Title 50% 3.30 GB /nfs/tv/Test show/season 1/ kickass torrents transmission
╭─────────────────── Update Downloads ────────────────────╮
│ Do you want to update your downloads? │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│╭────────────────────────────╮╭───────────────────────────╮│
││ Yes ││ No ││
│╰────────────────────────────╯╰───────────────────────────╯│
╰───────────────────────────────────────────────────────────╯
+25 -26
View File
@@ -4,8 +4,6 @@ mod tests {
use crate::app::App;
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, HISTORY_BLOCKS};
use crate::models::sonarr_models::SonarrHistoryItem;
use crate::models::stateful_table::StatefulTable;
use crate::ui::DrawUi;
use crate::ui::sonarr_ui::history::HistoryUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
@@ -23,11 +21,12 @@ mod tests {
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use rstest::rstest;
use super::*;
#[test]
fn test_history_ui_renders_loading_state() {
fn test_history_ui_renders_loading() {
let mut app = App::test_default();
app.is_loading = true;
app.push_navigation_stack(ActiveSonarrBlock::History.into());
@@ -39,42 +38,42 @@ mod tests {
insta::assert_snapshot!(output);
}
#[test]
fn test_history_ui_renders_empty_history() {
#[rstest]
fn test_history_ui_renders_empty(
#[values(ActiveSonarrBlock::History, ActiveSonarrBlock::HistoryItemDetails)]
active_sonarr_block: ActiveSonarrBlock,
) {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::History.into());
app.data.sonarr_data.history = StatefulTable::default();
app.push_navigation_stack(active_sonarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
HistoryUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
insta::assert_snapshot!(format!("loading_history_tab_{active_sonarr_block}"), output);
}
#[test]
fn test_history_ui_renders_with_history_items() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::History.into());
app.data.sonarr_data.history = StatefulTable::default();
app.data.sonarr_data.history.set_items(vec![
SonarrHistoryItem {
id: 1,
source_title: "Test.Series.S01E01".to_owned().into(),
..SonarrHistoryItem::default()
},
SonarrHistoryItem {
id: 2,
source_title: "Another.Series.S02E05".to_owned().into(),
..SonarrHistoryItem::default()
},
]);
#[rstest]
fn test_history_ui_renders(
#[values(
ActiveSonarrBlock::History,
ActiveSonarrBlock::HistoryItemDetails,
ActiveSonarrBlock::HistorySortPrompt,
ActiveSonarrBlock::FilterHistory,
ActiveSonarrBlock::FilterHistoryError,
ActiveSonarrBlock::SearchHistory,
ActiveSonarrBlock::SearchHistoryError
)]
active_sonarr_block: ActiveSonarrBlock,
) {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(active_sonarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
HistoryUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
insta::assert_snapshot!(format!("history_tab_{active_sonarr_block}"), output);
}
}
}
@@ -0,0 +1,28 @@
---
source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Source Title ▼ Event Type Language Quality Date
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
╭───────────────── Filter ──────────────────╮
│test filter │
╰─────────────────────────────────────────────╯
@@ -0,0 +1,31 @@
---
source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Source Title ▼ Event Type Language Quality Date
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
╭─────────────── Error ───────────────╮
│The given filter produced empty results│
│ │
╰───────────────────────────────────────╯
@@ -3,6 +3,5 @@ source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Source Title Event Type Language Quality Date
=> Test.Series.S01E01 unknown 1970-01-01 00:00:00 UTC
Another.Series.S02E05 unknown 1970-01-01 00:00:00 UTC
Source Title Event Type Language Quality Date
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
@@ -0,0 +1,34 @@
---
source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Source Title ▼ Event Type Language Quality Date
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
╭─────────────────────────────────── Details ───────────────────────────────────╮
│Source Title: Test source │
│Indexer: │
│Release Group: │
│Series Match Type: │
│NZB Info URL: │
│Download Client Name: │
│Age: 0 days │
│Published Date: 1970-01-01 00:00:00 UTC │
╰─────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,42 @@
---
source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Source Title Event Type Language Quality Date
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
╭───────────────────────────────╮
│Something │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────╯
@@ -0,0 +1,28 @@
---
source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Source Title ▼ Event Type Language Quality Date
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
╭───────────────── Search ──────────────────╮
│test search │
╰─────────────────────────────────────────────╯
@@ -0,0 +1,31 @@
---
source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Source Title ▼ Event Type Language Quality Date
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
╭─────────────── Error ───────────────╮
│ No items found matching search │
│ │
╰───────────────────────────────────────╯
@@ -0,0 +1,34 @@
---
source: src/ui/sonarr_ui/history/history_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
╭─────────────────────────────────── Details ───────────────────────────────────╮
│Source Title: │
│ │
│No additional data available │
│ │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────╯
@@ -4,16 +4,13 @@ mod tests {
use crate::app::App;
use crate::models::BlockSelectionState;
use crate::models::servarr_data::modals::EditIndexerModal;
use crate::models::servarr_data::sonarr::sonarr_data::{
ActiveSonarrBlock, EDIT_INDEXER_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
};
use crate::models::servarr_models::{Indexer, IndexerField};
use crate::models::stateful_table::StatefulTable;
use crate::models::servarr_models::Indexer;
use crate::ui::DrawUi;
use crate::ui::sonarr_ui::indexers::edit_indexer_ui::EditIndexerUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
use serde_json::json;
#[test]
fn test_edit_indexer_ui_accepts() {
@@ -27,39 +24,52 @@ mod tests {
}
mod snapshot_tests {
use crate::models::servarr_data::sonarr::sonarr_data::EDIT_INDEXER_NZB_SELECTION_BLOCKS;
use crate::network::sonarr_network::sonarr_network_test_utils::test_utils::indexer;
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use super::*;
#[test]
fn test_edit_indexer_ui_renders_edit_indexer_modal() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::EditIndexerNameInput.into());
app.data.sonarr_data.indexers = StatefulTable::default();
app.data.sonarr_data.indexers.set_items(vec![Indexer {
id: 1,
name: Some("Test Indexer".to_owned()),
enable_rss: true,
priority: 25,
fields: Some(vec![
IndexerField {
name: Some("baseUrl".to_owned()),
value: Some(json!("https://test.indexer.com")),
},
IndexerField {
name: Some("apiKey".to_owned()),
value: Some(json!("test-api-key")),
},
IndexerField {
name: Some("seedCriteria.seedRatio".to_owned()),
value: Some(json!(1.0)),
},
]),
..Indexer::default()
}]);
fn test_edit_indexer_ui_renders_loading() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.data.sonarr_data.edit_indexer_modal = None;
app.push_navigation_stack(ActiveSonarrBlock::EditIndexerPrompt.into());
app.data.sonarr_data.selected_block =
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal::from(&app.data.sonarr_data));
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EditIndexerUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_edit_indexer_ui_renders_edit_torrent_indexer() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::EditIndexerPrompt.into());
app.data.sonarr_data.selected_block =
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EditIndexerUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_edit_indexer_ui_renders_edit_usenet_indexer() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::EditIndexerPrompt.into());
app.data.sonarr_data.indexers.set_items(vec![Indexer {
protocol: "usenet".into(),
..indexer()
}]);
app.data.sonarr_data.selected_block =
BlockSelectionState::new(EDIT_INDEXER_NZB_SELECTION_BLOCKS);
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
EditIndexerUi::draw(f, app, f.area());
@@ -7,7 +7,6 @@ mod tests {
use crate::models::servarr_data::sonarr::sonarr_data::{
ActiveSonarrBlock, INDEXER_SETTINGS_BLOCKS, INDEXER_SETTINGS_SELECTION_BLOCKS,
};
use crate::models::sonarr_models::IndexerSettings;
use crate::ui::DrawUi;
use crate::ui::sonarr_ui::indexers::indexer_settings_ui::IndexerSettingsUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
@@ -30,11 +29,10 @@ mod tests {
#[test]
fn test_indexer_settings_ui_renders_indexer_settings() {
let mut app = App::test_default();
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::IndexerSettingsMinimumAgeInput.into());
app.data.sonarr_data.selected_block =
BlockSelectionState::new(INDEXER_SETTINGS_SELECTION_BLOCKS);
app.data.sonarr_data.indexer_settings = Some(IndexerSettings::default());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexerSettingsUi::draw(f, app, f.area());
+88 -25
View File
@@ -7,7 +7,6 @@ mod tests {
ActiveSonarrBlock, EDIT_INDEXER_BLOCKS, INDEXER_SETTINGS_BLOCKS, INDEXERS_BLOCKS,
};
use crate::models::servarr_models::Indexer;
use crate::models::stateful_table::StatefulTable;
use crate::ui::DrawUi;
use crate::ui::sonarr_ui::indexers::IndexersUi;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
@@ -30,13 +29,19 @@ mod tests {
}
mod snapshot_tests {
use crate::models::BlockSelectionState;
use crate::models::servarr_data::sonarr::sonarr_data::{
EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
};
use crate::network::sonarr_network::sonarr_network_test_utils::test_utils::indexer;
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use rstest::rstest;
use super::*;
#[test]
fn test_indexers_ui_renders_loading_state() {
let mut app = App::test_default();
fn test_indexers_ui_renders_loading() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
@@ -47,11 +52,67 @@ mod tests {
insta::assert_snapshot!(output);
}
#[test]
fn test_indexers_ui_renders_loading_test_results() {
let mut app = App::test_default_fully_populated();
app.is_loading = true;
app.push_navigation_stack(ActiveSonarrBlock::TestIndexer.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexersUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_indexers_ui_renders_loading_test_results_when_indexer_test_errors_is_none() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::TestIndexer.into());
app.data.sonarr_data.indexer_test_errors = None;
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexersUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_indexers_ui_renders_empty_indexers() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.data.sonarr_data.indexers = StatefulTable::default();
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexersUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[rstest]
fn test_indexers_ui_renders(
#[values(
ActiveSonarrBlock::DeleteIndexerPrompt,
ActiveSonarrBlock::Indexers,
ActiveSonarrBlock::TestIndexer
)]
active_sonarr_block: ActiveSonarrBlock,
) {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(active_sonarr_block.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexersUi::draw(f, app, f.area());
});
insta::assert_snapshot!(format!("indexers_ui_{active_sonarr_block}"), output);
}
#[test]
fn test_indexers_ui_renders_test_all_over_indexers() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::TestAllIndexers.into());
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexersUi::draw(f, app, f.area());
@@ -61,27 +122,29 @@ mod tests {
}
#[test]
fn test_indexers_ui_renders_with_indexers() {
let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.data.sonarr_data.indexers = StatefulTable::default();
app.data.sonarr_data.indexers.set_items(vec![
Indexer {
id: 1,
name: Some("Test Indexer 1".to_owned()),
enable_rss: true,
enable_automatic_search: true,
enable_interactive_search: true,
priority: 25,
..Indexer::default()
},
Indexer {
id: 2,
name: Some("Test Indexer 2".to_owned()),
enable_rss: false,
..Indexer::default()
},
]);
fn test_indexers_ui_renders_edit_usenet_indexer_over_indexers() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::EditIndexerPrompt.into());
app.data.sonarr_data.selected_block =
BlockSelectionState::new(EDIT_INDEXER_NZB_SELECTION_BLOCKS);
app.data.sonarr_data.indexers.set_items(vec![Indexer {
protocol: "usenet".into(),
..indexer()
}]);
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexersUi::draw(f, app, f.area());
});
insta::assert_snapshot!(output);
}
#[test]
fn test_indexers_ui_renders_edit_torrent_indexer_over_indexers() {
let mut app = App::test_default_fully_populated();
app.push_navigation_stack(ActiveSonarrBlock::EditIndexerPrompt.into());
app.data.sonarr_data.selected_block =
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
IndexersUi::draw(f, app, f.area());
@@ -0,0 +1,42 @@
---
source: src/ui/sonarr_ui/indexers/edit_indexer_ui_tests.rs
expression: output
---
╭──────────────────────────────────────────────── Edit Indexer ─────────────────────────────────────────────────╮
│ │
│ ╭─────────────────────────╮ ╭─────────────────────────╮ │
│ Name: │DrunkenSlug │ URL: │http://127.0.0.1:9696/1/ │ │
│ ╰─────────────────────────╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable RSS: │ ✔ │ API Key: │someApiKey │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Automatic Search: │ ✔ │ Seed Ratio: │ratio │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Interactive Search: │ ✔ │ Tags: │25 │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭─────────────────────────╮ │
│ Indexer Priority ▴▾: │1 │ │
│ ╰─────────────────────────╯ │
│ │
│ │
│ │
│ │
│ ╭───────────────────────────╮╭──────────────────────────╮ │
│ │ Save ││ Cancel │ │
│ ╰───────────────────────────╯╰──────────────────────────╯ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -18,16 +18,16 @@ expression: output
╭──────────────────────────────────────────────── Edit Indexer ─────────────────────────────────────────────────╮
│ │
│ ╭─────────────────────────╮ ╭─────────────────────────╮ │
│ Name: │Test Indexer │ URL: │https://test.indexer.com │ │
│ Name: │DrunkenSlug │ URL: │http://127.0.0.1:9696/1/ │ │
│ ╰─────────────────────────╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable RSS: │ ✔ │ API Key: │test-api-key │ │
│ Enable RSS: │ ✔ │ API Key: │someApiKey │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Automatic Search: │ │ Tags: │ │ │
│ Enable Automatic Search: │ │ Tags: │25 │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Interactive Search: │ │ Indexer Priority ▴▾: │25 │ │
│ Enable Interactive Search: │ │ Indexer Priority ▴▾: │1 │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ │
│ │
@@ -0,0 +1,42 @@
---
source: src/ui/sonarr_ui/indexers/edit_indexer_ui_tests.rs
expression: output
---
╭──────────────────────────────────────────────── Edit Indexer ─────────────────────────────────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -21,16 +21,16 @@ expression: output
│ │
│ │
│ ╭────────────────────────────────╮ │
│ Minimum Age (minutes) ▴▾: │0 │ │
│ Minimum Age (minutes) ▴▾: │1 │ │
│ ╰────────────────────────────────╯ │
│ ╭────────────────────────────────╮ │
│ Retention (days) ▴▾: │0 │ │
│ Retention (days) ▴▾: │1 │ │
│ ╰────────────────────────────────╯ │
│ ╭────────────────────────────────╮ │
│ Maximum Size (MB) ▴▾: │0 │ │
│ Maximum Size (MB) ▴▾: │12345 │ │
│ ╰────────────────────────────────╯ │
│ ╭────────────────────────────────╮ │
│ RSS Sync Interval (minutes) ▴▾: │0 │ │
│ RSS Sync Interval (minutes) ▴▾: │60 │ │
│ ╰────────────────────────────────╯ │
│ │
│ │
@@ -0,0 +1,38 @@
---
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Indexer RSS Automatic Search Interactive Search Priority Tags
=> Test Indexer Enabled Enabled Enabled 25 alex
╭──────────────────── Delete Indexer ─────────────────────╮
│ Do you really want to delete this indexer: │
│ Test Indexer? │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│╭────────────────────────────╮╭───────────────────────────╮│
││ Yes ││ No ││
│╰────────────────────────────╯╰───────────────────────────╯│
╰───────────────────────────────────────────────────────────╯
@@ -4,5 +4,4 @@ expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Indexer RSS Automatic Search Interactive Search Priority Tags
=> Test Indexer 1 Enabled Enabled Enabled 25
Test Indexer 2 Disabled Disabled Disabled 0
=> Test Indexer Enabled Enabled Enabled 25 alex
@@ -0,0 +1,35 @@
---
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Indexer RSS Automatic Search Interactive Search Priority Tags
=> Test Indexer Enabled Enabled Enabled 25 alex
╭─────────────── Error ───────────────╮
│ error │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────╯
@@ -0,0 +1,42 @@
---
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Indexer RSS Automatic Search Interactive Search Priority Tags
=> Test Indexer Enabled Enabled Enabled 25 alex
╭──────────────────────────────────────────────── Edit Indexer ─────────────────────────────────────────────────╮
│ │
│ ╭─────────────────────────╮ ╭─────────────────────────╮ │
│ Name: │DrunkenSlug │ URL: │http://127.0.0.1:9696/1/ │ │
│ ╰─────────────────────────╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable RSS: │ ✔ │ API Key: │someApiKey │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Automatic Search: │ ✔ │ Seed Ratio: │ratio │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Interactive Search: │ ✔ │ Tags: │25 │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭─────────────────────────╮ │
│ Indexer Priority ▴▾: │1 │ │
│ ╰─────────────────────────╯ │
│ │
│ │
│ │
│ │
│ ╭───────────────────────────╮╭──────────────────────────╮ │
│ │ Save ││ Cancel │ │
│ ╰───────────────────────────╯╰──────────────────────────╯ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,42 @@
---
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Indexer RSS Automatic Search Interactive Search Priority Tags
=> Test Indexer Enabled Enabled Enabled 25 alex
╭──────────────────────────────────────────────── Edit Indexer ─────────────────────────────────────────────────╮
│ │
│ ╭─────────────────────────╮ ╭─────────────────────────╮ │
│ Name: │DrunkenSlug │ URL: │http://127.0.0.1:9696/1/ │ │
│ ╰─────────────────────────╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable RSS: │ ✔ │ API Key: │someApiKey │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Automatic Search: │ ✔ │ Tags: │25 │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ ╭───╮ ╭─────────────────────────╮ │
│ Enable Interactive Search: │ ✔ │ Indexer Priority ▴▾: │1 │ │
│ ╰───╯ ╰─────────────────────────╯ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ ╭───────────────────────────╮╭──────────────────────────╮ │
│ │ Save ││ Cancel │ │
│ ╰───────────────────────────╯╰──────────────────────────╯ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,35 @@
---
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Loading ...
╭ Testing Indexer ────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────╯
@@ -0,0 +1,35 @@
---
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Indexer RSS Automatic Search Interactive Search Priority Tags
=> Test Indexer Enabled Enabled Enabled 25 alex
╭ Testing Indexer ────────────────────╮
│ │
│ │
│ Loading ... │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
expression: output
---
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Indexer RSS Automatic Search Interactive Search Priority Tags
=> Test Indexer Enabled Enabled Enabled 25 alex
╭ Test All Indexers ─────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Indexer Pass/Fail Failure Messages │
│=> DrunkenSlug ❌ Some failure │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,48 @@
---
source: src/ui/sonarr_ui/indexers/test_all_indexers_ui_tests.rs
expression: output
---
╭ Test All Indexers ─────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Indexer Pass/Fail Failure Messages │
│=> DrunkenSlug ❌ Some failure │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Some files were not shown because too many files have changed in this diff Show More