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, DOWNLOADS_BLOCKS};
|
||||
use crate::models::sonarr_models::DownloadRecord;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::downloads::DownloadsUi;
|
||||
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_downloads_ui_renders_loading_state() {
|
||||
fn test_downloads_ui_renders_loading() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Downloads.into());
|
||||
@@ -43,7 +42,6 @@ mod tests {
|
||||
fn test_downloads_ui_renders_empty_downloads() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Downloads.into());
|
||||
app.data.sonarr_data.downloads = StatefulTable::default();
|
||||
|
||||
let output = render_to_string_with_app(TerminalSize::Large, &mut app, |f, app| {
|
||||
DownloadsUi::draw(f, app, f.area());
|
||||
@@ -52,35 +50,23 @@ mod tests {
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_downloads_ui_renders_with_downloads() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Downloads.into());
|
||||
app.data.sonarr_data.downloads = StatefulTable::default();
|
||||
app.data.sonarr_data.downloads.set_items(vec![
|
||||
DownloadRecord {
|
||||
id: 1,
|
||||
title: "Test Series Download".to_owned(),
|
||||
status: Default::default(),
|
||||
size: 1024.0 * 1024.0 * 1024.0,
|
||||
sizeleft: 512.0 * 1024.0 * 1024.0,
|
||||
..DownloadRecord::default()
|
||||
},
|
||||
DownloadRecord {
|
||||
id: 2,
|
||||
title: "Another Series Download".to_owned(),
|
||||
status: Default::default(),
|
||||
size: 2048.0 * 1024.0 * 1024.0,
|
||||
sizeleft: 0.0,
|
||||
..DownloadRecord::default()
|
||||
},
|
||||
]);
|
||||
#[rstest]
|
||||
fn test_downloads_ui_renders(
|
||||
#[values(
|
||||
ActiveSonarrBlock::Downloads,
|
||||
ActiveSonarrBlock::DeleteDownloadPrompt,
|
||||
ActiveSonarrBlock::UpdateDownloadsPrompt
|
||||
)]
|
||||
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| {
|
||||
DownloadsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
insta::assert_snapshot!(format!("downloads_ui_{active_sonarr_block}"), output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/downloads/downloads_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Title Percent Complete Size Output Path Indexer Download Client
|
||||
=> Test Download Title 50% 3.30 GB /nfs/tv/Test show/season 1/ kickass torrents transmission
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭──────────────────── Cancel Download ────────────────────╮
|
||||
│ Do you really want to delete this download: │
|
||||
│ Test Download Title? │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│╭────────────────────────────╮╭───────────────────────────╮│
|
||||
││ Yes ││ No ││
|
||||
│╰────────────────────────────╯╰───────────────────────────╯│
|
||||
╰───────────────────────────────────────────────────────────╯
|
||||
+1
-2
@@ -4,5 +4,4 @@ expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Title Percent Complete Size Output Path Indexer Download Client
|
||||
=> Test Series Download 50% 1.00 GB
|
||||
Another Series Download 100% 2.00 GB
|
||||
=> Test Download Title 50% 3.30 GB /nfs/tv/Test show/season 1/ kickass torrents transmission
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/downloads/downloads_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Title Percent Complete Size Output Path Indexer Download Client
|
||||
=> Test Download Title 50% 3.30 GB /nfs/tv/Test show/season 1/ kickass torrents transmission
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────────── Update Downloads ────────────────────╮
|
||||
│ Do you want to update your downloads? │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│╭────────────────────────────╮╭───────────────────────────╮│
|
||||
││ Yes ││ No ││
|
||||
│╰────────────────────────────╯╰───────────────────────────╯│
|
||||
╰───────────────────────────────────────────────────────────╯
|
||||
Reference in New Issue
Block a user