test(sonarr): pin table search, filter and selection behaviour
Sonarr handler tests never asserted which block the search and filter keys push, so transposing searching_block and filtering_block in a TableHandlingConfig went undetected. Add a search key test for each of the six searchable tables and a filter key test for each of the four filterable ones, covering library, history, series details and season details. No test moved a table or list selection off index 0 either, which made current_selection() and items[0] indistinguishable. Select a non-zero index in the tests covering every handler that reads a selected row, adding a decoy entry at index 0 so existing expected values stay meaningful. The modal list selections in the add and edit series prompts are a separate gap that a table-only sweep misses, so those are covered too. Several fixtures also asserted against a default value, so the expected result was indistinguishable from an unset field. The system tasks now use two distinct non-default task names, the season monitoring and manual search expectations use distinct non-zero ids, and the add and edit series bodies expect a non-default series type and monitor with distinct quality and language profile ids so the two lookups cannot be transposed.
This commit is contained in:
14 files changed
+985
-137
No files matched your search
@@ -158,7 +158,7 @@ mod tests {
|
||||
#[case(
|
||||
ActiveSonarrBlock::Blocklist,
|
||||
ActiveSonarrBlock::DeleteBlocklistItemPrompt,
|
||||
SonarrEvent::DeleteBlocklistItem(3)
|
||||
SonarrEvent::DeleteBlocklistItem(2)
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::Blocklist,
|
||||
@@ -172,6 +172,7 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.blocklist.set_items(blocklist_vec());
|
||||
app.data.sonarr_data.blocklist.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(base_route.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
@@ -356,7 +357,7 @@ mod tests {
|
||||
#[case(
|
||||
ActiveSonarrBlock::Blocklist,
|
||||
ActiveSonarrBlock::DeleteBlocklistItemPrompt,
|
||||
SonarrEvent::DeleteBlocklistItem(3)
|
||||
SonarrEvent::DeleteBlocklistItem(2)
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::Blocklist,
|
||||
@@ -370,6 +371,7 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.blocklist.set_items(blocklist_vec());
|
||||
app.data.sonarr_data.blocklist.select_index(Some(1));
|
||||
app.push_navigation_stack(base_route.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
@@ -543,6 +545,7 @@ mod tests {
|
||||
fn test_extract_blocklist_item_id() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.blocklist.set_items(blocklist_vec());
|
||||
app.data.sonarr_data.blocklist.select_index(Some(1));
|
||||
|
||||
let blocklist_item_id = BlocklistHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
@@ -552,7 +555,7 @@ mod tests {
|
||||
)
|
||||
.extract_blocklist_item_id();
|
||||
|
||||
assert_eq!(blocklist_item_id, 3);
|
||||
assert_eq!(blocklist_item_id, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -153,11 +153,14 @@ mod tests {
|
||||
#[case] expected_action: SonarrEvent,
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.downloads
|
||||
.set_items(vec![download_record()]);
|
||||
app.data.sonarr_data.downloads.set_items(vec![
|
||||
DownloadRecord {
|
||||
id: 999,
|
||||
..download_record()
|
||||
},
|
||||
download_record(),
|
||||
]);
|
||||
app.data.sonarr_data.downloads.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(base_route.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
@@ -350,11 +353,14 @@ mod tests {
|
||||
#[case] expected_action: SonarrEvent,
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.downloads
|
||||
.set_items(vec![download_record()]);
|
||||
app.data.sonarr_data.downloads.set_items(vec![
|
||||
DownloadRecord {
|
||||
id: 999,
|
||||
..download_record()
|
||||
},
|
||||
download_record(),
|
||||
]);
|
||||
app.data.sonarr_data.downloads.select_index(Some(1));
|
||||
app.push_navigation_stack(base_route.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
@@ -408,11 +414,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_extract_download_id() {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.downloads
|
||||
.set_items(vec![download_record()]);
|
||||
app.data.sonarr_data.downloads.set_items(vec![
|
||||
DownloadRecord {
|
||||
id: 999,
|
||||
..download_record()
|
||||
},
|
||||
download_record(),
|
||||
]);
|
||||
app.data.sonarr_data.downloads.select_index(Some(1));
|
||||
|
||||
let download_id = DownloadsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
|
||||
@@ -199,6 +199,40 @@ mod tests {
|
||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::History.into());
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_history_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.history.set_items(history_vec());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
|
||||
HistoryHandler::new(
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::History,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::SearchHistory.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_filter_history_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.history.set_items(history_vec());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
|
||||
HistoryHandler::new(
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::History,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::FilterHistory.into());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -11,7 +11,7 @@ mod tests {
|
||||
use crate::handlers::sonarr_handlers::sonarr_handler_test_utils::utils::indexer;
|
||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EDIT_INDEXER_BLOCKS};
|
||||
use crate::models::servarr_models::EditIndexerParams;
|
||||
use crate::models::servarr_models::{EditIndexerParams, Indexer};
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
use strum::IntoEnumIterator;
|
||||
@@ -916,7 +916,14 @@ mod tests {
|
||||
priority: 0,
|
||||
};
|
||||
app.data.sonarr_data.edit_indexer_modal = Some(edit_indexer_modal);
|
||||
app.data.sonarr_data.indexers.set_items(vec![indexer()]);
|
||||
app.data.sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
id: 999,
|
||||
..indexer()
|
||||
},
|
||||
indexer(),
|
||||
]);
|
||||
app.data.sonarr_data.indexers.select_index(Some(1));
|
||||
let expected_edit_indexer_params = EditIndexerParams {
|
||||
indexer_id: 1,
|
||||
name: Some("Test Update".to_owned()),
|
||||
@@ -1758,7 +1765,14 @@ mod tests {
|
||||
priority: 0,
|
||||
};
|
||||
app.data.sonarr_data.edit_indexer_modal = Some(edit_indexer_modal);
|
||||
app.data.sonarr_data.indexers.set_items(vec![indexer()]);
|
||||
app.data.sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
id: 999,
|
||||
..indexer()
|
||||
},
|
||||
indexer(),
|
||||
]);
|
||||
app.data.sonarr_data.indexers.select_index(Some(1));
|
||||
let expected_edit_indexer_params = EditIndexerParams {
|
||||
indexer_id: 1,
|
||||
name: Some("Test Update".to_owned()),
|
||||
@@ -1836,7 +1850,14 @@ mod tests {
|
||||
priority: 0,
|
||||
};
|
||||
app.data.sonarr_data.edit_indexer_modal = Some(edit_indexer_modal);
|
||||
app.data.sonarr_data.indexers.set_items(vec![indexer()]);
|
||||
app.data.sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
id: 999,
|
||||
..indexer()
|
||||
},
|
||||
indexer(),
|
||||
]);
|
||||
app.data.sonarr_data.indexers.select_index(Some(1));
|
||||
let expected_edit_indexer_params = EditIndexerParams {
|
||||
indexer_id: 1,
|
||||
name: Some("Test Update".to_owned()),
|
||||
|
||||
@@ -148,6 +148,11 @@ mod tests {
|
||||
} else {
|
||||
"usenet".to_owned()
|
||||
};
|
||||
let decoy_protocol = if torrent_protocol {
|
||||
"usenet".to_owned()
|
||||
} else {
|
||||
"torrent".to_owned()
|
||||
};
|
||||
let mut expected_edit_indexer_modal = EditIndexerModal {
|
||||
name: "Test".into(),
|
||||
enable_rss: Some(true),
|
||||
@@ -191,7 +196,14 @@ mod tests {
|
||||
fields: Some(fields),
|
||||
..Indexer::default()
|
||||
};
|
||||
sonarr_data.indexers.set_items(vec![indexer]);
|
||||
sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
protocol: decoy_protocol,
|
||||
..Indexer::default()
|
||||
},
|
||||
indexer,
|
||||
]);
|
||||
sonarr_data.indexers.select_index(Some(1));
|
||||
app.data.sonarr_data = sonarr_data;
|
||||
|
||||
IndexersHandler::new(SUBMIT_KEY, &mut app, ActiveSonarrBlock::Indexers, None).handle();
|
||||
@@ -239,7 +251,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_delete_indexer_prompt_confirm_submit() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.indexers.set_items(vec![indexer()]);
|
||||
app.data.sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
id: 999,
|
||||
..indexer()
|
||||
},
|
||||
indexer(),
|
||||
]);
|
||||
app.data.sonarr_data.indexers.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::DeleteIndexerPrompt.into());
|
||||
@@ -538,7 +557,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_delete_indexer_prompt_confirm() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.indexers.set_items(vec![indexer()]);
|
||||
app.data.sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
id: 999,
|
||||
..indexer()
|
||||
},
|
||||
indexer(),
|
||||
]);
|
||||
app.data.sonarr_data.indexers.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::DeleteIndexerPrompt.into());
|
||||
|
||||
@@ -649,7 +675,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_extract_indexer_id() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.indexers.set_items(vec![indexer()]);
|
||||
app.data.sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
id: 999,
|
||||
..indexer()
|
||||
},
|
||||
indexer(),
|
||||
]);
|
||||
app.data.sonarr_data.indexers.select_index(Some(1));
|
||||
|
||||
let indexer_id = IndexersHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
|
||||
@@ -1144,22 +1144,35 @@ mod tests {
|
||||
add_series_modal.root_folder_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.quality_profile_list
|
||||
.set_items(vec!["HD - 1080p".to_owned()]);
|
||||
.set_items(vec!["Any".to_owned(), "HD - 1080p".to_owned()]);
|
||||
add_series_modal.quality_profile_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.language_profile_list
|
||||
.set_items(vec!["English".to_owned()]);
|
||||
.set_items(vec!["Any".to_owned(), "English".to_owned()]);
|
||||
add_series_modal.language_profile_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.monitor_list
|
||||
.set_items(Vec::from_iter(SeriesMonitor::iter()));
|
||||
add_series_modal.monitor_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.series_type_list
|
||||
.set_items(Vec::from_iter(SeriesType::iter()));
|
||||
add_series_modal.series_type_list.state.select(Some(1));
|
||||
app.data.sonarr_data.add_series_modal = Some(add_series_modal);
|
||||
app.data.sonarr_data.quality_profile_map =
|
||||
BiMap::from_iter([(2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map = BiMap::from_iter([(2222, "English".to_owned())]);
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter([(3333, "Any".to_owned()), (4444, "English".to_owned())]);
|
||||
let mut add_searched_series = StatefulTable::default();
|
||||
add_searched_series.set_items(vec![add_series_search_result()]);
|
||||
add_searched_series.set_items(vec![
|
||||
AddSeriesSearchResult {
|
||||
tvdb_id: 999,
|
||||
title: HorizontallyScrollableText::from("Decoy"),
|
||||
..add_series_search_result()
|
||||
},
|
||||
add_series_search_result(),
|
||||
]);
|
||||
add_searched_series.select_index(Some(1));
|
||||
app.data.sonarr_data.add_searched_series = Some(add_searched_series);
|
||||
let expected_add_series_body = AddSeriesBody {
|
||||
tvdb_id: 1234,
|
||||
@@ -1167,13 +1180,13 @@ mod tests {
|
||||
monitored: true,
|
||||
root_folder_path: "/nfs2".to_owned(),
|
||||
quality_profile_id: 2222,
|
||||
language_profile_id: 2222,
|
||||
series_type: SeriesType::Standard,
|
||||
language_profile_id: 4444,
|
||||
series_type: SeriesType::Daily,
|
||||
season_folder: true,
|
||||
tags: Vec::default(),
|
||||
tag_input_string: Some("usenet, testing".to_owned()),
|
||||
add_options: AddSeriesOptions {
|
||||
monitor: SeriesMonitor::All,
|
||||
monitor: SeriesMonitor::Unknown,
|
||||
search_for_cutoff_unmet_episodes: true,
|
||||
search_for_missing_episodes: true,
|
||||
},
|
||||
@@ -1622,22 +1635,35 @@ mod tests {
|
||||
add_series_modal.root_folder_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.quality_profile_list
|
||||
.set_items(vec!["HD - 1080p".to_owned()]);
|
||||
.set_items(vec!["Any".to_owned(), "HD - 1080p".to_owned()]);
|
||||
add_series_modal.quality_profile_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.language_profile_list
|
||||
.set_items(vec!["English".to_owned()]);
|
||||
.set_items(vec!["Any".to_owned(), "English".to_owned()]);
|
||||
add_series_modal.language_profile_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.monitor_list
|
||||
.set_items(Vec::from_iter(SeriesMonitor::iter()));
|
||||
add_series_modal.monitor_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.series_type_list
|
||||
.set_items(Vec::from_iter(SeriesType::iter()));
|
||||
add_series_modal.series_type_list.state.select(Some(1));
|
||||
app.data.sonarr_data.add_series_modal = Some(add_series_modal);
|
||||
app.data.sonarr_data.quality_profile_map =
|
||||
BiMap::from_iter([(2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map = BiMap::from_iter([(2222, "English".to_owned())]);
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter([(3333, "Any".to_owned()), (4444, "English".to_owned())]);
|
||||
let mut add_searched_series = StatefulTable::default();
|
||||
add_searched_series.set_items(vec![add_series_search_result()]);
|
||||
add_searched_series.set_items(vec![
|
||||
AddSeriesSearchResult {
|
||||
tvdb_id: 999,
|
||||
title: HorizontallyScrollableText::from("Decoy"),
|
||||
..add_series_search_result()
|
||||
},
|
||||
add_series_search_result(),
|
||||
]);
|
||||
add_searched_series.select_index(Some(1));
|
||||
app.data.sonarr_data.add_searched_series = Some(add_searched_series);
|
||||
let expected_add_series_body = AddSeriesBody {
|
||||
tvdb_id: 1234,
|
||||
@@ -1645,13 +1671,13 @@ mod tests {
|
||||
monitored: true,
|
||||
root_folder_path: "/nfs2".to_owned(),
|
||||
quality_profile_id: 2222,
|
||||
language_profile_id: 2222,
|
||||
series_type: SeriesType::Standard,
|
||||
language_profile_id: 4444,
|
||||
series_type: SeriesType::Daily,
|
||||
season_folder: true,
|
||||
tags: Vec::default(),
|
||||
tag_input_string: Some("usenet, testing".to_owned()),
|
||||
add_options: AddSeriesOptions {
|
||||
monitor: SeriesMonitor::All,
|
||||
monitor: SeriesMonitor::Unknown,
|
||||
search_for_cutoff_unmet_episodes: true,
|
||||
search_for_missing_episodes: true,
|
||||
},
|
||||
@@ -1753,21 +1779,35 @@ mod tests {
|
||||
add_series_modal.root_folder_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.quality_profile_list
|
||||
.set_items(vec!["HD - 1080p".to_owned()]);
|
||||
.set_items(vec!["Any".to_owned(), "HD - 1080p".to_owned()]);
|
||||
add_series_modal.quality_profile_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.language_profile_list
|
||||
.set_items(vec!["English".to_owned()]);
|
||||
.set_items(vec!["Any".to_owned(), "English".to_owned()]);
|
||||
add_series_modal.language_profile_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.monitor_list
|
||||
.set_items(Vec::from_iter(SeriesMonitor::iter()));
|
||||
add_series_modal.monitor_list.state.select(Some(1));
|
||||
add_series_modal
|
||||
.series_type_list
|
||||
.set_items(Vec::from_iter(SeriesType::iter()));
|
||||
add_series_modal.series_type_list.state.select(Some(1));
|
||||
app.data.sonarr_data.add_series_modal = Some(add_series_modal);
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter([(2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map = BiMap::from_iter([(2222, "English".to_owned())]);
|
||||
app.data.sonarr_data.quality_profile_map =
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter([(3333, "Any".to_owned()), (4444, "English".to_owned())]);
|
||||
let mut add_searched_series = StatefulTable::default();
|
||||
add_searched_series.set_items(vec![add_series_search_result()]);
|
||||
add_searched_series.set_items(vec![
|
||||
AddSeriesSearchResult {
|
||||
tvdb_id: 999,
|
||||
title: HorizontallyScrollableText::from("Decoy"),
|
||||
..add_series_search_result()
|
||||
},
|
||||
add_series_search_result(),
|
||||
]);
|
||||
add_searched_series.select_index(Some(1));
|
||||
app.data.sonarr_data.add_searched_series = Some(add_searched_series);
|
||||
let expected_add_series_body = AddSeriesBody {
|
||||
tvdb_id: 1234,
|
||||
@@ -1775,13 +1815,13 @@ mod tests {
|
||||
monitored: true,
|
||||
root_folder_path: "/nfs2".to_owned(),
|
||||
quality_profile_id: 2222,
|
||||
language_profile_id: 2222,
|
||||
series_type: SeriesType::Standard,
|
||||
language_profile_id: 4444,
|
||||
series_type: SeriesType::Daily,
|
||||
season_folder: true,
|
||||
tags: Vec::default(),
|
||||
tag_input_string: Some("usenet, testing".to_owned()),
|
||||
add_options: AddSeriesOptions {
|
||||
monitor: SeriesMonitor::All,
|
||||
monitor: SeriesMonitor::Unknown,
|
||||
search_for_cutoff_unmet_episodes: true,
|
||||
search_for_missing_episodes: true,
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ mod tests {
|
||||
use crate::handlers::sonarr_handlers::library::delete_series_handler::DeleteSeriesHandler;
|
||||
use crate::handlers::sonarr_handlers::sonarr_handler_test_utils::utils::series;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, DELETE_SERIES_BLOCKS};
|
||||
use crate::models::sonarr_models::DeleteSeriesParams;
|
||||
use crate::models::sonarr_models::{DeleteSeriesParams, Series};
|
||||
|
||||
mod test_handle_scroll_up_and_down {
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -133,7 +133,14 @@ mod tests {
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.data.sonarr_data.delete_series_files = true;
|
||||
app.data.sonarr_data.add_list_exclusion = true;
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
let expected_delete_series_params = DeleteSeriesParams {
|
||||
id: 1,
|
||||
delete_series_files: true,
|
||||
@@ -278,7 +285,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveSonarrBlock::DeleteSeriesPrompt.into());
|
||||
app.data.sonarr_data.delete_series_files = true;
|
||||
app.data.sonarr_data.add_list_exclusion = true;
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
let expected_delete_series_params = DeleteSeriesParams {
|
||||
id: 1,
|
||||
delete_series_files: true,
|
||||
@@ -345,7 +359,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_build_delete_series_params() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.delete_series_files = true;
|
||||
app.data.sonarr_data.add_list_exclusion = true;
|
||||
let expected_delete_series_params = DeleteSeriesParams {
|
||||
|
||||
@@ -785,29 +785,39 @@ mod tests {
|
||||
edit_series
|
||||
.quality_profile_list
|
||||
.set_items(vec!["Any".to_owned(), "HD - 1080p".to_owned()]);
|
||||
edit_series.quality_profile_list.state.select(Some(1));
|
||||
edit_series
|
||||
.language_profile_list
|
||||
.set_items(vec!["Any".to_owned(), "English".to_owned()]);
|
||||
edit_series.language_profile_list.state.select(Some(1));
|
||||
edit_series
|
||||
.series_type_list
|
||||
.set_items(Vec::from_iter(SeriesType::iter()));
|
||||
edit_series.series_type_list.state.select(Some(1));
|
||||
app.data.sonarr_data.edit_series_modal = Some(edit_series);
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
Series {
|
||||
monitored: false,
|
||||
season_folder: false,
|
||||
..series()
|
||||
}]);
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.quality_profile_map =
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "English".to_owned())]);
|
||||
BiMap::from_iter([(3333, "Any".to_owned()), (4444, "English".to_owned())]);
|
||||
let expected_edit_series_params = EditSeriesParams {
|
||||
series_id: 1,
|
||||
monitored: Some(false),
|
||||
use_season_folders: Some(false),
|
||||
series_type: Some(SeriesType::Standard),
|
||||
quality_profile_id: Some(1111),
|
||||
language_profile_id: Some(1111),
|
||||
series_type: Some(SeriesType::Daily),
|
||||
quality_profile_id: Some(2222),
|
||||
language_profile_id: Some(4444),
|
||||
root_folder_path: Some("/nfs/Test Path".to_owned()),
|
||||
tag_input_string: Some("usenet, testing".to_owned()),
|
||||
..EditSeriesParams::default()
|
||||
@@ -1298,29 +1308,39 @@ mod tests {
|
||||
edit_series
|
||||
.quality_profile_list
|
||||
.set_items(vec!["Any".to_owned(), "HD - 1080p".to_owned()]);
|
||||
edit_series.quality_profile_list.state.select(Some(1));
|
||||
edit_series
|
||||
.language_profile_list
|
||||
.set_items(vec!["Any".to_owned(), "English".to_owned()]);
|
||||
edit_series.language_profile_list.state.select(Some(1));
|
||||
edit_series
|
||||
.series_type_list
|
||||
.set_items(Vec::from_iter(SeriesType::iter()));
|
||||
edit_series.series_type_list.state.select(Some(1));
|
||||
app.data.sonarr_data.edit_series_modal = Some(edit_series);
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
Series {
|
||||
monitored: false,
|
||||
season_folder: false,
|
||||
..series()
|
||||
}]);
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.quality_profile_map =
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "English".to_owned())]);
|
||||
BiMap::from_iter([(3333, "Any".to_owned()), (4444, "English".to_owned())]);
|
||||
let expected_edit_series_params = EditSeriesParams {
|
||||
series_id: 1,
|
||||
monitored: Some(false),
|
||||
use_season_folders: Some(false),
|
||||
series_type: Some(SeriesType::Standard),
|
||||
quality_profile_id: Some(1111),
|
||||
language_profile_id: Some(1111),
|
||||
series_type: Some(SeriesType::Daily),
|
||||
quality_profile_id: Some(2222),
|
||||
language_profile_id: Some(4444),
|
||||
root_folder_path: Some("/nfs/Test Path".to_owned()),
|
||||
tag_input_string: Some("usenet, testing".to_owned()),
|
||||
..EditSeriesParams::default()
|
||||
@@ -1395,29 +1415,39 @@ mod tests {
|
||||
edit_series
|
||||
.quality_profile_list
|
||||
.set_items(vec!["Any".to_owned(), "HD - 1080p".to_owned()]);
|
||||
edit_series.quality_profile_list.state.select(Some(1));
|
||||
edit_series
|
||||
.language_profile_list
|
||||
.set_items(vec!["Any".to_owned(), "English".to_owned()]);
|
||||
edit_series.language_profile_list.state.select(Some(1));
|
||||
edit_series
|
||||
.series_type_list
|
||||
.set_items(Vec::from_iter(SeriesType::iter()));
|
||||
edit_series.series_type_list.state.select(Some(1));
|
||||
app.data.sonarr_data.edit_series_modal = Some(edit_series);
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
Series {
|
||||
monitored: false,
|
||||
season_folder: false,
|
||||
..series()
|
||||
}]);
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.quality_profile_map =
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "HD - 1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter([(1111, "Any".to_owned()), (2222, "English".to_owned())]);
|
||||
BiMap::from_iter([(3333, "Any".to_owned()), (4444, "English".to_owned())]);
|
||||
let expected_edit_series_params = EditSeriesParams {
|
||||
series_id: 1,
|
||||
monitored: Some(false),
|
||||
use_season_folders: Some(false),
|
||||
series_type: Some(SeriesType::Standard),
|
||||
quality_profile_id: Some(1111),
|
||||
language_profile_id: Some(1111),
|
||||
series_type: Some(SeriesType::Daily),
|
||||
quality_profile_id: Some(2222),
|
||||
language_profile_id: Some(4444),
|
||||
root_folder_path: Some("/nfs/Test Path".to_owned()),
|
||||
tag_input_string: Some("usenet, testing".to_owned()),
|
||||
..EditSeriesParams::default()
|
||||
|
||||
@@ -11,7 +11,7 @@ mod tests {
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::SonarrReleaseDownloadBody;
|
||||
use crate::models::sonarr_models::{Episode, SonarrRelease, SonarrReleaseDownloadBody};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
@@ -229,7 +229,21 @@ mod tests {
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![episode()]);
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
..episode()
|
||||
},
|
||||
episode(),
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
@@ -248,6 +262,61 @@ mod tests {
|
||||
fn test_manual_episode_search_confirm_prompt_confirm_submit() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_releases
|
||||
.set_items(vec![
|
||||
SonarrRelease {
|
||||
guid: "decoy guid".to_owned(),
|
||||
indexer_id: 999,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
SonarrRelease {
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_releases
|
||||
.select_index(Some(1));
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
..episode()
|
||||
},
|
||||
Episode { id: 5, ..episode() },
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualEpisodeSearch.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualEpisodeSearchConfirmPrompt.into());
|
||||
@@ -265,9 +334,9 @@ mod tests {
|
||||
assert_some_eq_x!(
|
||||
&app.data.sonarr_data.prompt_confirm_action,
|
||||
&SonarrEvent::DownloadRelease(SonarrReleaseDownloadBody {
|
||||
guid: String::new(),
|
||||
indexer_id: 0,
|
||||
episode_id: Some(0),
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
episode_id: Some(5),
|
||||
..SonarrReleaseDownloadBody::default()
|
||||
})
|
||||
);
|
||||
@@ -546,7 +615,21 @@ mod tests {
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![episode()]);
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
..episode()
|
||||
},
|
||||
episode(),
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::AutomaticallySearchEpisodePrompt.into());
|
||||
@@ -571,6 +654,61 @@ mod tests {
|
||||
fn test_episode_details_manual_search_confirm_prompt_confirm_confirm_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_releases
|
||||
.set_items(vec![
|
||||
SonarrRelease {
|
||||
guid: "decoy guid".to_owned(),
|
||||
indexer_id: 999,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
SonarrRelease {
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episode_releases
|
||||
.select_index(Some(1));
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
..episode()
|
||||
},
|
||||
Episode { id: 5, ..episode() },
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualEpisodeSearch.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualEpisodeSearchConfirmPrompt.into());
|
||||
@@ -588,9 +726,9 @@ mod tests {
|
||||
assert_some_eq_x!(
|
||||
&app.data.sonarr_data.prompt_confirm_action,
|
||||
&SonarrEvent::DownloadRelease(SonarrReleaseDownloadBody {
|
||||
guid: String::new(),
|
||||
indexer_id: 0,
|
||||
episode_id: Some(0),
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
episode_id: Some(5),
|
||||
..SonarrReleaseDownloadBody::default()
|
||||
})
|
||||
);
|
||||
@@ -631,7 +769,14 @@ mod tests {
|
||||
fn test_extract_episode_id() {
|
||||
let mut app = App::test_default();
|
||||
let mut season_details_modal = SeasonDetailsModal::default();
|
||||
season_details_modal.episodes.set_items(vec![episode()]);
|
||||
season_details_modal.episodes.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
..episode()
|
||||
},
|
||||
episode(),
|
||||
]);
|
||||
season_details_modal.episodes.select_index(Some(1));
|
||||
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
|
||||
|
||||
let episode_id = EpisodeDetailsHandler::new(
|
||||
|
||||
@@ -380,6 +380,14 @@ mod tests {
|
||||
fn test_toggle_monitoring_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.is_routing = false;
|
||||
|
||||
@@ -396,7 +404,7 @@ mod tests {
|
||||
assert!(app.is_routing);
|
||||
assert_some_eq_x!(
|
||||
&app.data.sonarr_data.prompt_confirm_action,
|
||||
&SonarrEvent::ToggleSeriesMonitoring(0)
|
||||
&SonarrEvent::ToggleSeriesMonitoring(1)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -508,6 +516,48 @@ mod tests {
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_series_key() {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.set_items(vec![Series::default()]);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
|
||||
LibraryHandler::new(
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::Series,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::SearchSeries.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_filter_series_key() {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.set_items(vec![Series::default()]);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
|
||||
LibraryHandler::new(
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::Series,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::FilterSeries.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_update_all_series_prompt_confirm() {
|
||||
let mut app = App::test_default();
|
||||
@@ -663,7 +713,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_extract_series_id() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
|
||||
let series_id = LibraryHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
|
||||
@@ -16,7 +16,9 @@ mod tests {
|
||||
ActiveSonarrBlock, SEASON_DETAILS_BLOCKS,
|
||||
};
|
||||
use crate::models::servarr_models::{Language, Quality, QualityWrapper};
|
||||
use crate::models::sonarr_models::{SonarrRelease, SonarrReleaseDownloadBody};
|
||||
use crate::models::sonarr_models::{
|
||||
Episode, Season, Series, SonarrRelease, SonarrReleaseDownloadBody,
|
||||
};
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
use rstest::rstest;
|
||||
use serde_json::Number;
|
||||
@@ -268,11 +270,11 @@ mod tests {
|
||||
#[rstest]
|
||||
#[case(
|
||||
ActiveSonarrBlock::AutomaticallySearchSeasonPrompt,
|
||||
SonarrEvent::TriggerAutomaticSeasonSearch(0, 0)
|
||||
SonarrEvent::TriggerAutomaticSeasonSearch(7, 3)
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::DeleteEpisodeFilePrompt,
|
||||
SonarrEvent::DeleteEpisodeFile(0)
|
||||
SonarrEvent::DeleteEpisodeFile(9)
|
||||
)]
|
||||
fn test_season_details_prompt_confirm_submit(
|
||||
#[case] prompt_block: ActiveSonarrBlock,
|
||||
@@ -282,6 +284,55 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
episode_file_id: 999,
|
||||
..episode()
|
||||
},
|
||||
Episode {
|
||||
id: 5,
|
||||
episode_file_id: 9,
|
||||
..episode()
|
||||
},
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..Series::default()
|
||||
},
|
||||
Series {
|
||||
id: 7,
|
||||
..Series::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.seasons.set_items(vec![
|
||||
Season {
|
||||
season_number: 999,
|
||||
..Season::default()
|
||||
},
|
||||
Season {
|
||||
season_number: 3,
|
||||
..Season::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.seasons.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
@@ -300,6 +351,55 @@ mod tests {
|
||||
fn test_season_details_manual_search_confirm_prompt_confirm_submit() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.season_releases
|
||||
.set_items(vec![
|
||||
SonarrRelease {
|
||||
guid: "decoy guid".to_owned(),
|
||||
indexer_id: 999,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
SonarrRelease {
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.season_releases
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..Series::default()
|
||||
},
|
||||
Series {
|
||||
id: 7,
|
||||
..Series::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.seasons.set_items(vec![
|
||||
Season {
|
||||
season_number: 999,
|
||||
..Season::default()
|
||||
},
|
||||
Season {
|
||||
season_number: 3,
|
||||
..Season::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.seasons.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualSeasonSearch.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualSeasonSearchConfirmPrompt.into());
|
||||
@@ -317,10 +417,10 @@ mod tests {
|
||||
assert_some_eq_x!(
|
||||
&app.data.sonarr_data.prompt_confirm_action,
|
||||
&SonarrEvent::DownloadRelease(SonarrReleaseDownloadBody {
|
||||
guid: String::new(),
|
||||
indexer_id: 0,
|
||||
series_id: Some(0),
|
||||
season_number: Some(0),
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
series_id: Some(7),
|
||||
season_number: Some(3),
|
||||
..SonarrReleaseDownloadBody::default()
|
||||
})
|
||||
);
|
||||
@@ -539,7 +639,21 @@ mod tests {
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![episode()]);
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
..episode()
|
||||
},
|
||||
episode(),
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonDetails.into());
|
||||
app.is_routing = false;
|
||||
|
||||
@@ -691,14 +805,65 @@ mod tests {
|
||||
assert!(!app.is_routing);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_episodes_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonDetails.into());
|
||||
|
||||
SeasonDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeasonDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::SearchEpisodes.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_season_history_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonHistory.into());
|
||||
|
||||
SeasonDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeasonHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::SearchSeasonHistory.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_filter_season_history_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonHistory.into());
|
||||
|
||||
SeasonDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeasonHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::FilterSeasonHistory.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(
|
||||
ActiveSonarrBlock::AutomaticallySearchSeasonPrompt,
|
||||
SonarrEvent::TriggerAutomaticSeasonSearch(0, 0)
|
||||
SonarrEvent::TriggerAutomaticSeasonSearch(7, 3)
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::DeleteEpisodeFilePrompt,
|
||||
SonarrEvent::DeleteEpisodeFile(0)
|
||||
SonarrEvent::DeleteEpisodeFile(9)
|
||||
)]
|
||||
fn test_season_details_prompt_confirm_confirm_key(
|
||||
#[case] prompt_block: ActiveSonarrBlock,
|
||||
@@ -708,6 +873,55 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
episode_file_id: 999,
|
||||
..episode()
|
||||
},
|
||||
Episode {
|
||||
id: 5,
|
||||
episode_file_id: 9,
|
||||
..episode()
|
||||
},
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..Series::default()
|
||||
},
|
||||
Series {
|
||||
id: 7,
|
||||
..Series::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.seasons.set_items(vec![
|
||||
Season {
|
||||
season_number: 999,
|
||||
..Season::default()
|
||||
},
|
||||
Season {
|
||||
season_number: 3,
|
||||
..Season::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.seasons.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
@@ -732,6 +946,55 @@ mod tests {
|
||||
fn test_season_details_manual_search_confirm_prompt_confirm_confirm_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.season_releases
|
||||
.set_items(vec![
|
||||
SonarrRelease {
|
||||
guid: "decoy guid".to_owned(),
|
||||
indexer_id: 999,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
SonarrRelease {
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
..SonarrRelease::default()
|
||||
},
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.season_releases
|
||||
.select_index(Some(1));
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..Series::default()
|
||||
},
|
||||
Series {
|
||||
id: 7,
|
||||
..Series::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.seasons.set_items(vec![
|
||||
Season {
|
||||
season_number: 999,
|
||||
..Season::default()
|
||||
},
|
||||
Season {
|
||||
season_number: 3,
|
||||
..Season::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.seasons.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualSeasonSearch.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::ManualSeasonSearchConfirmPrompt.into());
|
||||
@@ -749,10 +1012,10 @@ mod tests {
|
||||
assert_some_eq_x!(
|
||||
&app.data.sonarr_data.prompt_confirm_action,
|
||||
&SonarrEvent::DownloadRelease(SonarrReleaseDownloadBody {
|
||||
guid: String::new(),
|
||||
indexer_id: 0,
|
||||
series_id: Some(0),
|
||||
season_number: Some(0),
|
||||
guid: "test guid".to_owned(),
|
||||
indexer_id: 2,
|
||||
series_id: Some(7),
|
||||
season_number: Some(3),
|
||||
..SonarrReleaseDownloadBody::default()
|
||||
})
|
||||
);
|
||||
@@ -793,6 +1056,31 @@ mod tests {
|
||||
fn test_extract_episode_file_id() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.set_items(vec![
|
||||
Episode {
|
||||
episode_file_id: 999,
|
||||
..episode()
|
||||
},
|
||||
Episode {
|
||||
episode_file_id: 9,
|
||||
..episode()
|
||||
},
|
||||
]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.episodes
|
||||
.select_index(Some(1));
|
||||
|
||||
let episode_file_id = SeasonDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
@@ -802,7 +1090,7 @@ mod tests {
|
||||
)
|
||||
.extract_episode_file_id();
|
||||
|
||||
assert_eq!(episode_file_id, 0);
|
||||
assert_eq!(episode_file_id, 9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -823,7 +1111,14 @@ mod tests {
|
||||
fn test_extract_episode_id() {
|
||||
let mut app = App::test_default();
|
||||
let mut season_details_modal = SeasonDetailsModal::default();
|
||||
season_details_modal.episodes.set_items(vec![episode()]);
|
||||
season_details_modal.episodes.set_items(vec![
|
||||
Episode {
|
||||
id: 999,
|
||||
..episode()
|
||||
},
|
||||
episode(),
|
||||
]);
|
||||
season_details_modal.episodes.select_index(Some(1));
|
||||
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
|
||||
|
||||
let episode_id = SeasonDetailsHandler::new(
|
||||
@@ -855,6 +1150,28 @@ mod tests {
|
||||
fn test_extract_series_id_season_number_tuple() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..Series::default()
|
||||
},
|
||||
Series {
|
||||
id: 7,
|
||||
..Series::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.seasons.set_items(vec![
|
||||
Season {
|
||||
season_number: 999,
|
||||
..Season::default()
|
||||
},
|
||||
Season {
|
||||
season_number: 3,
|
||||
..Season::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.seasons.select_index(Some(1));
|
||||
|
||||
let (series_id, season_number) = SeasonDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
@@ -864,8 +1181,8 @@ mod tests {
|
||||
)
|
||||
.extract_series_id_season_number_tuple();
|
||||
|
||||
assert_eq!(series_id, 0);
|
||||
assert_eq!(season_number, 0);
|
||||
assert_eq!(series_id, 7);
|
||||
assert_eq!(season_number, 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -11,8 +11,8 @@ mod tests {
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, SERIES_DETAILS_BLOCKS, SERIES_OVERVIEW_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::Season;
|
||||
use crate::models::sonarr_models::SonarrHistoryItem;
|
||||
use crate::models::sonarr_models::{Season, Series};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::test_handler_delegation;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -190,7 +190,14 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
@@ -516,6 +523,25 @@ mod tests {
|
||||
fn test_toggle_monitoring_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.seasons.set_items(vec![
|
||||
Season {
|
||||
season_number: 999,
|
||||
..season()
|
||||
},
|
||||
Season {
|
||||
season_number: 2,
|
||||
..season()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.seasons.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into());
|
||||
app.is_routing = false;
|
||||
|
||||
@@ -535,7 +561,7 @@ mod tests {
|
||||
assert!(app.is_routing);
|
||||
assert_some_eq_x!(
|
||||
&app.data.sonarr_data.prompt_confirm_action,
|
||||
&SonarrEvent::ToggleSeasonMonitoring(0, 0)
|
||||
&SonarrEvent::ToggleSeasonMonitoring(1, 2)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -696,6 +722,61 @@ mod tests {
|
||||
assert!(!app.is_routing);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_seasons_key() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.seasons.set_items(vec![season()]);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into());
|
||||
|
||||
SeriesDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeriesDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::SearchSeason.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_series_history_key() {
|
||||
let mut app = App::test_default();
|
||||
let mut series_history = StatefulTable::default();
|
||||
series_history.set_items(vec![SonarrHistoryItem::default()]);
|
||||
app.data.sonarr_data.series_history = Some(series_history);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesHistory.into());
|
||||
|
||||
SeriesDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeriesHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::SearchSeriesHistory.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_filter_series_history_key() {
|
||||
let mut app = App::test_default();
|
||||
let mut series_history = StatefulTable::default();
|
||||
series_history.set_items(vec![SonarrHistoryItem::default()]);
|
||||
app.data.sonarr_data.series_history = Some(series_history);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesHistory.into());
|
||||
|
||||
SeriesDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeriesHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveSonarrBlock::FilterSeriesHistory.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(
|
||||
ActiveSonarrBlock::AutomaticallySearchSeriesPrompt,
|
||||
@@ -712,7 +793,14 @@ mod tests {
|
||||
active_sonarr_block: ActiveSonarrBlock,
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
@@ -778,8 +866,25 @@ mod tests {
|
||||
#[test]
|
||||
fn test_extract_series_id_season_number_tuple() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.seasons.set_items(vec![season()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
app.data.sonarr_data.seasons.set_items(vec![
|
||||
Season {
|
||||
season_number: 999,
|
||||
..season()
|
||||
},
|
||||
Season {
|
||||
season_number: 2,
|
||||
..season()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.seasons.select_index(Some(1));
|
||||
|
||||
let series_id_season_number_tuple = SeriesDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
@@ -789,13 +894,20 @@ mod tests {
|
||||
)
|
||||
.extract_series_id_season_number_tuple();
|
||||
|
||||
assert_eq!(series_id_season_number_tuple, (1, 1));
|
||||
assert_eq!(series_id_season_number_tuple, (1, 2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_series_id() {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.data.sonarr_data.series.set_items(vec![
|
||||
Series {
|
||||
id: 999,
|
||||
..series()
|
||||
},
|
||||
series(),
|
||||
]);
|
||||
app.data.sonarr_data.series.select_index(Some(1));
|
||||
|
||||
let series_id = SeriesDetailsHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
|
||||
@@ -323,11 +323,15 @@ mod tests {
|
||||
#[test]
|
||||
fn test_delete_root_folder_prompt_confirm_submit() {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.root_folders
|
||||
.set_items(vec![root_folder()]);
|
||||
app.data.sonarr_data.root_folders.set_items(vec![
|
||||
RootFolder {
|
||||
id: 999,
|
||||
path: "/decoy".to_owned(),
|
||||
..root_folder()
|
||||
},
|
||||
root_folder(),
|
||||
]);
|
||||
app.data.sonarr_data.root_folders.select_index(Some(1));
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::DeleteRootFolderPrompt.into());
|
||||
@@ -595,11 +599,15 @@ mod tests {
|
||||
#[test]
|
||||
fn test_delete_root_folder_prompt_confirm() {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.root_folders
|
||||
.set_items(vec![root_folder()]);
|
||||
app.data.sonarr_data.root_folders.set_items(vec![
|
||||
RootFolder {
|
||||
id: 999,
|
||||
path: "/decoy".to_owned(),
|
||||
..root_folder()
|
||||
},
|
||||
root_folder(),
|
||||
]);
|
||||
app.data.sonarr_data.root_folders.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::DeleteRootFolderPrompt.into());
|
||||
|
||||
@@ -653,11 +661,15 @@ mod tests {
|
||||
#[test]
|
||||
fn test_extract_root_folder_id() {
|
||||
let mut app = App::test_default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.root_folders
|
||||
.set_items(vec![root_folder()]);
|
||||
app.data.sonarr_data.root_folders.set_items(vec![
|
||||
RootFolder {
|
||||
id: 999,
|
||||
path: "/decoy".to_owned(),
|
||||
..root_folder()
|
||||
},
|
||||
root_folder(),
|
||||
]);
|
||||
app.data.sonarr_data.root_folders.select_index(Some(1));
|
||||
|
||||
let root_folder_id = RootFoldersHandler::new(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
|
||||
@@ -694,11 +694,17 @@ mod tests {
|
||||
let mut app = App::test_default();
|
||||
app.data.sonarr_data.updates = ScrollableText::with_string("Test".to_owned());
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.tasks
|
||||
.set_items(vec![SonarrTask::default()]);
|
||||
app.data.sonarr_data.tasks.set_items(vec![
|
||||
SonarrTask {
|
||||
task_name: SonarrTaskName::Backup,
|
||||
..SonarrTask::default()
|
||||
},
|
||||
SonarrTask {
|
||||
task_name: SonarrTaskName::RefreshMonitoredDownloads,
|
||||
..SonarrTask::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.tasks.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SystemTasks.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SystemTaskStartConfirmPrompt.into());
|
||||
|
||||
@@ -713,7 +719,7 @@ mod tests {
|
||||
assert!(app.data.sonarr_data.prompt_confirm);
|
||||
assert_some_eq_x!(
|
||||
&app.data.sonarr_data.prompt_confirm_action,
|
||||
&SonarrEvent::StartTask(SonarrTaskName::default())
|
||||
&SonarrEvent::StartTask(SonarrTaskName::RefreshMonitoredDownloads)
|
||||
);
|
||||
assert_navigation_popped!(app, ActiveSonarrBlock::SystemTasks.into());
|
||||
}
|
||||
@@ -912,11 +918,17 @@ mod tests {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::System.into());
|
||||
app.data.sonarr_data.updates = ScrollableText::with_string("Test".to_owned());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.tasks
|
||||
.set_items(vec![SonarrTask::default()]);
|
||||
app.data.sonarr_data.tasks.set_items(vec![
|
||||
SonarrTask {
|
||||
task_name: SonarrTaskName::Backup,
|
||||
..SonarrTask::default()
|
||||
},
|
||||
SonarrTask {
|
||||
task_name: SonarrTaskName::RefreshMonitoredDownloads,
|
||||
..SonarrTask::default()
|
||||
},
|
||||
]);
|
||||
app.data.sonarr_data.tasks.select_index(Some(1));
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SystemTasks.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SystemTaskStartConfirmPrompt.into());
|
||||
|
||||
@@ -931,7 +943,9 @@ mod tests {
|
||||
assert!(app.data.sonarr_data.prompt_confirm);
|
||||
assert_eq!(
|
||||
app.data.sonarr_data.prompt_confirm_action,
|
||||
Some(SonarrEvent::StartTask(SonarrTaskName::default()))
|
||||
Some(SonarrEvent::StartTask(
|
||||
SonarrTaskName::RefreshMonitoredDownloads
|
||||
))
|
||||
);
|
||||
assert_navigation_popped!(app, ActiveSonarrBlock::SystemTasks.into());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user