Refactored unnecessary data fields into Options to make the code cleaner, and to reduce the memory usage of the application
This commit is contained in:
@@ -234,7 +234,6 @@ mod tests {
|
||||
RadarrData, EDIT_COLLECTION_SELECTION_BLOCKS,
|
||||
};
|
||||
|
||||
use crate::models::StatefulTable;
|
||||
use crate::test_edit_collection_key;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -19,6 +19,7 @@ mod tests {
|
||||
mod test_handle_scroll_up_and_down {
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::models::StatefulTable;
|
||||
use crate::{simple_stateful_iterable_vec, test_iterable_scroll};
|
||||
|
||||
use super::*;
|
||||
@@ -34,21 +35,54 @@ mod tests {
|
||||
to_string
|
||||
);
|
||||
|
||||
test_iterable_scroll!(
|
||||
test_filtered_collections_scroll,
|
||||
CollectionsHandler,
|
||||
filtered_collections,
|
||||
simple_stateful_iterable_vec!(Collection, HorizontallyScrollableText),
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
title,
|
||||
to_string
|
||||
);
|
||||
#[rstest]
|
||||
fn test_filtered_collections_scroll(
|
||||
#[values(DEFAULT_KEYBINDINGS.up.key, DEFAULT_KEYBINDINGS.down.key)] key: Key,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
let mut filtered_collections = StatefulTable::default();
|
||||
filtered_collections.set_items(simple_stateful_iterable_vec!(
|
||||
Collection,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.filtered_collections = Some(filtered_collections);
|
||||
|
||||
CollectionsHandler::with(&key, &mut app, &ActiveRadarrBlock::Collections, &None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
CollectionsHandler::with(&key, &mut app, &ActiveRadarrBlock::Collections, &None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 1"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_home_end {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::models::StatefulTable;
|
||||
use crate::{extended_stateful_iterable_vec, test_iterable_home_and_end};
|
||||
|
||||
use super::*;
|
||||
@@ -64,16 +98,58 @@ mod tests {
|
||||
to_string
|
||||
);
|
||||
|
||||
test_iterable_home_and_end!(
|
||||
test_filtered_collections_home_end,
|
||||
CollectionsHandler,
|
||||
filtered_collections,
|
||||
extended_stateful_iterable_vec!(Collection, HorizontallyScrollableText),
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
title,
|
||||
to_string
|
||||
);
|
||||
#[test]
|
||||
fn test_filtered_collections_home_end() {
|
||||
let mut app = App::default();
|
||||
let mut filtered_collections = StatefulTable::default();
|
||||
filtered_collections.set_items(extended_stateful_iterable_vec!(
|
||||
Collection,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.filtered_collections = Some(filtered_collections);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 3"
|
||||
);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 1"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_collection_search_box_home_end_keys() {
|
||||
@@ -341,6 +417,7 @@ mod tests {
|
||||
}
|
||||
|
||||
mod test_handle_submit {
|
||||
use crate::models::StatefulTable;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
@@ -450,14 +527,12 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Collections.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SearchCollection.into());
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.set_items(extended_stateful_iterable_vec!(
|
||||
Collection,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
let mut filtered_collections = StatefulTable::default();
|
||||
filtered_collections.set_items(extended_stateful_iterable_vec!(
|
||||
Collection,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.filtered_collections = Some(filtered_collections);
|
||||
app.data.radarr_data.search = Some("Test 2".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
@@ -473,6 +548,8 @@ mod tests {
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.text,
|
||||
@@ -507,12 +584,25 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.filtered_collections.items.len(), 3);
|
||||
assert!(app.data.radarr_data.filtered_collections.is_some());
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.items
|
||||
.len(),
|
||||
3
|
||||
);
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.text,
|
||||
@@ -547,7 +637,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.filtered_collections.items.is_empty());
|
||||
assert!(app.data.radarr_data.filtered_collections.is_none());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterCollectionsError.into()
|
||||
@@ -715,7 +805,6 @@ mod tests {
|
||||
RadarrData, EDIT_COLLECTION_SELECTION_BLOCKS,
|
||||
};
|
||||
|
||||
use crate::models::StatefulTable;
|
||||
use crate::{assert_refresh_key, test_edit_collection_key};
|
||||
|
||||
use super::*;
|
||||
@@ -784,7 +873,7 @@ mod tests {
|
||||
assert!(app.data.radarr_data.is_filtering);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.filter.is_some());
|
||||
assert!(app.data.radarr_data.filtered_collections.items.is_empty());
|
||||
assert!(app.data.radarr_data.filtered_collections.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler
|
||||
use crate::models::servarr_data::radarr::radarr_data::{
|
||||
ActiveRadarrBlock, COLLECTIONS_BLOCKS, EDIT_COLLECTION_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::{BlockSelectionState, HorizontallyScrollableText, Scrollable};
|
||||
use crate::models::{BlockSelectionState, HorizontallyScrollableText, Scrollable, StatefulTable};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::utils::strip_non_search_characters;
|
||||
use crate::{filter_table, handle_text_box_keys, handle_text_box_left_right_keys, search_table};
|
||||
@@ -68,15 +68,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Collections {
|
||||
if !self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.items
|
||||
.is_empty()
|
||||
{
|
||||
self.app.data.radarr_data.filtered_collections.scroll_up();
|
||||
if let Some(filtered_collections) = self.app.data.radarr_data.filtered_collections.as_mut() {
|
||||
filtered_collections.scroll_up();
|
||||
} else {
|
||||
self.app.data.radarr_data.collections.scroll_up()
|
||||
}
|
||||
@@ -85,15 +78,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Collections {
|
||||
if !self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.items
|
||||
.is_empty()
|
||||
{
|
||||
self.app.data.radarr_data.filtered_collections.scroll_down();
|
||||
if let Some(filtered_collections) = self.app.data.radarr_data.filtered_collections.as_mut() {
|
||||
filtered_collections.scroll_down();
|
||||
} else {
|
||||
self.app.data.radarr_data.collections.scroll_down()
|
||||
}
|
||||
@@ -103,20 +89,9 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
fn handle_home(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Collections => {
|
||||
if !self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.items
|
||||
.is_empty()
|
||||
if let Some(filtered_collections) = self.app.data.radarr_data.filtered_collections.as_mut()
|
||||
{
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.scroll_to_top();
|
||||
filtered_collections.scroll_to_top();
|
||||
} else {
|
||||
self.app.data.radarr_data.collections.scroll_to_top()
|
||||
}
|
||||
@@ -144,20 +119,9 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
fn handle_end(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Collections => {
|
||||
if !self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.items
|
||||
.is_empty()
|
||||
if let Some(filtered_collections) = self.app.data.radarr_data.filtered_collections.as_mut()
|
||||
{
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.scroll_to_bottom();
|
||||
filtered_collections.scroll_to_bottom();
|
||||
} else {
|
||||
self.app.data.radarr_data.collections.scroll_to_bottom()
|
||||
}
|
||||
@@ -212,23 +176,17 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::CollectionDetails.into()),
|
||||
ActiveRadarrBlock::SearchCollection => {
|
||||
if self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.items
|
||||
.is_empty()
|
||||
{
|
||||
if self.app.data.radarr_data.filtered_collections.is_some() {
|
||||
search_table!(
|
||||
self.app,
|
||||
collections,
|
||||
ActiveRadarrBlock::SearchCollectionError
|
||||
filtered_collections,
|
||||
ActiveRadarrBlock::SearchCollectionError,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
search_table!(
|
||||
self.app,
|
||||
filtered_collections,
|
||||
collections,
|
||||
ActiveRadarrBlock::SearchCollectionError
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
||||
use crate::models::servarr_data::radarr::radarr_data::{
|
||||
ActiveRadarrBlock, ADD_MOVIE_BLOCKS, ADD_MOVIE_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::{BlockSelectionState, Scrollable, StatefulTable};
|
||||
use crate::models::{BlockSelectionState, Scrollable};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, App, Key};
|
||||
|
||||
@@ -43,9 +43,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::AddMovieSearchResults => {
|
||||
self.app.data.radarr_data.add_searched_movies.scroll_up()
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSearchResults => self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_up(),
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor => self
|
||||
.app
|
||||
.data
|
||||
@@ -89,9 +94,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::AddMovieSearchResults => {
|
||||
self.app.data.radarr_data.add_searched_movies.scroll_down()
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSearchResults => self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_down(),
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor => self
|
||||
.app
|
||||
.data
|
||||
@@ -140,6 +150,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_to_top(),
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor => self
|
||||
.app
|
||||
@@ -205,6 +217,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor => self
|
||||
.app
|
||||
@@ -312,19 +326,15 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
self.app.should_ignore_quit_key = false;
|
||||
}
|
||||
_ if *self.active_radarr_block == ActiveRadarrBlock::AddMovieSearchResults
|
||||
&& !self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.items
|
||||
.is_empty() =>
|
||||
&& self.app.data.radarr_data.add_searched_movies.is_some() =>
|
||||
{
|
||||
let tmdb_id = self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.tmdb_id
|
||||
.clone();
|
||||
@@ -403,7 +413,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSearchResults | ActiveRadarrBlock::AddMovieEmptySearchResults => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.radarr_data.add_searched_movies = StatefulTable::default();
|
||||
self.app.data.radarr_data.add_searched_movies = None;
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
ActiveRadarrBlock::AddMoviePrompt => {
|
||||
|
||||
@@ -21,21 +21,65 @@ mod tests {
|
||||
|
||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
||||
use crate::models::BlockSelectionState;
|
||||
use crate::{simple_stateful_iterable_vec, test_iterable_scroll};
|
||||
use crate::models::{BlockSelectionState, StatefulTable};
|
||||
use crate::simple_stateful_iterable_vec;
|
||||
|
||||
use super::*;
|
||||
|
||||
test_iterable_scroll!(
|
||||
test_add_movie_search_results_scroll,
|
||||
AddMovieHandler,
|
||||
add_searched_movies,
|
||||
simple_stateful_iterable_vec!(AddMovieSearchResult, HorizontallyScrollableText),
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
title,
|
||||
to_string
|
||||
);
|
||||
#[rstest]
|
||||
fn test_add_movie_search_results_scroll(
|
||||
#[values(DEFAULT_KEYBINDINGS.up.key, DEFAULT_KEYBINDINGS.down.key)] key: Key,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
let mut add_searched_movies = StatefulTable::default();
|
||||
add_searched_movies.set_items(simple_stateful_iterable_vec!(
|
||||
AddMovieSearchResult,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 1"
|
||||
);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_add_movie_select_monitor_scroll(
|
||||
@@ -302,21 +346,64 @@ mod tests {
|
||||
mod test_handle_home_end {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::extended_stateful_iterable_vec;
|
||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||
use crate::{extended_stateful_iterable_vec, test_iterable_home_and_end};
|
||||
use crate::models::StatefulTable;
|
||||
|
||||
use super::*;
|
||||
|
||||
test_iterable_home_and_end!(
|
||||
test_add_movie_search_results_home_end,
|
||||
AddMovieHandler,
|
||||
add_searched_movies,
|
||||
extended_stateful_iterable_vec!(AddMovieSearchResult, HorizontallyScrollableText),
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
title,
|
||||
to_string
|
||||
);
|
||||
#[test]
|
||||
fn test_add_movie_search_results_home_end() {
|
||||
let mut app = App::default();
|
||||
let mut add_searched_movies = StatefulTable::default();
|
||||
add_searched_movies.set_items(extended_stateful_iterable_vec!(
|
||||
AddMovieSearchResult,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 3"
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 1"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_select_monitor_home_end() {
|
||||
@@ -765,7 +852,7 @@ mod tests {
|
||||
use crate::models::radarr_models::Movie;
|
||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
||||
use crate::models::BlockSelectionState;
|
||||
use crate::models::{BlockSelectionState, StatefulTable};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
|
||||
use super::*;
|
||||
@@ -818,11 +905,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_add_movie_search_results_submit() {
|
||||
let mut app = App::default();
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.set_items(vec![AddMovieSearchResult::default()]);
|
||||
let mut add_searched_movies = StatefulTable::default();
|
||||
add_searched_movies.set_items(vec![AddMovieSearchResult::default()]);
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
app.data.radarr_data.quality_profile_map =
|
||||
BiMap::from_iter([(1, "B - Test 2".to_owned()), (0, "A - Test 1".to_owned())]);
|
||||
|
||||
@@ -904,11 +989,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_add_movie_search_results_submit_movie_already_in_library() {
|
||||
let mut app = App::default();
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.set_items(vec![AddMovieSearchResult::default()]);
|
||||
let mut add_searched_movies = StatefulTable::default();
|
||||
add_searched_movies.set_items(vec![AddMovieSearchResult::default()]);
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
@@ -1063,6 +1146,7 @@ mod tests {
|
||||
|
||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||
use crate::models::StatefulTable;
|
||||
use crate::{assert_search_reset, simple_stateful_iterable_vec};
|
||||
|
||||
use super::*;
|
||||
@@ -1123,14 +1207,12 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into());
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_searched_movies
|
||||
.set_items(simple_stateful_iterable_vec!(
|
||||
AddMovieSearchResult,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
let mut add_searched_movies = StatefulTable::default();
|
||||
add_searched_movies.set_items(simple_stateful_iterable_vec!(
|
||||
AddMovieSearchResult,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
|
||||
@@ -1138,7 +1220,7 @@ mod tests {
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.add_searched_movies.items.is_empty());
|
||||
assert!(app.data.radarr_data.add_searched_movies.is_none());
|
||||
assert!(app.should_ignore_quit_key);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ mod tests {
|
||||
use crate::test_handler_delegation;
|
||||
|
||||
mod test_handle_scroll_up_and_down {
|
||||
use crate::models::StatefulTable;
|
||||
use crate::{simple_stateful_iterable_vec, test_iterable_scroll};
|
||||
|
||||
use super::*;
|
||||
@@ -33,21 +34,54 @@ mod tests {
|
||||
to_string
|
||||
);
|
||||
|
||||
test_iterable_scroll!(
|
||||
test_filtered_movies_scroll,
|
||||
LibraryHandler,
|
||||
filtered_movies,
|
||||
simple_stateful_iterable_vec!(Movie, HorizontallyScrollableText),
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
title,
|
||||
to_string
|
||||
);
|
||||
#[rstest]
|
||||
fn test_filtered_movies_scroll(
|
||||
#[values(DEFAULT_KEYBINDINGS.up.key, DEFAULT_KEYBINDINGS.down.key)] key: Key,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
let mut filtered_movies = StatefulTable::default();
|
||||
filtered_movies.set_items(simple_stateful_iterable_vec!(
|
||||
Movie,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.filtered_movies = Some(filtered_movies);
|
||||
|
||||
LibraryHandler::with(&key, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
LibraryHandler::with(&key, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 1"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_home_end {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::models::StatefulTable;
|
||||
use crate::{extended_stateful_iterable_vec, test_iterable_home_and_end};
|
||||
|
||||
use super::*;
|
||||
@@ -63,16 +97,58 @@ mod tests {
|
||||
to_string
|
||||
);
|
||||
|
||||
test_iterable_home_and_end!(
|
||||
test_filtered_movies_home_end,
|
||||
LibraryHandler,
|
||||
filtered_movies,
|
||||
extended_stateful_iterable_vec!(Movie, HorizontallyScrollableText),
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
title,
|
||||
to_string
|
||||
);
|
||||
#[test]
|
||||
fn test_filtered_movies_home_end() {
|
||||
let mut app = App::default();
|
||||
let mut filtered_movies = StatefulTable::default();
|
||||
filtered_movies.set_items(extended_stateful_iterable_vec!(
|
||||
Movie,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.filtered_movies = Some(filtered_movies);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 3"
|
||||
);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
"Test 1"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_movie_search_box_home_end_keys() {
|
||||
@@ -367,6 +443,7 @@ mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::extended_stateful_iterable_vec;
|
||||
use crate::models::StatefulTable;
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
|
||||
use super::*;
|
||||
@@ -453,14 +530,12 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SearchMovie.into());
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.set_items(extended_stateful_iterable_vec!(
|
||||
Movie,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
let mut filtered_movies = StatefulTable::default();
|
||||
filtered_movies.set_items(extended_stateful_iterable_vec!(
|
||||
Movie,
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
app.data.radarr_data.filtered_movies = Some(filtered_movies);
|
||||
app.data.radarr_data.search = Some("Test 2".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
@@ -476,6 +551,8 @@ mod tests {
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.text,
|
||||
@@ -507,12 +584,25 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.filtered_movies.items.len(), 3);
|
||||
assert!(app.data.radarr_data.filtered_movies.is_some());
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.items
|
||||
.len(),
|
||||
3
|
||||
);
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.title
|
||||
.text,
|
||||
@@ -544,7 +634,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.filtered_movies.items.is_empty());
|
||||
assert!(app.data.radarr_data.filtered_movies.is_none());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterMoviesError.into()
|
||||
@@ -688,7 +778,6 @@ mod tests {
|
||||
RadarrData, EDIT_MOVIE_SELECTION_BLOCKS,
|
||||
};
|
||||
|
||||
use crate::models::StatefulTable;
|
||||
use crate::{assert_refresh_key, test_edit_movie_key};
|
||||
|
||||
use super::*;
|
||||
@@ -757,7 +846,7 @@ mod tests {
|
||||
assert!(app.data.radarr_data.is_filtering);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.filter.is_some());
|
||||
assert!(app.data.radarr_data.filtered_movies.items.is_empty());
|
||||
assert!(app.data.radarr_data.filtered_movies.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler
|
||||
use crate::models::servarr_data::radarr::radarr_data::{
|
||||
ActiveRadarrBlock, DELETE_MOVIE_SELECTION_BLOCKS, EDIT_MOVIE_SELECTION_BLOCKS, LIBRARY_BLOCKS,
|
||||
};
|
||||
use crate::models::{BlockSelectionState, HorizontallyScrollableText, Scrollable};
|
||||
use crate::models::{BlockSelectionState, HorizontallyScrollableText, Scrollable, StatefulTable};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::utils::strip_non_search_characters;
|
||||
use crate::{filter_table, handle_text_box_keys, handle_text_box_left_right_keys, search_table};
|
||||
@@ -81,8 +81,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Movies {
|
||||
if !self.app.data.radarr_data.filtered_movies.items.is_empty() {
|
||||
self.app.data.radarr_data.filtered_movies.scroll_up();
|
||||
if let Some(filtered_movies) = self.app.data.radarr_data.filtered_movies.as_mut() {
|
||||
filtered_movies.scroll_up();
|
||||
} else {
|
||||
self.app.data.radarr_data.movies.scroll_up()
|
||||
}
|
||||
@@ -91,8 +91,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Movies {
|
||||
if !self.app.data.radarr_data.filtered_movies.items.is_empty() {
|
||||
self.app.data.radarr_data.filtered_movies.scroll_down();
|
||||
if let Some(filtered_movies) = self.app.data.radarr_data.filtered_movies.as_mut() {
|
||||
filtered_movies.scroll_down();
|
||||
} else {
|
||||
self.app.data.radarr_data.movies.scroll_down()
|
||||
}
|
||||
@@ -102,8 +102,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
fn handle_home(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Movies => {
|
||||
if !self.app.data.radarr_data.filtered_movies.items.is_empty() {
|
||||
self.app.data.radarr_data.filtered_movies.scroll_to_top();
|
||||
if let Some(filtered_movies) = self.app.data.radarr_data.filtered_movies.as_mut() {
|
||||
filtered_movies.scroll_to_top();
|
||||
} else {
|
||||
self.app.data.radarr_data.movies.scroll_to_top()
|
||||
}
|
||||
@@ -135,8 +135,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
fn handle_end(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Movies => {
|
||||
if !self.app.data.radarr_data.filtered_movies.items.is_empty() {
|
||||
self.app.data.radarr_data.filtered_movies.scroll_to_bottom();
|
||||
if let Some(filtered_movies) = self.app.data.radarr_data.filtered_movies.as_mut() {
|
||||
filtered_movies.scroll_to_bottom();
|
||||
} else {
|
||||
self.app.data.radarr_data.movies.scroll_to_bottom()
|
||||
}
|
||||
@@ -199,14 +199,15 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::MovieDetails.into()),
|
||||
ActiveRadarrBlock::SearchMovie => {
|
||||
if self.app.data.radarr_data.filtered_movies.items.is_empty() {
|
||||
search_table!(self.app, movies, ActiveRadarrBlock::SearchMovieError);
|
||||
} else {
|
||||
if self.app.data.radarr_data.filtered_movies.is_some() {
|
||||
search_table!(
|
||||
self.app,
|
||||
filtered_movies,
|
||||
ActiveRadarrBlock::SearchMovieError
|
||||
ActiveRadarrBlock::SearchMovieError,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
search_table!(self.app, movies, ActiveRadarrBlock::SearchMovieError);
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::FilterMovies => {
|
||||
|
||||
@@ -477,7 +477,7 @@ fn sort_releases_by_selected_field(
|
||||
.cmp(release_b.size.as_u64().as_ref().unwrap())
|
||||
},
|
||||
ReleaseField::Peers => |release_a, release_b| {
|
||||
let default_number = Number::from(i64::max_value());
|
||||
let default_number = Number::from(i64::MAX);
|
||||
let seeder_a = release_a
|
||||
.seeders
|
||||
.as_ref()
|
||||
|
||||
@@ -914,7 +914,7 @@ mod tests {
|
||||
use crate::models::servarr_data::radarr::radarr_data::{
|
||||
RadarrData, EDIT_MOVIE_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::StatefulTable;
|
||||
|
||||
use crate::test_edit_movie_key;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -117,16 +117,8 @@ pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: &Key) {
|
||||
#[macro_export]
|
||||
macro_rules! search_table {
|
||||
($app:expr, $data_ref:ident, $error_block:expr) => {
|
||||
let search_index = if $app.data.radarr_data.search.is_some() {
|
||||
let search_string = $app
|
||||
.data
|
||||
.radarr_data
|
||||
.search
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.text
|
||||
.clone()
|
||||
.to_lowercase();
|
||||
let search_index = if let Some(search_str) = $app.data.radarr_data.search.as_ref() {
|
||||
let search_string = search_str.text.clone().to_lowercase();
|
||||
|
||||
$app.data.radarr_data.search = None;
|
||||
|
||||
@@ -151,44 +143,65 @@ macro_rules! search_table {
|
||||
$app.pop_and_push_navigation_stack($error_block.into());
|
||||
}
|
||||
};
|
||||
($app:expr, $data_ref:ident, $error_block:expr, $option:ident) => {
|
||||
let search_index = if let Some(search_str) = $app.data.radarr_data.search.as_ref() {
|
||||
let search_string = search_str.text.clone().to_lowercase();
|
||||
|
||||
$app.data.radarr_data.search = None;
|
||||
|
||||
$app
|
||||
.data
|
||||
.radarr_data
|
||||
.$data_ref
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.items
|
||||
.iter()
|
||||
.position(|item| strip_non_search_characters(&item.title.text).contains(&search_string))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
$app.data.radarr_data.is_searching = false;
|
||||
$app.should_ignore_quit_key = false;
|
||||
|
||||
if search_index.is_some() {
|
||||
$app.pop_navigation_stack();
|
||||
$app
|
||||
.data
|
||||
.radarr_data
|
||||
.$data_ref
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.select_index(search_index);
|
||||
} else {
|
||||
$app.pop_and_push_navigation_stack($error_block.into());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! filter_table {
|
||||
($app:expr, $source_table_ref:ident, $filter_table_ref:ident, $error_block:expr) => {
|
||||
let empty_filter = $app.data.radarr_data.filter.is_some()
|
||||
&& $app
|
||||
.data
|
||||
.radarr_data
|
||||
.filter
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.text
|
||||
.is_empty();
|
||||
let filter_matches = if $app.data.radarr_data.filter.is_some()
|
||||
&& !$app
|
||||
.data
|
||||
.radarr_data
|
||||
.filter
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.text
|
||||
.is_empty()
|
||||
{
|
||||
let filter =
|
||||
strip_non_search_characters(&$app.data.radarr_data.filter.as_ref().unwrap().text.clone());
|
||||
let empty_filter = match $app.data.radarr_data.filter.as_ref() {
|
||||
Some(filter) if filter.text.is_empty() => true,
|
||||
_ => false,
|
||||
};
|
||||
let filter_matches = match $app.data.radarr_data.filter.as_ref() {
|
||||
Some(filter) if !filter.text.is_empty() => {
|
||||
let scrubbed_filter = strip_non_search_characters(&filter.text.clone());
|
||||
|
||||
$app
|
||||
.data
|
||||
.radarr_data
|
||||
.$source_table_ref
|
||||
.items
|
||||
.iter()
|
||||
.filter(|item| strip_non_search_characters(&item.title.text).contains(&filter))
|
||||
.cloned()
|
||||
.collect()
|
||||
} else {
|
||||
Vec::new()
|
||||
$app
|
||||
.data
|
||||
.radarr_data
|
||||
.$source_table_ref
|
||||
.items
|
||||
.iter()
|
||||
.filter(|item| strip_non_search_characters(&item.title.text).contains(&scrubbed_filter))
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
_ => Vec::new(),
|
||||
};
|
||||
|
||||
$app.data.radarr_data.filter = None;
|
||||
@@ -201,11 +214,9 @@ macro_rules! filter_table {
|
||||
$app.pop_navigation_stack();
|
||||
} else {
|
||||
$app.pop_navigation_stack();
|
||||
$app
|
||||
.data
|
||||
.radarr_data
|
||||
.$filter_table_ref
|
||||
.set_items(filter_matches);
|
||||
let mut filter_table = StatefulTable::default();
|
||||
filter_table.set_items(filter_matches);
|
||||
$app.data.radarr_data.$filter_table_ref = Some(filter_table);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ mod utils {
|
||||
(1111, "Any".to_owned()),
|
||||
]),
|
||||
tags_map: BiMap::from_iter([(1, "test".to_owned())]),
|
||||
filtered_movies: StatefulTable::default(),
|
||||
filtered_movies: None,
|
||||
..create_test_radarr_data()
|
||||
};
|
||||
radarr_data.movies.set_items(vec![Movie {
|
||||
@@ -126,7 +126,7 @@ mod utils {
|
||||
(2222, "HD - 1080p".to_owned()),
|
||||
(1111, "Any".to_owned()),
|
||||
]),
|
||||
filtered_collections: StatefulTable::default(),
|
||||
filtered_collections: None,
|
||||
..create_test_radarr_data()
|
||||
};
|
||||
radarr_data.collections.set_items(vec![Collection {
|
||||
|
||||
@@ -10,7 +10,7 @@ mod tests {
|
||||
use crate::handlers::KeyEventHandler;
|
||||
use crate::models::radarr_models::Movie;
|
||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::models::{HorizontallyScrollableText, StatefulTable};
|
||||
use crate::utils::strip_non_search_characters;
|
||||
use crate::{
|
||||
extended_stateful_iterable_vec, filter_table, search_table, test_handler_delegation,
|
||||
@@ -130,9 +130,22 @@ mod tests {
|
||||
ActiveRadarrBlock::FilterMoviesError
|
||||
);
|
||||
|
||||
assert_eq!(app.data.radarr_data.filtered_movies.items.len(), 1);
|
||||
assert!(app.data.radarr_data.filtered_movies.is_some());
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.items
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.filtered_movies.items[0].title.text,
|
||||
app.data.radarr_data.filtered_movies.as_ref().unwrap().items[0]
|
||||
.title
|
||||
.text,
|
||||
"Test 2"
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
@@ -165,7 +178,7 @@ mod tests {
|
||||
ActiveRadarrBlock::FilterMoviesError
|
||||
);
|
||||
|
||||
assert!(app.data.radarr_data.filtered_movies.items.is_empty());
|
||||
assert!(app.data.radarr_data.filtered_movies.is_none());
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert!(!app.data.radarr_data.is_filtering);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
@@ -196,7 +209,7 @@ mod tests {
|
||||
ActiveRadarrBlock::FilterMoviesError
|
||||
);
|
||||
|
||||
assert!(app.data.radarr_data.filtered_movies.items.is_empty());
|
||||
assert!(app.data.radarr_data.filtered_movies.is_none());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterMoviesError.into()
|
||||
@@ -229,7 +242,7 @@ mod tests {
|
||||
ActiveRadarrBlock::FilterMoviesError
|
||||
);
|
||||
|
||||
assert!(app.data.radarr_data.filtered_movies.items.is_empty());
|
||||
assert!(app.data.radarr_data.filtered_movies.is_none());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterMoviesError.into()
|
||||
|
||||
Reference in New Issue
Block a user