Refactored the ErrorMessage widget into a generic Message widget for enhanced reuse. Added support for testing a single indexer at a time.

This commit is contained in:
2024-02-15 11:11:10 -07:00
parent b49bfaa9c1
commit a360c83431
23 changed files with 418 additions and 78 deletions
@@ -312,6 +312,19 @@ mod tests {
assert!(!app.data.radarr_data.prompt_confirm);
}
#[test]
fn test_test_indexer_esc() {
let mut app = App::default();
app.data.radarr_data.indexer_test_error = Some("test result".to_owned());
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
app.push_navigation_stack(ActiveRadarrBlock::TestIndexer.into());
IndexersHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::TestIndexer, &None).handle();
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
assert_eq!(app.data.radarr_data.indexer_test_error, None);
}
#[test]
fn test_default_esc() {
let mut app = App::default();
@@ -391,6 +404,24 @@ mod tests {
)
.handle();
assert_eq!(
app.get_current_route(),
&ActiveRadarrBlock::TestIndexer.into()
);
}
#[test]
fn test_test_all_key() {
let mut app = App::default();
IndexersHandler::with(
&DEFAULT_KEYBINDINGS.test_all.key,
&mut app,
&ActiveRadarrBlock::Indexers,
&None,
)
.handle();
assert_eq!(
app.get_current_route(),
&ActiveRadarrBlock::TestAllIndexers.into()
@@ -152,6 +152,10 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
self.app.pop_navigation_stack();
self.app.data.radarr_data.prompt_confirm = false;
}
ActiveRadarrBlock::TestIndexer => {
self.app.pop_navigation_stack();
self.app.data.radarr_data.indexer_test_error = None;
}
_ => handle_clear_errors(self.app),
}
}
@@ -169,6 +173,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
self.app.should_refresh = true;
}
_ if *key == DEFAULT_KEYBINDINGS.test.key => {
self
.app
.push_navigation_stack(ActiveRadarrBlock::TestIndexer.into());
}
_ if *key == DEFAULT_KEYBINDINGS.test_all.key => {
self
.app
.push_navigation_stack(ActiveRadarrBlock::TestAllIndexers.into());