feat: Created a History tab in the Radarr UI and created a list history command and mark-history-item-as-failed command for Radarr
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, HISTORY_BLOCKS};
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::radarr_ui::history::HistoryUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if HISTORY_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(HistoryUi::accepts(active_radarr_block.into()));
|
||||
} else {
|
||||
assert!(!HistoryUi::accepts(active_radarr_block.into()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use crate::ui::ui_test_utils::test_utils::TerminalSize;
|
||||
use rstest::rstest;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_renders_loading() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveRadarrBlock::History.into());
|
||||
|
||||
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_history_ui_renders_empty(
|
||||
#[values(ActiveRadarrBlock::History, ActiveRadarrBlock::HistoryItemDetails)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(format!("loading_history_tab_{active_radarr_block}"), output);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_history_ui_renders(
|
||||
#[values(
|
||||
ActiveRadarrBlock::History,
|
||||
ActiveRadarrBlock::HistoryItemDetails,
|
||||
ActiveRadarrBlock::HistorySortPrompt,
|
||||
ActiveRadarrBlock::FilterHistory,
|
||||
ActiveRadarrBlock::FilterHistoryError,
|
||||
ActiveRadarrBlock::SearchHistory,
|
||||
ActiveRadarrBlock::SearchHistoryError
|
||||
)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
let mut app = App::test_default_fully_populated();
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(format!("history_tab_{active_radarr_block}"), output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
use crate::app::App;
|
||||
use crate::models::Route;
|
||||
use crate::models::radarr_models::RadarrHistoryItem;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, HISTORY_BLOCKS};
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::styles::{ManagarrStyle, secondary_style};
|
||||
use crate::ui::utils::{get_width_from_percentage, layout_block_top_border};
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::message::Message;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use ratatui::Frame;
|
||||
use ratatui::layout::{Alignment, Constraint, Rect};
|
||||
use ratatui::text::Text;
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
|
||||
use super::radarr_ui_utils::create_history_event_details;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "history_ui_tests.rs"]
|
||||
mod history_ui_tests;
|
||||
|
||||
pub(super) struct HistoryUi;
|
||||
|
||||
impl DrawUi for HistoryUi {
|
||||
fn accepts(route: Route) -> bool {
|
||||
if let Route::Radarr(active_radarr_block, _) = route {
|
||||
return HISTORY_BLOCKS.contains(&active_radarr_block);
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
draw_history_table(f, app, area);
|
||||
|
||||
if active_radarr_block == ActiveRadarrBlock::HistoryItemDetails {
|
||||
draw_history_item_details_popup(f, app);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let current_selection = if app.data.radarr_data.history.items.is_empty() {
|
||||
RadarrHistoryItem::default()
|
||||
} else {
|
||||
app.data.radarr_data.history.current_selection().clone()
|
||||
};
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
let history_row_mapping = |history_item: &RadarrHistoryItem| {
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
languages,
|
||||
quality,
|
||||
event_type,
|
||||
date,
|
||||
..
|
||||
} = history_item;
|
||||
|
||||
source_title.scroll_left_or_reset(
|
||||
get_width_from_percentage(area, 40),
|
||||
current_selection == *history_item,
|
||||
app.ui_scroll_tick_count == 0,
|
||||
);
|
||||
|
||||
Row::new(vec![
|
||||
Cell::from(source_title.to_string()),
|
||||
Cell::from(event_type.to_string()),
|
||||
Cell::from(
|
||||
languages
|
||||
.iter()
|
||||
.map(|language| language.name.to_owned())
|
||||
.collect::<Vec<String>>()
|
||||
.join(","),
|
||||
),
|
||||
Cell::from(quality.quality.name.to_owned()),
|
||||
Cell::from(date.to_string()),
|
||||
])
|
||||
.primary()
|
||||
};
|
||||
let history_table =
|
||||
ManagarrTable::new(Some(&mut app.data.radarr_data.history), history_row_mapping)
|
||||
.block(layout_block_top_border())
|
||||
.loading(app.is_loading)
|
||||
.sorting(active_radarr_block == ActiveRadarrBlock::HistorySortPrompt)
|
||||
.searching(active_radarr_block == ActiveRadarrBlock::SearchHistory)
|
||||
.search_produced_empty_results(active_radarr_block == ActiveRadarrBlock::SearchHistoryError)
|
||||
.filtering(active_radarr_block == ActiveRadarrBlock::FilterHistory)
|
||||
.filter_produced_empty_results(active_radarr_block == ActiveRadarrBlock::FilterHistoryError)
|
||||
.headers(["Source Title", "Event Type", "Language", "Quality", "Date"])
|
||||
.constraints([
|
||||
Constraint::Percentage(40),
|
||||
Constraint::Percentage(15),
|
||||
Constraint::Percentage(12),
|
||||
Constraint::Percentage(13),
|
||||
Constraint::Percentage(20),
|
||||
]);
|
||||
|
||||
if [
|
||||
ActiveRadarrBlock::SearchHistory,
|
||||
ActiveRadarrBlock::FilterHistory,
|
||||
]
|
||||
.contains(&active_radarr_block)
|
||||
{
|
||||
history_table.show_cursor(f, area);
|
||||
}
|
||||
|
||||
f.render_widget(history_table, area);
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_history_item_details_popup(f: &mut Frame<'_>, app: &mut App<'_>) {
|
||||
let current_selection = if app.data.radarr_data.history.items.is_empty() {
|
||||
RadarrHistoryItem::default()
|
||||
} else {
|
||||
app.data.radarr_data.history.current_selection().clone()
|
||||
};
|
||||
|
||||
let line_vec = create_history_event_details(current_selection);
|
||||
let text = Text::from(line_vec);
|
||||
|
||||
let message = Message::new(text)
|
||||
.title("Details")
|
||||
.style(secondary_style())
|
||||
.alignment(Alignment::Left);
|
||||
|
||||
f.render_widget(Popup::new(message).size(Size::NarrowLongMessage), f.area());
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────────── Filter ──────────────────╮
|
||||
│Something │
|
||||
╰─────────────────────────────────────────────╯
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────── Error ───────────────╮
|
||||
│The given filter produced empty results│
|
||||
│ │
|
||||
╰───────────────────────────────────────╯
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────────────────────────── Details ───────────────────────────────────╮
|
||||
│Source Title: Test │
|
||||
│Event Type: grabbed │
|
||||
│Indexer: DrunkenSlug (Prowlarr) │
|
||||
│Release Group: SPARKS │
|
||||
│NZB Info URL: │
|
||||
│Download Client: transmission │
|
||||
│Age: 0 days │
|
||||
│Published Date: 1970-01-01 00:00:00 UTC │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰─────────────────────────────────────────────────────────────────────────────────╯
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title Event Type Language Quality Date
|
||||
=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────────────────────────╮
|
||||
│Something │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰───────────────────────────────╯
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────────── Search ──────────────────╮
|
||||
│Something │
|
||||
╰─────────────────────────────────────────────╯
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────── Error ───────────────╮
|
||||
│ No items found matching search │
|
||||
│ │
|
||||
╰───────────────────────────────────────╯
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Loading ...
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────────────────────────── Details ───────────────────────────────────╮
|
||||
│Source Title: │
|
||||
│Event Type: unknown │
|
||||
│ │
|
||||
│No additional data available │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰─────────────────────────────────────────────────────────────────────────────────╯
|
||||
@@ -21,6 +21,7 @@ use crate::ui::draw_tabs;
|
||||
use crate::ui::radarr_ui::blocklist::BlocklistUi;
|
||||
use crate::ui::radarr_ui::collections::CollectionsUi;
|
||||
use crate::ui::radarr_ui::downloads::DownloadsUi;
|
||||
use crate::ui::radarr_ui::history::HistoryUi;
|
||||
use crate::ui::radarr_ui::indexers::IndexersUi;
|
||||
use crate::ui::radarr_ui::library::LibraryUi;
|
||||
use crate::ui::radarr_ui::root_folders::RootFoldersUi;
|
||||
@@ -35,10 +36,12 @@ use crate::utils::convert_to_gb;
|
||||
mod blocklist;
|
||||
mod collections;
|
||||
mod downloads;
|
||||
mod history;
|
||||
mod indexers;
|
||||
mod library;
|
||||
#[cfg(test)]
|
||||
mod radarr_ui_tests;
|
||||
mod radarr_ui_utils;
|
||||
mod root_folders;
|
||||
mod system;
|
||||
|
||||
@@ -61,6 +64,7 @@ impl DrawUi for RadarrUi {
|
||||
_ if RootFoldersUi::accepts(route) => RootFoldersUi::draw(f, app, content_area),
|
||||
_ if SystemUi::accepts(route) => SystemUi::draw(f, app, content_area),
|
||||
_ if BlocklistUi::accepts(route) => BlocklistUi::draw(f, app, content_area),
|
||||
_ if HistoryUi::accepts(route) => HistoryUi::draw(f, app, content_area),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,10 @@ mod tests {
|
||||
#[case(ActiveRadarrBlock::Collections, 1)]
|
||||
#[case(ActiveRadarrBlock::Downloads, 2)]
|
||||
#[case(ActiveRadarrBlock::Blocklist, 3)]
|
||||
#[case(ActiveRadarrBlock::RootFolders, 4)]
|
||||
#[case(ActiveRadarrBlock::Indexers, 5)]
|
||||
#[case(ActiveRadarrBlock::System, 6)]
|
||||
#[case(ActiveRadarrBlock::History, 4)]
|
||||
#[case(ActiveRadarrBlock::RootFolders, 5)]
|
||||
#[case(ActiveRadarrBlock::Indexers, 6)]
|
||||
#[case(ActiveRadarrBlock::System, 7)]
|
||||
fn test_radarr_ui_renders_radarr_tabs(
|
||||
#[case] active_radarr_block: ActiveRadarrBlock,
|
||||
#[case] index: usize,
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
use ratatui::text::Line;
|
||||
|
||||
use crate::models::radarr_models::{RadarrHistoryData, RadarrHistoryEventType, RadarrHistoryItem};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "radarr_ui_utils_tests.rs"]
|
||||
mod radarr_ui_utils_tests;
|
||||
|
||||
pub(super) fn create_history_event_details(history_item: RadarrHistoryItem) -> Vec<Line<'static>> {
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
event_type,
|
||||
data,
|
||||
..
|
||||
} = history_item;
|
||||
let RadarrHistoryData {
|
||||
indexer,
|
||||
release_group,
|
||||
nzb_info_url,
|
||||
download_client,
|
||||
download_client_name,
|
||||
age,
|
||||
published_date,
|
||||
dropped_path,
|
||||
imported_path,
|
||||
message,
|
||||
reason,
|
||||
source_path,
|
||||
path,
|
||||
..
|
||||
} = data;
|
||||
|
||||
let mut lines = vec![
|
||||
Line::from(format!("Source Title: {}", source_title.text.trim_start())),
|
||||
Line::from(format!("Event Type: {}", event_type)),
|
||||
];
|
||||
|
||||
match event_type {
|
||||
RadarrHistoryEventType::Grabbed => {
|
||||
lines.push(Line::from(format!(
|
||||
"Indexer: {}",
|
||||
indexer.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Release Group: {}",
|
||||
release_group.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"NZB Info URL: {}",
|
||||
nzb_info_url.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Download Client: {}",
|
||||
download_client
|
||||
.or(download_client_name)
|
||||
.unwrap_or_default()
|
||||
.trim_start()
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Age: {} days",
|
||||
age.unwrap_or("0".to_owned()).trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Published Date: {}",
|
||||
published_date.unwrap_or_default().to_string().trim_start(),
|
||||
)));
|
||||
}
|
||||
RadarrHistoryEventType::DownloadFolderImported => {
|
||||
lines.push(Line::from(format!(
|
||||
"Dropped Path: {}",
|
||||
dropped_path.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Imported Path: {}",
|
||||
imported_path.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Download Client: {}",
|
||||
download_client
|
||||
.or(download_client_name)
|
||||
.unwrap_or_default()
|
||||
.trim_start()
|
||||
)));
|
||||
}
|
||||
RadarrHistoryEventType::DownloadFailed => {
|
||||
lines.push(Line::from(format!(
|
||||
"Download Client: {}",
|
||||
download_client
|
||||
.or(download_client_name)
|
||||
.unwrap_or_default()
|
||||
.trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Message: {}",
|
||||
message.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
}
|
||||
RadarrHistoryEventType::MovieFileDeleted => {
|
||||
lines.push(Line::from(format!(
|
||||
"Reason: {}",
|
||||
reason.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
}
|
||||
RadarrHistoryEventType::MovieFileRenamed => {
|
||||
lines.push(Line::from(format!(
|
||||
"Source Path: {}",
|
||||
source_path.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
"Destination Path: {}",
|
||||
path.unwrap_or_default().trim_start(),
|
||||
)));
|
||||
}
|
||||
_ => {
|
||||
lines.push(Line::from(String::new()));
|
||||
lines.push(Line::from("No additional data available"));
|
||||
}
|
||||
}
|
||||
|
||||
lines
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use chrono::Utc;
|
||||
use ratatui::text::Line;
|
||||
|
||||
use crate::models::radarr_models::RadarrHistoryEventType;
|
||||
use crate::models::radarr_models::{RadarrHistoryData, RadarrHistoryItem};
|
||||
use crate::ui::radarr_ui::radarr_ui_utils::create_history_event_details;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_create_grabbed_history_event_details() {
|
||||
let history_item = radarr_history_item(RadarrHistoryEventType::Grabbed);
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
data,
|
||||
event_type,
|
||||
..
|
||||
} = history_item.clone();
|
||||
let RadarrHistoryData {
|
||||
indexer,
|
||||
release_group,
|
||||
nzb_info_url,
|
||||
download_client,
|
||||
download_client_name,
|
||||
age,
|
||||
published_date,
|
||||
..
|
||||
} = data;
|
||||
let expected_vec = vec![
|
||||
Line::from(format!("Source Title: {}", source_title.text.trim_start(),)),
|
||||
Line::from(format!("Event Type: {event_type}")),
|
||||
Line::from(format!(
|
||||
"Indexer: {}",
|
||||
indexer.unwrap_or_default().trim_start(),
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Release Group: {}",
|
||||
release_group.unwrap_or_default().trim_start()
|
||||
)),
|
||||
Line::from(format!(
|
||||
"NZB Info URL: {}",
|
||||
nzb_info_url.unwrap_or_default().trim_start()
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Download Client: {}",
|
||||
download_client
|
||||
.or(download_client_name)
|
||||
.unwrap_or_default()
|
||||
.trim_start()
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Age: {} days",
|
||||
age.unwrap_or("0".to_owned()).trim_start(),
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Published Date: {}",
|
||||
published_date.unwrap_or_default().to_string().trim_start()
|
||||
)),
|
||||
];
|
||||
|
||||
let history_details_vec = create_history_event_details(history_item);
|
||||
|
||||
assert_eq!(expected_vec, history_details_vec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_download_folder_imported_history_event_details() {
|
||||
let history_item = radarr_history_item(RadarrHistoryEventType::DownloadFolderImported);
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
data,
|
||||
event_type,
|
||||
..
|
||||
} = history_item.clone();
|
||||
let RadarrHistoryData {
|
||||
dropped_path,
|
||||
imported_path,
|
||||
download_client,
|
||||
..
|
||||
} = data;
|
||||
let expected_vec = vec![
|
||||
Line::from(format!("Source Title: {}", source_title.text.trim_start(),)),
|
||||
Line::from(format!("Event Type: {event_type}")),
|
||||
Line::from(format!(
|
||||
"Dropped Path: {}",
|
||||
dropped_path.unwrap_or_default().trim_start()
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Imported Path: {}",
|
||||
imported_path.unwrap_or_default().trim_start()
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Download Client: {}",
|
||||
download_client.unwrap_or_default().trim_start(),
|
||||
)),
|
||||
];
|
||||
|
||||
let history_details_vec = create_history_event_details(history_item);
|
||||
|
||||
assert_eq!(expected_vec, history_details_vec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_download_failed_history_event_details() {
|
||||
let history_item = radarr_history_item(RadarrHistoryEventType::DownloadFailed);
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
data,
|
||||
event_type,
|
||||
..
|
||||
} = history_item.clone();
|
||||
let RadarrHistoryData {
|
||||
message,
|
||||
download_client,
|
||||
..
|
||||
} = data;
|
||||
let expected_vec = vec![
|
||||
Line::from(format!("Source Title: {}", source_title.text.trim_start())),
|
||||
Line::from(format!("Event Type: {event_type}")),
|
||||
Line::from(format!(
|
||||
"Download Client: {}",
|
||||
download_client.unwrap_or_default().trim_start()
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Message: {}",
|
||||
message.unwrap_or_default().trim_start()
|
||||
)),
|
||||
];
|
||||
|
||||
let history_details_vec = create_history_event_details(history_item);
|
||||
|
||||
assert_eq!(expected_vec, history_details_vec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_movie_file_deleted_history_event_details() {
|
||||
let history_item = radarr_history_item(RadarrHistoryEventType::MovieFileDeleted);
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
data,
|
||||
event_type,
|
||||
..
|
||||
} = history_item.clone();
|
||||
let RadarrHistoryData { reason, .. } = data;
|
||||
let expected_vec = vec![
|
||||
Line::from(format!("Source Title: {}", source_title.text.trim_start(),)),
|
||||
Line::from(format!("Event Type: {event_type}")),
|
||||
Line::from(format!(
|
||||
"Reason: {}",
|
||||
reason.unwrap_or_default().trim_start(),
|
||||
)),
|
||||
];
|
||||
|
||||
let history_details_vec = create_history_event_details(history_item);
|
||||
|
||||
assert_eq!(expected_vec, history_details_vec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_movie_file_renamed_history_event_details() {
|
||||
let history_item = radarr_history_item(RadarrHistoryEventType::MovieFileRenamed);
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
data,
|
||||
event_type,
|
||||
..
|
||||
} = history_item.clone();
|
||||
let RadarrHistoryData {
|
||||
source_path, path, ..
|
||||
} = data;
|
||||
let expected_vec = vec![
|
||||
Line::from(format!("Source Title: {}", source_title.text.trim_start(),)),
|
||||
Line::from(format!("Event Type: {event_type}")),
|
||||
Line::from(format!(
|
||||
"Source Path: {}",
|
||||
source_path.unwrap_or_default().trim_start(),
|
||||
)),
|
||||
Line::from(format!(
|
||||
"Destination Path: {}",
|
||||
path.unwrap_or_default().trim_start(),
|
||||
)),
|
||||
];
|
||||
|
||||
let history_details_vec = create_history_event_details(history_item);
|
||||
|
||||
assert_eq!(expected_vec, history_details_vec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_no_data_history_event_details() {
|
||||
let history_item = radarr_history_item(RadarrHistoryEventType::Unknown);
|
||||
let RadarrHistoryItem {
|
||||
source_title,
|
||||
event_type,
|
||||
..
|
||||
} = history_item.clone();
|
||||
let expected_vec = vec![
|
||||
Line::from(format!("Source Title: {}", source_title.text.trim_start(),)),
|
||||
Line::from(format!("Event Type: {event_type}")),
|
||||
Line::from(String::new()),
|
||||
Line::from("No additional data available"),
|
||||
];
|
||||
|
||||
let history_details_vec = create_history_event_details(history_item);
|
||||
|
||||
assert_eq!(expected_vec, history_details_vec);
|
||||
}
|
||||
|
||||
fn radarr_history_item(event_type: RadarrHistoryEventType) -> RadarrHistoryItem {
|
||||
RadarrHistoryItem {
|
||||
source_title: "test.source.title".into(),
|
||||
event_type,
|
||||
data: radarr_history_data(),
|
||||
..RadarrHistoryItem::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn radarr_history_data() -> RadarrHistoryData {
|
||||
RadarrHistoryData {
|
||||
dropped_path: Some("/dropped/test".into()),
|
||||
imported_path: Some("/imported/test".into()),
|
||||
indexer: Some("Test Indexer".into()),
|
||||
release_group: Some("test release group".into()),
|
||||
nzb_info_url: Some("test url".into()),
|
||||
download_client: Some("test download client".into()),
|
||||
download_client_name: None,
|
||||
age: Some("1".into()),
|
||||
published_date: Some(Utc::now()),
|
||||
message: Some("test message".into()),
|
||||
reason: Some("test reason".into()),
|
||||
source_path: Some("/source/path".into()),
|
||||
path: Some("/path".into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@ source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Movie Title ▼ Source Title Languages Quality Formats Date │
|
||||
│=> Test z movie English HD - 1080p English 2024-02-10 07:28:45 UTC │
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Collection ▼ Number of Movies Root Folder Path Quality Profile Search on Add Monitored │
|
||||
│=> Test Collection 1 /nfs/movies HD - 1080p Yes 🏷 │
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Title Percent Complete Size Output Path Indexer Download Client │
|
||||
│=> Test Download Title 50% 3.30 GB /nfs/movies/Test kickass torrents transmission │
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
---
|
||||
source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source Title ▼ Event Type Language Quality Date │
|
||||
│=> Test grabbed English HD - 1080p 2022-12-30 07:37:56 UTC │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+1
-1
@@ -3,7 +3,7 @@ source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Indexer ▼ RSS Automatic Search Interactive Search Priority Tags │
|
||||
│=> Test Indexer Enabled Enabled Enabled 25 alex │
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Title ▼ Year Studio Runtime Rating Language Size Quality Profile Monitored Tags │
|
||||
│=> Test 2023 21st Century Alex 2h 0m R English 3.30 GB HD - 1080p 🏷 alex │
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Path Free Space Unmapped Folders │
|
||||
│=> /nfs 204800.00 GB 0 │
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ source: src/ui/radarr_ui/radarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│╭ Tasks ───────────────────────────────────────────────────────────────────────╮╭ Queued Events ──────────────────────────────────────────────────────────────╮│
|
||||
││Name Interval Last Execution Last Duration Next Execution ││Trigger Status Name Queued Started Duration ││
|
||||
││Backup 1 hour now 00:00:17 59 minutes ││manual completed Refresh Monitored 4 minutes ago 4 minutes a 00:03:03 ││
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ expression: output
|
||||
│ ││ ││ │
|
||||
╰───────────────────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────────────────╯╰──────────────────╯
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Title ▼ Year Studio Runtime Rating Language Size Quality Profile Monitored Tags │
|
||||
│=> Test 2023 21st Century Alex 2h 0m R English 3.30 GB HD - 1080p 🏷 alex │
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ expression: output
|
||||
│ ││ ││ │
|
||||
╰───────────────────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────────────────╯╰──────────────────╯
|
||||
╭ Movies ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ Root Folders │ Indexers │ System │
|
||||
│ Library │ Collections │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Title ▼ Year Studio Runtime Rating Language Size Quality Profile Monitored Tags │
|
||||
│=> Test 2023 21st Century Alex 2h 0m R English 3.30 GB HD - 1080p 🏷 alex │
|
||||
|
||||
Reference in New Issue
Block a user