feat(handler): Full indexer tab handler support
This commit is contained in:
@@ -20,9 +20,86 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[rstest]
|
||||
fn test_edit_indexer_priority_scroll(#[values(Key::Up, Key::Down)] key: Key) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
key,
|
||||
&mut app,
|
||||
ActiveRadarrBlock::EditIndexerPriorityInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
if key == Key::Up {
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.edit_indexer_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.priority,
|
||||
1
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.edit_indexer_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.priority,
|
||||
0
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
Key::Up,
|
||||
&mut app,
|
||||
ActiveRadarrBlock::EditIndexerPriorityInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.edit_indexer_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.priority,
|
||||
1
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
key,
|
||||
&mut app,
|
||||
ActiveRadarrBlock::EditIndexerPriorityInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.edit_indexer_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.priority,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_edit_indexer_prompt_scroll(#[values(Key::Up, Key::Down)] key: Key) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
@@ -48,6 +125,7 @@ mod tests {
|
||||
#[values(Key::Up, Key::Down)] key: Key,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.is_loading = true;
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.data.radarr_data.selected_block =
|
||||
@@ -75,6 +153,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_name_input_home_end() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
name: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -126,6 +205,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_url_input_home_end() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
url: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -177,6 +257,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_api_key_input_home_end() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
api_key: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -228,6 +309,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_seed_ratio_input_home_end() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
seed_ratio: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -279,6 +361,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_tags_input_home_end() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
tags: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -345,6 +428,7 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_left_right_prompt_toggle(#[values(Key::Left, Key::Right)] key: Key) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.y = EDIT_INDEXER_TORRENT_SELECTION_BLOCKS.len() - 1;
|
||||
@@ -386,6 +470,7 @@ mod tests {
|
||||
#[case] right_block: ActiveRadarrBlock,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.y = starting_y_index;
|
||||
@@ -426,6 +511,11 @@ mod tests {
|
||||
ActiveRadarrBlock::EditIndexerToggleEnableAutomaticSearch,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput
|
||||
)]
|
||||
#[case(
|
||||
3,
|
||||
ActiveRadarrBlock::EditIndexerToggleEnableInteractiveSearch,
|
||||
ActiveRadarrBlock::EditIndexerPriorityInput
|
||||
)]
|
||||
fn test_left_right_block_toggle_nzb(
|
||||
#[values(Key::Left, Key::Right)] key: Key,
|
||||
#[case] starting_y_index: usize,
|
||||
@@ -433,6 +523,7 @@ mod tests {
|
||||
#[case] right_block: ActiveRadarrBlock,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_NZB_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.y = starting_y_index;
|
||||
@@ -458,18 +549,19 @@ mod tests {
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_left_right_block_toggle_nzb_empty_row_to_prompt_confirm(
|
||||
fn test_left_right_block_toggle_torren_empty_row_to_prompt_confirm(
|
||||
#[values(Key::Left, Key::Right)] key: Key,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_NZB_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.y = 3;
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.y = 4;
|
||||
app.data.radarr_data.prompt_confirm = false;
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
ActiveRadarrBlock::EditIndexerToggleEnableInteractiveSearch
|
||||
ActiveRadarrBlock::EditIndexerPriorityInput
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
@@ -491,6 +583,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_name_input_left_right_keys() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
name: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -542,6 +635,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_url_input_left_right_keys() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
url: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -593,6 +687,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_api_key_input_left_right_keys() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
api_key: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -644,6 +739,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_seed_ratio_input_left_right_keys() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
seed_ratio: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -695,6 +791,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_tags_input_left_right_keys() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
tags: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -857,6 +954,7 @@ mod tests {
|
||||
#[case] block: ActiveRadarrBlock,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||
app.data.radarr_data.selected_block =
|
||||
@@ -879,9 +977,35 @@ mod tests {
|
||||
assert!(app.should_ignore_quit_key);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_indexer_priority_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.set_index(0, 4);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveRadarrBlock::EditIndexerPriorityInput.into()
|
||||
);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_indexer_toggle_enable_rss_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
@@ -934,6 +1058,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_toggle_enable_automatic_search_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
@@ -986,6 +1111,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_toggle_enable_interactive_search_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
@@ -1038,6 +1164,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_name_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.should_ignore_quit_key = true;
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
name: "Test".into(),
|
||||
@@ -1073,6 +1200,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_url_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.should_ignore_quit_key = true;
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
url: "Test".into(),
|
||||
@@ -1108,6 +1236,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_api_key_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.should_ignore_quit_key = true;
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
api_key: "Test".into(),
|
||||
@@ -1143,6 +1272,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_seed_ratio_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.should_ignore_quit_key = true;
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
seed_ratio: "Test".into(),
|
||||
@@ -1178,6 +1308,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_tags_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.should_ignore_quit_key = true;
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
tags: "Test".into(),
|
||||
@@ -1249,7 +1380,8 @@ mod tests {
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
ActiveRadarrBlock::EditIndexerPriorityInput
|
||||
)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
@@ -1283,6 +1415,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_name_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
name: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -1312,6 +1445,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_url_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
url: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -1341,6 +1475,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_api_key_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
api_key: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -1370,6 +1505,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_seed_ratio_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
seed_ratio: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -1399,6 +1535,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_tags_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
|
||||
tags: "Test".into(),
|
||||
..EditIndexerModal::default()
|
||||
@@ -1428,6 +1565,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_name_input_char_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
@@ -1454,6 +1592,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_url_input_char_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
@@ -1480,6 +1619,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_api_key_input_char_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
@@ -1506,6 +1646,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_seed_ratio_input_char_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
@@ -1532,6 +1673,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_tags_input_char_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
@@ -1588,7 +1730,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_indexer_settings_handler_accepts() {
|
||||
fn test_edit_indexer_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if EDIT_INDEXER_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(EditIndexerHandler::accepts(active_radarr_block));
|
||||
@@ -1601,6 +1743,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_handler_is_not_ready_when_loading() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = EditIndexerHandler::with(
|
||||
@@ -1616,6 +1759,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_handler_is_not_ready_when_edit_indexer_modal_is_none() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = EditIndexerHandler::with(
|
||||
@@ -1631,6 +1775,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_indexer_handler_is_ready_when_edit_indexer_modal_is_some() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.is_loading = false;
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user