test: assert delegated handlers pop exactly one navigation stack frame
test_handler_delegation! asserted only that the current route equalled the base block after Esc. When the delegated block was itself the base block the stack read [base, base], so that assertion held whether or not the sub-handler popped, and the case asserted nothing. Capture the navigation stack depth before delegating and assert it drops by exactly one, which also catches a handler that pops and then re-pushes. Depth is read through a test-only accessor on App; the navigation_stack field stays private. Main tab blocks clear errors on Esc rather than popping, by design, so they cannot be probed this way at all. Drop them from the delegation value lists; the remaining values in each list already exercise the same dispatch arm.
This commit is contained in:
6 files changed
+10
-29
No files matched your search
@@ -371,6 +371,10 @@ impl App<'_> {
|
||||
..App::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_navigation_stack_depth(&self) -> usize {
|
||||
self.navigation_stack.len()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -333,10 +333,16 @@ mod test_utils {
|
||||
let mut app = App::test_default_fully_populated();
|
||||
app.push_navigation_stack($base.into());
|
||||
app.push_navigation_stack($active_block.into());
|
||||
let navigation_stack_depth_before_delegation = app.get_navigation_stack_depth();
|
||||
|
||||
$handler::new(DEFAULT_KEYBINDINGS.esc.key, &mut app, $active_block, None).handle();
|
||||
|
||||
pretty_assertions::assert_eq!(app.get_current_route(), $base.into());
|
||||
pretty_assertions::assert_eq!(
|
||||
app.get_navigation_stack_depth(),
|
||||
navigation_stack_depth_before_delegation - 1,
|
||||
"Expected the delegated handler to pop exactly one route off the navigation stack"
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_library_blocks_to_library_handler(
|
||||
#[values(
|
||||
ActiveLidarrBlock::Artists,
|
||||
ActiveLidarrBlock::ArtistsSortPrompt,
|
||||
ActiveLidarrBlock::FilterArtists,
|
||||
ActiveLidarrBlock::FilterArtistsError,
|
||||
@@ -187,7 +186,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_downloads_blocks_to_downloads_handler(
|
||||
#[values(
|
||||
ActiveLidarrBlock::Downloads,
|
||||
ActiveLidarrBlock::DeleteDownloadPrompt,
|
||||
ActiveLidarrBlock::UpdateDownloadsPrompt
|
||||
)]
|
||||
@@ -203,7 +201,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_blocklist_blocks_to_blocklist_handler(
|
||||
#[values(
|
||||
ActiveLidarrBlock::Blocklist,
|
||||
ActiveLidarrBlock::BlocklistItemDetails,
|
||||
ActiveLidarrBlock::DeleteBlocklistItemPrompt,
|
||||
ActiveLidarrBlock::BlocklistClearAllItemsPrompt,
|
||||
@@ -221,7 +218,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_history_blocks_to_history_handler(
|
||||
#[values(
|
||||
ActiveLidarrBlock::History,
|
||||
ActiveLidarrBlock::HistoryItemDetails,
|
||||
ActiveLidarrBlock::HistorySortPrompt,
|
||||
ActiveLidarrBlock::FilterHistory,
|
||||
@@ -241,7 +237,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_root_folders_blocks_to_root_folders_handler(
|
||||
#[values(
|
||||
ActiveLidarrBlock::RootFolders,
|
||||
ActiveLidarrBlock::AddRootFolderPrompt,
|
||||
ActiveLidarrBlock::DeleteRootFolderPrompt
|
||||
)]
|
||||
@@ -258,7 +253,6 @@ mod tests {
|
||||
fn test_delegates_indexers_blocks_to_indexers_handler(
|
||||
#[values(
|
||||
ActiveLidarrBlock::DeleteIndexerPrompt,
|
||||
ActiveLidarrBlock::Indexers,
|
||||
ActiveLidarrBlock::AllIndexerSettingsPrompt,
|
||||
ActiveLidarrBlock::IndexerSettingsConfirmPrompt,
|
||||
ActiveLidarrBlock::IndexerSettingsMaximumSizeInput,
|
||||
@@ -278,7 +272,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_system_blocks_to_system_handler(
|
||||
#[values(
|
||||
ActiveLidarrBlock::System,
|
||||
ActiveLidarrBlock::SystemLogs,
|
||||
ActiveLidarrBlock::SystemQueuedEvents,
|
||||
ActiveLidarrBlock::SystemTasks,
|
||||
|
||||
@@ -123,7 +123,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_system_blocks_to_system_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::System,
|
||||
ActiveRadarrBlock::SystemLogs,
|
||||
ActiveRadarrBlock::SystemQueuedEvents,
|
||||
ActiveRadarrBlock::SystemTasks,
|
||||
@@ -142,7 +141,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_library_blocks_to_library_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::Movies,
|
||||
ActiveRadarrBlock::MoviesSortPrompt,
|
||||
ActiveRadarrBlock::SearchMovie,
|
||||
ActiveRadarrBlock::SearchMovieError,
|
||||
@@ -186,7 +184,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_collections_blocks_to_collections_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::Collections,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
ActiveRadarrBlock::SearchCollectionError,
|
||||
@@ -213,7 +210,6 @@ mod tests {
|
||||
fn test_delegates_indexers_blocks_to_indexers_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
ActiveRadarrBlock::IndexerSettingsAvailabilityDelayInput,
|
||||
ActiveRadarrBlock::IndexerSettingsConfirmPrompt,
|
||||
@@ -237,7 +233,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_downloads_blocks_to_downloads_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::Downloads,
|
||||
ActiveRadarrBlock::DeleteDownloadPrompt,
|
||||
ActiveRadarrBlock::UpdateDownloadsPrompt
|
||||
)]
|
||||
@@ -253,7 +248,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_root_folders_blocks_to_root_folders_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt
|
||||
)]
|
||||
@@ -269,7 +263,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_blocklist_blocks_to_blocklist_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
ActiveRadarrBlock::BlocklistItemDetails,
|
||||
ActiveRadarrBlock::DeleteBlocklistItemPrompt,
|
||||
ActiveRadarrBlock::BlocklistClearAllItemsPrompt,
|
||||
@@ -287,7 +280,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_history_blocks_to_history_handler(
|
||||
#[values(
|
||||
ActiveRadarrBlock::History,
|
||||
ActiveRadarrBlock::HistoryItemDetails,
|
||||
ActiveRadarrBlock::HistorySortPrompt,
|
||||
ActiveRadarrBlock::FilterHistory,
|
||||
|
||||
@@ -160,7 +160,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_library_blocks_to_library_handler(
|
||||
#[values(
|
||||
ActiveReadarrBlock::Authors,
|
||||
ActiveReadarrBlock::AuthorsSortPrompt,
|
||||
ActiveReadarrBlock::FilterAuthors,
|
||||
ActiveReadarrBlock::FilterAuthorsError,
|
||||
@@ -180,7 +179,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_blocklist_blocks_to_blocklist_handler(
|
||||
#[values(
|
||||
ActiveReadarrBlock::Blocklist,
|
||||
ActiveReadarrBlock::BlocklistItemDetails,
|
||||
ActiveReadarrBlock::DeleteBlocklistItemPrompt,
|
||||
ActiveReadarrBlock::BlocklistClearAllItemsPrompt,
|
||||
@@ -198,7 +196,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_downloads_blocks_to_downloads_handler(
|
||||
#[values(
|
||||
ActiveReadarrBlock::Downloads,
|
||||
ActiveReadarrBlock::DeleteDownloadPrompt,
|
||||
ActiveReadarrBlock::UpdateDownloadsPrompt
|
||||
)]
|
||||
@@ -214,7 +211,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_history_blocks_to_history_handler(
|
||||
#[values(
|
||||
ActiveReadarrBlock::History,
|
||||
ActiveReadarrBlock::HistoryItemDetails,
|
||||
ActiveReadarrBlock::HistorySortPrompt,
|
||||
ActiveReadarrBlock::SearchHistory,
|
||||
@@ -234,7 +230,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_root_folders_blocks_to_root_folders_handler(
|
||||
#[values(
|
||||
ActiveReadarrBlock::RootFolders,
|
||||
ActiveReadarrBlock::AddRootFolderPrompt,
|
||||
ActiveReadarrBlock::DeleteRootFolderPrompt
|
||||
)]
|
||||
@@ -250,7 +245,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_indexers_blocks_to_indexers_handler(
|
||||
#[values(
|
||||
ActiveReadarrBlock::Indexers,
|
||||
ActiveReadarrBlock::DeleteIndexerPrompt,
|
||||
ActiveReadarrBlock::TestIndexer,
|
||||
ActiveReadarrBlock::TestAllIndexers,
|
||||
@@ -274,7 +268,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_system_blocks_to_system_handler(
|
||||
#[values(
|
||||
ActiveReadarrBlock::System,
|
||||
ActiveReadarrBlock::SystemLogs,
|
||||
ActiveReadarrBlock::SystemQueuedEvents,
|
||||
ActiveReadarrBlock::SystemTasks,
|
||||
|
||||
@@ -165,7 +165,6 @@ mod tests {
|
||||
ActiveSonarrBlock::SearchSeriesHistory,
|
||||
ActiveSonarrBlock::SearchSeriesHistoryError,
|
||||
ActiveSonarrBlock::SeasonDetails,
|
||||
ActiveSonarrBlock::Series,
|
||||
ActiveSonarrBlock::SeriesDetails,
|
||||
ActiveSonarrBlock::SeriesHistory,
|
||||
ActiveSonarrBlock::SeriesHistorySortPrompt,
|
||||
@@ -186,7 +185,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_downloads_blocks_to_downloads_handler(
|
||||
#[values(
|
||||
ActiveSonarrBlock::Downloads,
|
||||
ActiveSonarrBlock::DeleteDownloadPrompt,
|
||||
ActiveSonarrBlock::UpdateDownloadsPrompt
|
||||
)]
|
||||
@@ -202,7 +200,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_blocklist_blocks_to_blocklist_handler(
|
||||
#[values(
|
||||
ActiveSonarrBlock::Blocklist,
|
||||
ActiveSonarrBlock::BlocklistItemDetails,
|
||||
ActiveSonarrBlock::DeleteBlocklistItemPrompt,
|
||||
ActiveSonarrBlock::BlocklistClearAllItemsPrompt,
|
||||
@@ -220,7 +217,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_history_blocks_to_history_handler(
|
||||
#[values(
|
||||
ActiveSonarrBlock::History,
|
||||
ActiveSonarrBlock::HistoryItemDetails,
|
||||
ActiveSonarrBlock::HistorySortPrompt,
|
||||
ActiveSonarrBlock::FilterHistory,
|
||||
@@ -240,7 +236,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_root_folders_blocks_to_root_folders_handler(
|
||||
#[values(
|
||||
ActiveSonarrBlock::RootFolders,
|
||||
ActiveSonarrBlock::AddRootFolderPrompt,
|
||||
ActiveSonarrBlock::DeleteRootFolderPrompt
|
||||
)]
|
||||
@@ -257,7 +252,6 @@ mod tests {
|
||||
fn test_delegates_indexers_blocks_to_indexers_handler(
|
||||
#[values(
|
||||
ActiveSonarrBlock::DeleteIndexerPrompt,
|
||||
ActiveSonarrBlock::Indexers,
|
||||
ActiveSonarrBlock::AllIndexerSettingsPrompt,
|
||||
ActiveSonarrBlock::IndexerSettingsConfirmPrompt,
|
||||
ActiveSonarrBlock::IndexerSettingsMaximumSizeInput,
|
||||
@@ -277,7 +271,6 @@ mod tests {
|
||||
#[rstest]
|
||||
fn test_delegates_system_blocks_to_system_handler(
|
||||
#[values(
|
||||
ActiveSonarrBlock::System,
|
||||
ActiveSonarrBlock::SystemLogs,
|
||||
ActiveSonarrBlock::SystemQueuedEvents,
|
||||
ActiveSonarrBlock::SystemTasks,
|
||||
|
||||
Reference in new issue
Block a user