fix(app/mod): use correct api for tab when starting on non default tab
Further testing of the servarr_name switch revealed an issue where selecting a server that didn't match the first tab caused the wrong api to be used. Now when a non-default tab is selected the correct api is used
This commit is contained in:
1 parent
5279d37ea2
commit
699e929ed2
2 files changed
+36
-8
No files matched your search
@@ -15,6 +15,7 @@ mod tests {
|
||||
use crate::models::{HorizontallyScrollableText, TabRoute};
|
||||
use crate::network::NetworkEvent;
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::network::sonarr_network::SonarrEvent;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
#[test]
|
||||
@@ -145,6 +146,36 @@ mod tests {
|
||||
assert!(app.is_routing);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_named_tab_uses_selected_servarr_route_and_network_events() {
|
||||
let (network_tx, mut network_rx) = mpsc::channel(500);
|
||||
let mut app = App::new(
|
||||
network_tx,
|
||||
AppConfig {
|
||||
radarr: Some(vec![ServarrConfig {
|
||||
name: Some("Movies".to_owned()),
|
||||
..ServarrConfig::default()
|
||||
}]),
|
||||
sonarr: Some(vec![ServarrConfig {
|
||||
name: Some("Shows".to_owned()),
|
||||
..ServarrConfig::default()
|
||||
}]),
|
||||
..AppConfig::default()
|
||||
},
|
||||
CancellationToken::new(),
|
||||
);
|
||||
|
||||
assert!(app.server_tabs.select_tab_by_title("Shows"));
|
||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into());
|
||||
|
||||
app.on_tick().await;
|
||||
|
||||
assert_eq!(
|
||||
network_rx.recv().await.unwrap(),
|
||||
SonarrEvent::GetQualityProfiles.into()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reset_cancellation_token() {
|
||||
let mut app = App {
|
||||
|
||||
+5
-8
@@ -240,14 +240,11 @@ impl App<'_> {
|
||||
}
|
||||
|
||||
pub fn get_current_route(&self) -> Route {
|
||||
*self.navigation_stack.last().unwrap_or(
|
||||
&self
|
||||
.server_tabs
|
||||
.tabs
|
||||
.first()
|
||||
.expect("At least one server tab must exist")
|
||||
.route,
|
||||
)
|
||||
self
|
||||
.navigation_stack
|
||||
.last()
|
||||
.copied()
|
||||
.unwrap_or_else(|| self.server_tabs.get_active_route())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user