test: Wrote snapshot tests for all Sonarr UI
This commit is contained in:
@@ -4,8 +4,6 @@ mod tests {
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, HISTORY_BLOCKS};
|
||||
use crate::models::sonarr_models::SonarrHistoryItem;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::history::HistoryUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
@@ -23,11 +21,12 @@ mod tests {
|
||||
|
||||
mod snapshot_tests {
|
||||
use crate::ui::ui_test_utils::test_utils::TerminalSize;
|
||||
use rstest::rstest;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_renders_loading_state() {
|
||||
fn test_history_ui_renders_loading() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
@@ -39,42 +38,42 @@ mod tests {
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_renders_empty_history() {
|
||||
#[rstest]
|
||||
fn test_history_ui_renders_empty(
|
||||
#[values(ActiveSonarrBlock::History, ActiveSonarrBlock::HistoryItemDetails)]
|
||||
active_sonarr_block: ActiveSonarrBlock,
|
||||
) {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
app.data.sonarr_data.history = StatefulTable::default();
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
|
||||
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
insta::assert_snapshot!(format!("loading_history_tab_{active_sonarr_block}"), output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_renders_with_history_items() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
app.data.sonarr_data.history = StatefulTable::default();
|
||||
app.data.sonarr_data.history.set_items(vec![
|
||||
SonarrHistoryItem {
|
||||
id: 1,
|
||||
source_title: "Test.Series.S01E01".to_owned().into(),
|
||||
..SonarrHistoryItem::default()
|
||||
},
|
||||
SonarrHistoryItem {
|
||||
id: 2,
|
||||
source_title: "Another.Series.S02E05".to_owned().into(),
|
||||
..SonarrHistoryItem::default()
|
||||
},
|
||||
]);
|
||||
#[rstest]
|
||||
fn test_history_ui_renders(
|
||||
#[values(
|
||||
ActiveSonarrBlock::History,
|
||||
ActiveSonarrBlock::HistoryItemDetails,
|
||||
ActiveSonarrBlock::HistorySortPrompt,
|
||||
ActiveSonarrBlock::FilterHistory,
|
||||
ActiveSonarrBlock::FilterHistoryError,
|
||||
ActiveSonarrBlock::SearchHistory,
|
||||
ActiveSonarrBlock::SearchHistoryError
|
||||
)]
|
||||
active_sonarr_block: ActiveSonarrBlock,
|
||||
) {
|
||||
let mut app = App::test_default_fully_populated();
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
|
||||
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
insta::assert_snapshot!(format!("history_tab_{active_sonarr_block}"), output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────────── Filter ──────────────────╮
|
||||
│test filter │
|
||||
╰─────────────────────────────────────────────╯
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────── Error ───────────────╮
|
||||
│The given filter produced empty results│
|
||||
│ │
|
||||
╰───────────────────────────────────────╯
|
||||
+2
-3
@@ -3,6 +3,5 @@ source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title Event Type Language Quality Date
|
||||
=> Test.Series.S01E01 unknown 1970-01-01 00:00:00 UTC
|
||||
Another.Series.S02E05 unknown 1970-01-01 00:00:00 UTC
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────────────────────────── Details ───────────────────────────────────╮
|
||||
│Source Title: Test source │
|
||||
│Indexer: │
|
||||
│Release Group: │
|
||||
│Series Match Type: │
|
||||
│NZB Info URL: │
|
||||
│Download Client Name: │
|
||||
│Age: 0 days │
|
||||
│Published Date: 1970-01-01 00:00:00 UTC │
|
||||
╰─────────────────────────────────────────────────────────────────────────────────╯
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title Event Type Language Quality Date
|
||||
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────────────────────────╮
|
||||
│Something │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰───────────────────────────────╯
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────────── Search ──────────────────╮
|
||||
│test search │
|
||||
╰─────────────────────────────────────────────╯
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Source Title ▼ Event Type Language Quality Date
|
||||
=> Test source grabbed English Bluray-1080p 2024-02-10 07:28:45 UTC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────── Error ───────────────╮
|
||||
│ No items found matching search │
|
||||
│ │
|
||||
╰───────────────────────────────────────╯
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────────────────────────── Details ───────────────────────────────────╮
|
||||
│Source Title: │
|
||||
│ │
|
||||
│No additional data available │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰─────────────────────────────────────────────────────────────────────────────────╯
|
||||
Reference in New Issue
Block a user