Mostly completed tags implementation; still need to add the UI option for the Add Movie popup, and I still need to fix the REALLY FAST horizontal scrolling issue (I'm thinking just %2 everything to slow it down). Oh, and also need to convert the quality profile Hashmap into a BiMap
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::app::radarr::ActiveRadarrBlock;
|
||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
||||
use crate::models::{Scrollable, StatefulTable};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::{handle_text_box_keys, App, Key};
|
||||
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, App, Key};
|
||||
|
||||
pub(super) struct AddMovieHandler<'a> {
|
||||
key: &'a Key,
|
||||
@@ -119,6 +119,7 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
.radarr_data
|
||||
.movie_quality_profile_list
|
||||
.scroll_to_top(),
|
||||
ActiveRadarrBlock::AddMovieSearchInput => self.app.data.radarr_data.search.scroll_home(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -149,6 +150,7 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
.radarr_data
|
||||
.movie_quality_profile_list
|
||||
.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::AddMovieSearchInput => self.app.data.radarr_data.search.reset_offset(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -156,8 +158,12 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for AddMovieHandler<'a> {
|
||||
fn handle_delete(&mut self) {}
|
||||
|
||||
fn handle_left_right_action(&mut self) {
|
||||
if let ActiveRadarrBlock::AddMoviePrompt = self.active_radarr_block {
|
||||
handle_prompt_toggle(self.app, self.key)
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::AddMoviePrompt => handle_prompt_toggle(self.app, self.key),
|
||||
ActiveRadarrBlock::AddMovieSearchInput => {
|
||||
handle_text_box_left_right_keys!(self, self.key, self.app.data.radarr_data.search)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +304,7 @@ mod tests {
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
|
||||
test_enum_scroll!(
|
||||
@@ -349,10 +355,12 @@ mod tests {
|
||||
}
|
||||
|
||||
mod test_handle_home_end {
|
||||
use rstest::rstest;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::{
|
||||
extended_stateful_iterable_vec, test_enum_home_and_end, test_iterable_home_and_end,
|
||||
test_text_box_home_end_keys,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
@@ -365,7 +373,7 @@ mod tests {
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
|
||||
test_enum_home_and_end!(
|
||||
@@ -393,11 +401,22 @@ mod tests {
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
None
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_search_input_home_end_keys() {
|
||||
test_text_box_home_end_keys!(
|
||||
AddMovieHandler,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
search
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_left_right_action {
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::test_text_box_left_right_keys;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[rstest]
|
||||
@@ -412,6 +431,15 @@ mod tests {
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_movie_search_input_left_right_keys() {
|
||||
test_text_box_left_right_keys!(
|
||||
AddMovieHandler,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
search
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_submit {
|
||||
@@ -805,7 +833,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_add_movie_search_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.search = "Test".to_owned();
|
||||
app.data.radarr_data.search = "Test".to_owned().into();
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
@@ -815,7 +843,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.search, "Tes");
|
||||
assert_str_eq!(app.data.radarr_data.search.text, "Tes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -830,7 +858,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.search, "h");
|
||||
assert_str_eq!(app.data.radarr_data.search.text, "h");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ mod tests {
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ mod tests {
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||
use crate::app::radarr::ActiveRadarrBlock;
|
||||
use crate::app::App;
|
||||
use crate::event::Key;
|
||||
use crate::handle_text_box_keys;
|
||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
||||
use crate::models::Scrollable;
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::{handle_text_box_keys, handle_text_box_left_right_keys};
|
||||
|
||||
pub(super) struct EditMovieHandler<'a> {
|
||||
key: &'a Key,
|
||||
@@ -100,6 +100,8 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for EditMovieHandler<'a> {
|
||||
.radarr_data
|
||||
.movie_quality_profile_list
|
||||
.scroll_to_top(),
|
||||
ActiveRadarrBlock::EditMoviePathInput => self.app.data.radarr_data.edit_path.scroll_home(),
|
||||
ActiveRadarrBlock::EditMovieTagsInput => self.app.data.radarr_data.edit_tags.scroll_home(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -118,6 +120,8 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for EditMovieHandler<'a> {
|
||||
.radarr_data
|
||||
.movie_quality_profile_list
|
||||
.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::EditMoviePathInput => self.app.data.radarr_data.edit_path.reset_offset(),
|
||||
ActiveRadarrBlock::EditMovieTagsInput => self.app.data.radarr_data.edit_tags.reset_offset(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -125,8 +129,15 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for EditMovieHandler<'a> {
|
||||
fn handle_delete(&mut self) {}
|
||||
|
||||
fn handle_left_right_action(&mut self) {
|
||||
if let ActiveRadarrBlock::EditMoviePrompt = self.active_radarr_block {
|
||||
handle_prompt_toggle(self.app, self.key)
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::EditMoviePrompt => handle_prompt_toggle(self.app, self.key),
|
||||
ActiveRadarrBlock::EditMoviePathInput => {
|
||||
handle_text_box_left_right_keys!(self, self.key, self.app.data.radarr_data.edit_path)
|
||||
}
|
||||
ActiveRadarrBlock::EditMovieTagsInput => {
|
||||
handle_text_box_left_right_keys!(self, self.key, self.app.data.radarr_data.edit_tags)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +273,7 @@ mod tests {
|
||||
mod test_handle_home_end {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::{test_enum_home_and_end, test_iterable_home_and_end};
|
||||
use crate::{test_enum_home_and_end, test_iterable_home_and_end, test_text_box_home_end_keys};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -282,11 +293,31 @@ mod tests {
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
None
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn test_edit_movie_path_input_home_end_keys() {
|
||||
test_text_box_home_end_keys!(
|
||||
EditMovieHandler,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
edit_path
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_movie_tags_input_home_end_keys() {
|
||||
test_text_box_home_end_keys!(
|
||||
EditMovieHandler,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
edit_tags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_left_right_action {
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::{test_text_box_home_end_keys, test_text_box_left_right_keys};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[rstest]
|
||||
@@ -301,6 +332,24 @@ mod tests {
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_movie_path_input_left_right_keys() {
|
||||
test_text_box_left_right_keys!(
|
||||
EditMovieHandler,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
edit_path
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_movie_tags_input_left_right_keys() {
|
||||
test_text_box_left_right_keys!(
|
||||
EditMovieHandler,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
edit_tags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_submit {
|
||||
@@ -321,7 +370,7 @@ mod tests {
|
||||
fn test_edit_movie_path_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.should_ignore_quit_key = true;
|
||||
app.data.radarr_data.edit_path = "Test Path".to_owned();
|
||||
app.data.radarr_data.edit_path = "Test Path".to_owned().into();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePrompt.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePathInput.into());
|
||||
|
||||
@@ -334,7 +383,7 @@ mod tests {
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(!app.data.radarr_data.edit_path.is_empty());
|
||||
assert!(!app.data.radarr_data.edit_path.text.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
@@ -345,7 +394,7 @@ mod tests {
|
||||
fn test_edit_movie_tags_input_submit() {
|
||||
let mut app = App::default();
|
||||
app.should_ignore_quit_key = true;
|
||||
app.data.radarr_data.edit_tags = "Test Tags".to_owned();
|
||||
app.data.radarr_data.edit_tags = "Test Tags".to_owned().into();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePrompt.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePathInput.into());
|
||||
|
||||
@@ -358,7 +407,7 @@ mod tests {
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(!app.data.radarr_data.edit_tags.is_empty());
|
||||
assert!(!app.data.radarr_data.edit_tags.text.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
@@ -599,7 +648,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_edit_movie_path_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.edit_path = "Test".to_owned();
|
||||
app.data.radarr_data.edit_path = "Test".to_owned().into();
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
@@ -609,13 +658,13 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.edit_path, "Tes");
|
||||
assert_str_eq!(app.data.radarr_data.edit_path.text, "Tes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_movie_tags_input_backspace() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.edit_tags = "Test".to_owned();
|
||||
app.data.radarr_data.edit_tags = "Test".to_owned().into();
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
@@ -625,7 +674,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.edit_tags, "Tes");
|
||||
assert_str_eq!(app.data.radarr_data.edit_tags.text, "Tes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -640,7 +689,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.edit_path, "h");
|
||||
assert_str_eq!(app.data.radarr_data.edit_path.text, "h");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -655,7 +704,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.edit_tags, "h");
|
||||
assert_str_eq!(app.data.radarr_data.edit_tags.text, "h");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler
|
||||
use crate::models::Scrollable;
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::utils::strip_non_alphanumeric_characters;
|
||||
use crate::{handle_text_box_keys, App, Key};
|
||||
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, App, Key};
|
||||
|
||||
mod add_movie_handler;
|
||||
mod collection_details_handler;
|
||||
@@ -149,6 +149,12 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for RadarrHandler<'a> {
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::Downloads => self.app.data.radarr_data.downloads.scroll_to_top(),
|
||||
ActiveRadarrBlock::SearchMovie | ActiveRadarrBlock::SearchCollection => {
|
||||
self.app.data.radarr_data.search.scroll_home()
|
||||
}
|
||||
ActiveRadarrBlock::FilterMovies | ActiveRadarrBlock::FilterCollections => {
|
||||
self.app.data.radarr_data.filter.scroll_home()
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -182,6 +188,12 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for RadarrHandler<'a> {
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::Downloads => self.app.data.radarr_data.downloads.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::SearchMovie | ActiveRadarrBlock::SearchCollection => {
|
||||
self.app.data.radarr_data.search.reset_offset()
|
||||
}
|
||||
ActiveRadarrBlock::FilterMovies | ActiveRadarrBlock::FilterCollections => {
|
||||
self.app.data.radarr_data.filter.reset_offset()
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -222,6 +234,12 @@ impl<'a> KeyEventHandler<'a, ActiveRadarrBlock> for RadarrHandler<'a> {
|
||||
| ActiveRadarrBlock::RefreshAllMoviesPrompt
|
||||
| ActiveRadarrBlock::RefreshAllCollectionsPrompt
|
||||
| ActiveRadarrBlock::RefreshDownloadsPrompt => handle_prompt_toggle(self.app, self.key),
|
||||
ActiveRadarrBlock::SearchMovie | ActiveRadarrBlock::SearchCollection => {
|
||||
handle_text_box_left_right_keys!(self, self.key, self.app.data.radarr_data.search)
|
||||
}
|
||||
ActiveRadarrBlock::FilterMovies | ActiveRadarrBlock::FilterCollections => {
|
||||
handle_text_box_left_right_keys!(self, self.key, self.app.data.radarr_data.filter)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -476,14 +494,7 @@ impl RadarrHandler<'_> {
|
||||
where
|
||||
F: Fn(&T) -> &str,
|
||||
{
|
||||
let search_string = self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.search
|
||||
.drain(..)
|
||||
.collect::<String>()
|
||||
.to_lowercase();
|
||||
let search_string = self.app.data.radarr_data.search.drain().to_lowercase();
|
||||
let search_index = rows.iter().position(|item| {
|
||||
strip_non_alphanumeric_characters(field_selection_fn(item)).contains(&search_string)
|
||||
});
|
||||
@@ -503,15 +514,7 @@ impl RadarrHandler<'_> {
|
||||
F: Fn(&T) -> &str,
|
||||
T: Clone,
|
||||
{
|
||||
let filter = strip_non_alphanumeric_characters(
|
||||
&self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.filter
|
||||
.drain(..)
|
||||
.collect::<String>(),
|
||||
);
|
||||
let filter = strip_non_alphanumeric_characters(&self.app.data.radarr_data.filter.drain());
|
||||
let filter_matches: Vec<T> = rows
|
||||
.iter()
|
||||
.filter(|&item| strip_non_alphanumeric_characters(field_selection_fn(item)).contains(&filter))
|
||||
@@ -537,21 +540,23 @@ mod radarr_handler_test_utils {
|
||||
($handler:ident, $block:expr, $context:expr) => {
|
||||
let mut app = App::default();
|
||||
let mut radarr_data = RadarrData {
|
||||
edit_path: String::default(),
|
||||
edit_tags: String::default(),
|
||||
edit_path: HorizontallyScrollableText::default(),
|
||||
edit_tags: HorizontallyScrollableText::default(),
|
||||
edit_monitored: None,
|
||||
quality_profile_map: HashMap::from([
|
||||
(2222, "HD - 1080p".to_owned()),
|
||||
(1111, "Any".to_owned()),
|
||||
]),
|
||||
tags_map: BiMap::from_iter([(1, "test".to_owned())]),
|
||||
filtered_movies: StatefulTable::default(),
|
||||
..create_test_radarr_data()
|
||||
};
|
||||
radarr_data.movies.set_items(vec![Movie {
|
||||
path: "/nfs/movies/Test".to_owned(),
|
||||
path: "/nfs/movies/Test".to_owned().into(),
|
||||
monitored: true,
|
||||
quality_profile_id: Number::from(2222),
|
||||
minimum_availability: MinimumAvailability::Released,
|
||||
tags: vec![Number::from(1)],
|
||||
..Movie::default()
|
||||
}]);
|
||||
app.data.radarr_data = radarr_data;
|
||||
@@ -582,7 +587,7 @@ mod radarr_handler_test_utils {
|
||||
app.data.radarr_data.movie_quality_profile_list.items,
|
||||
vec!["Any".to_owned(), "HD - 1080p".to_owned()]
|
||||
);
|
||||
assert_eq!(
|
||||
assert_str_eq!(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
@@ -590,10 +595,8 @@ mod radarr_handler_test_utils {
|
||||
.current_selection(),
|
||||
"HD - 1080p"
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.edit_path,
|
||||
"/nfs/movies/Test".to_owned()
|
||||
);
|
||||
assert_str_eq!(app.data.radarr_data.edit_path.text, "/nfs/movies/Test");
|
||||
assert_str_eq!(app.data.radarr_data.edit_tags.text, "test");
|
||||
assert_eq!(app.data.radarr_data.edit_monitored, Some(true));
|
||||
};
|
||||
}
|
||||
@@ -673,8 +676,12 @@ mod tests {
|
||||
}
|
||||
|
||||
mod test_handle_home_end {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::models::radarr_models::DownloadRecord;
|
||||
use crate::{extended_stateful_iterable_vec, test_iterable_home_and_end};
|
||||
use crate::{
|
||||
extended_stateful_iterable_vec, test_iterable_home_and_end, test_text_box_home_end_keys,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -727,6 +734,22 @@ mod tests {
|
||||
None,
|
||||
title
|
||||
);
|
||||
|
||||
#[rstest]
|
||||
fn test_search_boxes_home_end_keys(
|
||||
#[values(ActiveRadarrBlock::SearchMovie, ActiveRadarrBlock::SearchCollection)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
test_text_box_home_end_keys!(RadarrHandler, active_radarr_block, search);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_filter_boxes_home_end_keys(
|
||||
#[values(ActiveRadarrBlock::FilterMovies, ActiveRadarrBlock::FilterCollections)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
test_text_box_home_end_keys!(RadarrHandler, active_radarr_block, filter);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_delete {
|
||||
@@ -765,6 +788,8 @@ mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::test_text_box_left_right_keys;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[rstest]
|
||||
@@ -843,6 +868,22 @@ mod tests {
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_search_boxes_left_right_keys(
|
||||
#[values(ActiveRadarrBlock::SearchMovie, ActiveRadarrBlock::SearchCollection)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
test_text_box_left_right_keys!(RadarrHandler, active_radarr_block, search);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_filter_boxes_left_right_keys(
|
||||
#[values(ActiveRadarrBlock::FilterMovies, ActiveRadarrBlock::FilterCollections)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
test_text_box_left_right_keys!(RadarrHandler, active_radarr_block, filter);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_handle_submit {
|
||||
@@ -877,7 +918,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.movies
|
||||
.set_items(extended_stateful_iterable_vec!(Movie));
|
||||
app.data.radarr_data.search = "Test 2".to_owned();
|
||||
app.data.radarr_data.search = "Test 2".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
@@ -901,7 +942,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.set_items(extended_stateful_iterable_vec!(Movie));
|
||||
app.data.radarr_data.search = "Test 2".to_owned();
|
||||
app.data.radarr_data.search = "Test 2".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
@@ -930,7 +971,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.collections
|
||||
.set_items(extended_stateful_iterable_vec!(Collection));
|
||||
app.data.radarr_data.search = "Test 2".to_owned();
|
||||
app.data.radarr_data.search = "Test 2".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
@@ -954,7 +995,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.set_items(extended_stateful_iterable_vec!(Collection));
|
||||
app.data.radarr_data.search = "Test 2".to_owned();
|
||||
app.data.radarr_data.search = "Test 2".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
@@ -983,7 +1024,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.movies
|
||||
.set_items(extended_stateful_iterable_vec!(Movie));
|
||||
app.data.radarr_data.filter = "Test".to_owned();
|
||||
app.data.radarr_data.filter = "Test".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
@@ -1013,7 +1054,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.collections
|
||||
.set_items(extended_stateful_iterable_vec!(Collection));
|
||||
app.data.radarr_data.filter = "Test".to_owned();
|
||||
app.data.radarr_data.filter = "Test".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
@@ -1210,7 +1251,8 @@ mod tests {
|
||||
mod test_handle_key_char {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
use bimap::BiMap;
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
use rstest::rstest;
|
||||
use serde_json::Number;
|
||||
use strum::IntoEnumIterator;
|
||||
@@ -1219,6 +1261,7 @@ mod tests {
|
||||
use crate::app::radarr::radarr_test_utils::create_test_radarr_data;
|
||||
use crate::app::radarr::RadarrData;
|
||||
use crate::models::radarr_models::MinimumAvailability;
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::models::StatefulTable;
|
||||
|
||||
use super::*;
|
||||
@@ -1328,7 +1371,7 @@ mod tests {
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.search = "Test".to_owned();
|
||||
app.data.radarr_data.search = "Test".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
@@ -1338,7 +1381,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.search, "Tes");
|
||||
assert_str_eq!(app.data.radarr_data.search.text, "Tes");
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -1347,7 +1390,7 @@ mod tests {
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.filter = "Test".to_owned();
|
||||
app.data.radarr_data.filter = "Test".to_owned().into();
|
||||
|
||||
RadarrHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
@@ -1357,7 +1400,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.filter, "Tes");
|
||||
assert_str_eq!(app.data.radarr_data.filter.text, "Tes");
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -1369,7 +1412,7 @@ mod tests {
|
||||
|
||||
RadarrHandler::with(&Key::Char('h'), &mut app, &active_radarr_block, &None).handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.search, "h");
|
||||
assert_str_eq!(app.data.radarr_data.search.text, "h");
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -1381,7 +1424,7 @@ mod tests {
|
||||
|
||||
RadarrHandler::with(&Key::Char('h'), &mut app, &active_radarr_block, &None).handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.filter, "h");
|
||||
assert_str_eq!(app.data.radarr_data.filter.text, "h");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,7 +1436,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.movies
|
||||
.set_items(extended_stateful_iterable_vec!(Movie));
|
||||
app.data.radarr_data.search = "Test 2".to_owned();
|
||||
app.data.radarr_data.search = "Test 2".to_owned().into();
|
||||
app.data.radarr_data.is_searching = true;
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SearchMovie.into());
|
||||
@@ -1412,7 +1455,7 @@ mod tests {
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert!(!app.data.radarr_data.is_searching);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.search.is_empty());
|
||||
assert!(app.data.radarr_data.search.text.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1423,7 +1466,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.movies
|
||||
.set_items(extended_stateful_iterable_vec!(Movie));
|
||||
app.data.radarr_data.search = "Test 5".to_owned();
|
||||
app.data.radarr_data.search = "Test 5".to_owned().into();
|
||||
app.data.radarr_data.is_searching = true;
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SearchMovie.into());
|
||||
@@ -1445,7 +1488,7 @@ mod tests {
|
||||
);
|
||||
assert!(!app.data.radarr_data.is_searching);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.search.is_empty());
|
||||
assert!(app.data.radarr_data.search.text.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1456,7 +1499,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.movies
|
||||
.set_items(extended_stateful_iterable_vec!(Movie));
|
||||
app.data.radarr_data.filter = "Test 2".to_owned();
|
||||
app.data.radarr_data.filter = "Test 2".to_owned().into();
|
||||
app.data.radarr_data.is_searching = true;
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::FilterMovies.into());
|
||||
@@ -1476,7 +1519,7 @@ mod tests {
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert!(!app.data.radarr_data.is_filtering);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.filter.is_empty());
|
||||
assert!(app.data.radarr_data.filter.text.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1487,7 +1530,7 @@ mod tests {
|
||||
.radarr_data
|
||||
.movies
|
||||
.set_items(extended_stateful_iterable_vec!(Movie));
|
||||
app.data.radarr_data.filter = "Test 5".to_owned();
|
||||
app.data.radarr_data.filter = "Test 5".to_owned().into();
|
||||
app.data.radarr_data.is_filtering = true;
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::FilterMovies.into());
|
||||
@@ -1509,7 +1552,7 @@ mod tests {
|
||||
);
|
||||
assert!(!app.data.radarr_data.is_searching);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.filter.is_empty());
|
||||
assert!(app.data.radarr_data.filter.text.is_empty());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
|
||||
@@ -271,12 +271,7 @@ fn sort_releases_by_selected_field(
|
||||
ReleaseField::Source => |release_a, release_b| release_a.protocol.cmp(&release_b.protocol),
|
||||
ReleaseField::Age => |release_a, release_b| release_a.age.as_u64().cmp(&release_b.age.as_u64()),
|
||||
ReleaseField::Rejected => |release_a, release_b| release_a.rejected.cmp(&release_b.rejected),
|
||||
ReleaseField::Title => |release_a, release_b| {
|
||||
release_a
|
||||
.title
|
||||
.stationary_style()
|
||||
.cmp(&release_b.title.stationary_style())
|
||||
},
|
||||
ReleaseField::Title => |release_a, release_b| release_a.title.text.cmp(&release_b.title.text),
|
||||
ReleaseField::Indexer => |release_a, release_b| release_a.indexer.cmp(&release_b.indexer),
|
||||
ReleaseField::Size => |release_a, release_b| {
|
||||
release_a
|
||||
@@ -394,7 +389,7 @@ mod tests {
|
||||
ActiveRadarrBlock::MovieHistory,
|
||||
None,
|
||||
source_title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
|
||||
test_iterable_scroll!(
|
||||
@@ -427,7 +422,7 @@ mod tests {
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
|
||||
test_enum_scroll!(
|
||||
@@ -484,7 +479,7 @@ mod tests {
|
||||
ActiveRadarrBlock::MovieHistory,
|
||||
None,
|
||||
source_title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
|
||||
test_iterable_home_and_end!(
|
||||
@@ -517,7 +512,7 @@ mod tests {
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
title,
|
||||
stationary_style
|
||||
to_string
|
||||
);
|
||||
|
||||
test_enum_home_and_end!(
|
||||
@@ -717,11 +712,13 @@ mod tests {
|
||||
}
|
||||
|
||||
mod test_handle_esc {
|
||||
use pretty_assertions::assert_eq;
|
||||
use bimap::BiMap;
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::app::radarr::radarr_test_utils::create_test_radarr_data;
|
||||
use crate::assert_movie_info_tabs_reset;
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -775,7 +772,8 @@ mod tests {
|
||||
mod test_handle_key_char {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
use bimap::BiMap;
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
use rstest::rstest;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
@@ -783,6 +781,7 @@ mod tests {
|
||||
use crate::app::radarr::RadarrData;
|
||||
use crate::handlers::radarr_handlers::RadarrHandler;
|
||||
use crate::models::radarr_models::{MinimumAvailability, Movie};
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::models::StatefulTable;
|
||||
use crate::test_edit_movie_key;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user