test: Implemented UI snapshot tests
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, BLOCKLIST_BLOCKS};
|
||||
use crate::models::sonarr_models::BlocklistItem;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::blocklist::BlocklistUi;
|
||||
use strum::IntoEnumIterator;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_blocklist_ui_accepts() {
|
||||
@@ -15,4 +20,59 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_blocklist_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
BlocklistUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_blocklist_ui_renders_empty_blocklist() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
|
||||
app.data.sonarr_data.blocklist = StatefulTable::default();
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
BlocklistUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_blocklist_ui_renders_with_blocklist_items() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
|
||||
app.data.sonarr_data.blocklist = StatefulTable::default();
|
||||
app.data.sonarr_data.blocklist.set_items(vec![
|
||||
BlocklistItem {
|
||||
id: 1,
|
||||
source_title: "Test.Series.S01E01.1080p".to_owned(),
|
||||
..BlocklistItem::default()
|
||||
},
|
||||
BlocklistItem {
|
||||
id: 2,
|
||||
source_title: "Another.Series.S02E05.720p".to_owned(),
|
||||
..BlocklistItem::default()
|
||||
},
|
||||
]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
BlocklistUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Loading ...
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/blocklist/blocklist_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Series Title Source Title Language Quality Date
|
||||
=> Test.Series.S01E01.1080p 1970-01-01 00:00:0
|
||||
Another.Series.S02E05.720p 1970-01-01 00:00:0
|
||||
@@ -2,9 +2,13 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
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;
|
||||
|
||||
#[test]
|
||||
fn test_downloads_ui_accepts() {
|
||||
@@ -16,4 +20,65 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_downloads_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Downloads.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
DownloadsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
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(120, 30, &mut app, |f, app| {
|
||||
DownloadsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
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()
|
||||
},
|
||||
]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
DownloadsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/downloads/downloads_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/downloads/downloads_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Loading ...
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/downloads/downloads_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Title Percent Compl Size Output Path Indexer Download Client
|
||||
=> Test Series Download 50% 1.00 GB
|
||||
Another Series Download 100% 2.00 GB
|
||||
@@ -1,9 +1,14 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
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 strum::IntoEnumIterator;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_accepts() {
|
||||
@@ -15,4 +20,59 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_history_ui_renders_empty_history() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
app.data.sonarr_data.history = StatefulTable::default();
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(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()
|
||||
},
|
||||
]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
HistoryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/history/history_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Loading ...
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
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
|
||||
@@ -1,9 +1,19 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EDIT_INDEXER_BLOCKS};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::BlockSelectionState;
|
||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, EDIT_INDEXER_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::servarr_models::{Indexer, IndexerField};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::indexers::edit_indexer_ui::EditIndexerUi;
|
||||
use strum::IntoEnumIterator;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn test_edit_indexer_ui_accepts() {
|
||||
@@ -15,4 +25,45 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_edit_indexer_ui_renders_edit_indexer_modal() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::EditIndexerNameInput.into());
|
||||
app.data.sonarr_data.indexers = StatefulTable::default();
|
||||
app.data.sonarr_data.indexers.set_items(vec![Indexer {
|
||||
id: 1,
|
||||
name: Some("Test Indexer".to_owned()),
|
||||
enable_rss: true,
|
||||
priority: 25,
|
||||
fields: Some(vec![
|
||||
IndexerField {
|
||||
name: Some("baseUrl".to_owned()),
|
||||
value: Some(json!("https://test.indexer.com")),
|
||||
},
|
||||
IndexerField {
|
||||
name: Some("apiKey".to_owned()),
|
||||
value: Some(json!("test-api-key")),
|
||||
},
|
||||
IndexerField {
|
||||
name: Some("seedCriteria.seedRatio".to_owned()),
|
||||
value: Some(json!(1.0)),
|
||||
},
|
||||
]),
|
||||
..Indexer::default()
|
||||
}]);
|
||||
app.data.sonarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal::from(&app.data.sonarr_data));
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
EditIndexerUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::BlockSelectionState;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, INDEXER_SETTINGS_BLOCKS,
|
||||
ActiveSonarrBlock, INDEXER_SETTINGS_BLOCKS, INDEXER_SETTINGS_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::IndexerSettings;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::indexers::indexer_settings_ui::IndexerSettingsUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_indexer_settings_ui_accepts() {
|
||||
@@ -18,4 +22,23 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_indexer_settings_ui_renders_indexer_settings() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::IndexerSettingsMinimumAgeInput.into());
|
||||
app.data.sonarr_data.selected_block =
|
||||
BlockSelectionState::new(INDEXER_SETTINGS_SELECTION_BLOCKS);
|
||||
app.data.sonarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
IndexerSettingsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, EDIT_INDEXER_BLOCKS, INDEXER_SETTINGS_BLOCKS, INDEXERS_BLOCKS,
|
||||
};
|
||||
use crate::models::servarr_models::Indexer;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::indexers::IndexersUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_indexers_ui_accepts() {
|
||||
@@ -24,4 +28,64 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_indexers_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
IndexersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_indexers_ui_renders_empty_indexers() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
|
||||
app.data.sonarr_data.indexers = StatefulTable::default();
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
IndexersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_indexers_ui_renders_with_indexers() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
|
||||
app.data.sonarr_data.indexers = StatefulTable::default();
|
||||
app.data.sonarr_data.indexers.set_items(vec![
|
||||
Indexer {
|
||||
id: 1,
|
||||
name: Some("Test Indexer 1".to_owned()),
|
||||
enable_rss: true,
|
||||
enable_automatic_search: true,
|
||||
enable_interactive_search: true,
|
||||
priority: 25,
|
||||
..Indexer::default()
|
||||
},
|
||||
Indexer {
|
||||
id: 2,
|
||||
name: Some("Test Indexer 2".to_owned()),
|
||||
enable_rss: false,
|
||||
..Indexer::default()
|
||||
},
|
||||
]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
IndexersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/indexers/edit_indexer_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────────────────────────── Edit Indexer ─────────────────────────────────╮
|
||||
│ │
|
||||
│ ╭─────────────────╮ ╭─────────────────╮ │
|
||||
│ Name: ╰─────────────────╯ URL: ╰─────────────────╯ │
|
||||
│ ╭───╮ ╭─────────────────╮ │
|
||||
│ ╭───╮ API Key: ╰─────────────────╯ │
|
||||
│ Enable Automatic Se╰───╯ ╭─────────────────╮ │
|
||||
│ ╭───╮ Tags: ╰─────────────────╯ │
|
||||
│ ╭─────────────────╮ │
|
||||
│ Indexer Priority ▴▾╰─────────────────╯ │
|
||||
│ │
|
||||
│ ╭──────────────────╮╭───────────────────╮ │
|
||||
│ │ Save ││ Cancel │ │
|
||||
│ ╰──────────────────╯╰───────────────────╯ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────╯
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/indexers/indexer_settings_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────── Configure All Indexer Settings ─────────╮
|
||||
│ ╭───────────────────────╮ │
|
||||
│Minimum Age (minutes) ▴▾:│0 │ │
|
||||
│ ╰───────────────────────╯ │
|
||||
│ ╭───────────────────────╮ │
|
||||
│ Retention (days) ▴▾: │0 │ │
|
||||
│ ╰───────────────────────╯ │
|
||||
│ ╭───────────────────────╮ │
|
||||
│ Maximum Size (MB) ▴▾: │0 │ │
|
||||
│ ╰───────────────────────╯ │
|
||||
│ ╭───────────────────────╮ │
|
||||
│RSS Sync Interval (minute│0 │ │
|
||||
│ ╰───────────────────────╯ │
|
||||
╰────────────────────────────────────────────────────╯
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Loading ...
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/indexers/indexers_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Indexer RSS Automatic Search Interactive Sea Priority Tags
|
||||
=> Test Indexer 1 Enabled Enabled Enabled 25
|
||||
Test Indexer 2 Disabled Disabled Disabled 0
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/indexers/test_all_indexers_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭ Test All Indexers ───────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ Loading ... │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
@@ -2,9 +2,11 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::indexers::test_all_indexers_ui::TestAllIndexersUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_test_all_indexers_ui_accepts() {
|
||||
@@ -16,4 +18,21 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_test_all_indexers_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::TestAllIndexers.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
TestAllIndexersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ADD_SERIES_BLOCKS, ActiveSonarrBlock};
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::library::add_series_ui::AddSeriesUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_add_series_ui_accepts() {
|
||||
@@ -16,4 +19,35 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_add_series_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into());
|
||||
app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
AddSeriesUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_series_ui_renders_search_input() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into());
|
||||
app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
AddSeriesUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,16 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, DELETE_SERIES_BLOCKS};
|
||||
use crate::app::App;
|
||||
use crate::models::BlockSelectionState;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, DELETE_SERIES_BLOCKS, DELETE_SERIES_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::Series;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::library::delete_series_ui::DeleteSeriesUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_delete_series_ui_accepts() {
|
||||
@@ -16,4 +23,28 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_delete_series_ui_renders_delete_series_toggle() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::DeleteSeriesPrompt.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
id: 1,
|
||||
title: "Test Series".into(),
|
||||
..Series::default()
|
||||
}]);
|
||||
app.data.sonarr_data.selected_block =
|
||||
BlockSelectionState::new(DELETE_SERIES_SELECTION_BLOCKS);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
DeleteSeriesUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bimap::BiMap;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EDIT_SERIES_BLOCKS};
|
||||
use crate::app::App;
|
||||
use crate::models::BlockSelectionState;
|
||||
use crate::models::servarr_data::sonarr::modals::EditSeriesModal;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, EDIT_SERIES_BLOCKS, EDIT_SERIES_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::Series;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::library::edit_series_ui::EditSeriesUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_edit_series_ui_accepts() {
|
||||
@@ -16,4 +25,34 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_edit_series_ui_renders_edit_series_modal() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::EditSeriesPathInput.into());
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter(vec![(1, "HD-1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter(vec![(1, "English".to_owned())]);
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
id: 1,
|
||||
title: "Test Series".into(),
|
||||
path: "/tv/test".to_owned(),
|
||||
quality_profile_id: 1,
|
||||
language_profile_id: 1,
|
||||
..Series::default()
|
||||
}]);
|
||||
app.data.sonarr_data.selected_block = BlockSelectionState::new(EDIT_SERIES_SELECTION_BLOCKS);
|
||||
app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal::from(&app.data.sonarr_data));
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
EditSeriesUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::modals::{EpisodeDetailsModal, SeasonDetailsModal};
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::{Episode, Season, Series};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::library::episode_details_ui::EpisodeDetailsUi;
|
||||
use strum::IntoEnumIterator;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_episode_details_ui_accepts() {
|
||||
@@ -17,4 +23,111 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_episode_details_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::EpisodeDetails.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season {
|
||||
season_number: 1,
|
||||
..Season::default()
|
||||
}]),
|
||||
..Series::default()
|
||||
}]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
EpisodeDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_episode_details_ui_renders_episode_details_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::EpisodeDetails.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season {
|
||||
season_number: 1,
|
||||
..Season::default()
|
||||
}]),
|
||||
..Series::default()
|
||||
}]);
|
||||
let mut season_details_modal = SeasonDetailsModal::default();
|
||||
season_details_modal
|
||||
.episodes
|
||||
.set_items(vec![Episode::default()]);
|
||||
season_details_modal.episode_details_modal = Some(EpisodeDetailsModal::default());
|
||||
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
EpisodeDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_episode_details_ui_renders_episode_history_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::EpisodeDetails.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season {
|
||||
season_number: 1,
|
||||
..Season::default()
|
||||
}]),
|
||||
..Series::default()
|
||||
}]);
|
||||
let mut season_details_modal = SeasonDetailsModal::default();
|
||||
season_details_modal
|
||||
.episodes
|
||||
.set_items(vec![Episode::default()]);
|
||||
let mut episode_details_modal = EpisodeDetailsModal::default();
|
||||
episode_details_modal.episode_details_tabs.set_index(1);
|
||||
season_details_modal.episode_details_modal = Some(episode_details_modal);
|
||||
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
EpisodeDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_episode_details_ui_renders_manual_search_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::EpisodeDetails.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season {
|
||||
season_number: 1,
|
||||
..Season::default()
|
||||
}]),
|
||||
..Series::default()
|
||||
}]);
|
||||
let mut season_details_modal = SeasonDetailsModal::default();
|
||||
season_details_modal
|
||||
.episodes
|
||||
.set_items(vec![Episode::default()]);
|
||||
let mut episode_details_modal = EpisodeDetailsModal::default();
|
||||
episode_details_modal.episode_details_tabs.set_index(3);
|
||||
season_details_modal.episode_details_modal = Some(episode_details_modal);
|
||||
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
EpisodeDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,4 +245,41 @@ mod tests {
|
||||
|
||||
assert_eq!(style, row.indeterminate());
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::library::LibraryUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_library_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
LibraryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_library_ui_renders_empty_series() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
LibraryUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bimap::BiMap;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::modals::SeasonDetailsModal;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS, SEASON_DETAILS_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::{Season, Series};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::library::season_details_ui::SeasonDetailsUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_season_details_ui_accepts() {
|
||||
@@ -21,4 +27,121 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_season_details_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonDetails.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season::default()]),
|
||||
..Series::default()
|
||||
}]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SeasonDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_season_details_ui_renders_episodes_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonDetails.into());
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season::default()]),
|
||||
..Series::default()
|
||||
}]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SeasonDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_season_details_ui_renders_manual_search_tab() {
|
||||
use crate::models::sonarr_models::{Episode, EpisodeFile, SonarrRelease};
|
||||
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonDetails.into());
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter(vec![(0, "Any".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter(vec![(0, "English".to_owned())]);
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season::default()]),
|
||||
..Series::default()
|
||||
}]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.seasons
|
||||
.set_items(vec![Season::default()]);
|
||||
let mut season_details_modal = SeasonDetailsModal::default();
|
||||
season_details_modal.season_details_tabs.set_index(2);
|
||||
season_details_modal
|
||||
.episodes
|
||||
.set_items(vec![Episode::default()]);
|
||||
season_details_modal
|
||||
.episode_files
|
||||
.set_items(vec![EpisodeFile::default()]);
|
||||
season_details_modal
|
||||
.season_releases
|
||||
.set_items(vec![SonarrRelease::default()]);
|
||||
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SeasonDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_season_details_ui_renders_season_history_tab() {
|
||||
use crate::models::sonarr_models::{Episode, EpisodeFile, SonarrHistoryItem};
|
||||
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeasonDetails.into());
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter(vec![(0, "Any".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter(vec![(0, "English".to_owned())]);
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
seasons: Some(vec![Season::default()]),
|
||||
..Series::default()
|
||||
}]);
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.seasons
|
||||
.set_items(vec![Season::default()]);
|
||||
let mut season_details_modal = SeasonDetailsModal::default();
|
||||
season_details_modal.season_details_tabs.set_index(1);
|
||||
season_details_modal
|
||||
.episodes
|
||||
.set_items(vec![Episode::default()]);
|
||||
season_details_modal
|
||||
.episode_files
|
||||
.set_items(vec![EpisodeFile::default()]);
|
||||
season_details_modal
|
||||
.season_history
|
||||
.set_items(vec![SonarrHistoryItem::default()]);
|
||||
app.data.sonarr_data.season_details_modal = Some(season_details_modal);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SeasonDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bimap::BiMap;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS, SEASON_DETAILS_BLOCKS, SERIES_DETAILS_BLOCKS,
|
||||
};
|
||||
use crate::models::sonarr_models::{Season, Series};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::library::series_details_ui::SeriesDetailsUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_series_details_ui_accepts() {
|
||||
@@ -22,4 +27,33 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_series_details_ui_renders_series_details() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into());
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter(vec![(1, "HD-1080p".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter(vec![(1, "English".to_owned())]);
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
id: 1,
|
||||
title: "Test Series".into(),
|
||||
seasons: Some(vec![Season::default()]),
|
||||
quality_profile_id: 1,
|
||||
language_profile_id: 1,
|
||||
..Series::default()
|
||||
}]);
|
||||
app.data.sonarr_data.series_history = Some(StatefulTable::default());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SeriesDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/add_series_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭──────────────────────────────────── Add Series ────────────────────────────────────╮
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
||||
╭──────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/add_series_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭──────────────────────────────────── Add Series ────────────────────────────────────╮
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
||||
╭──────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/delete_series_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭───────────── Delete Series ─────────────╮
|
||||
│ Do you really want to delete the series: │
|
||||
│ Test Series? │
|
||||
│ │
|
||||
│ ╭───╮ │
|
||||
│ Delete Series File: │ │ │
|
||||
│ ╰───╯ │
|
||||
│ ╭───╮ │
|
||||
│ Add List Exclusion: │ │ │
|
||||
│ ╰───╯ │
|
||||
╰───────────────────────────────────────────╯
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/edit_series_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭─────────────────────────── Edit - Test Series ───────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ ╭───╮ │
|
||||
│ Monitored: ╰───╯ │
|
||||
│ ╭───╮ │
|
||||
│ Season Folder: │ │ │
|
||||
│ ╰───╯ │
|
||||
│ ╭───────────────────────────────────╮ │
|
||||
│ Quality Profile: ╰───────────────────────────────────╯ │
|
||||
│ ╭───────────────────────────────────╮ │
|
||||
│ Language Profile: │English ▼ │ │
|
||||
│ ╰───────────────────────────────────╯ │
|
||||
│ ╭───────────────────────────────────╮ │
|
||||
│ Series Type: ╰───────────────────────────────────╯ │
|
||||
│ ╭───────────────────────────────────╮ │
|
||||
│ Path: │/tv/test │ │
|
||||
│ ╰───────────────────────────────────╯ │
|
||||
│ ╭───────────────────────────────────╮ │
|
||||
│ Tags: ╰───────────────────────────────────╯ │
|
||||
╰────────────────────────────────────────────────────────────────────────────╯
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/episode_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭ Episode Details ─────────────────────────────────────────────────────────────────────╮
|
||||
│ Details │ History │ File │ Manual Search │
|
||||
│────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/episode_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭ Episode Details ─────────────────────────────────────────────────────────────────────╮
|
||||
│ Details │ History │ File │ Manual Search │
|
||||
│────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/episode_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/episode_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭ Episode Details ─────────────────────────────────────────────────────────────────────╮
|
||||
│ Details │ History │ File │ Manual Search │
|
||||
│────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ │
|
||||
│ │
|
||||
│ Loading ... │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/library_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/library_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Loading ...
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/season_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/season_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/season_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
╭ Season 0 Details ─────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Episodes │ History │ Manual Search │
|
||||
│─────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source Age ⛔ Title Indexer Size Peers Languag Quality│
|
||||
│=> 0 days 0.0 GB │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/season_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
╭ Season 0 Details ─────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Episodes │ History │ Manual Search │
|
||||
│─────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source Title Event Type Language Quality Date │
|
||||
│=> unknown 1970-01-01 00:00:00│
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/library/series_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
╭ Test Series ───────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│Title: Test Series │
|
||||
│Overview: │
|
||||
│Network: │
|
||||
│Status: Continuing │
|
||||
│Genres: │
|
||||
│Rating: 0% │
|
||||
│Year: 0 │
|
||||
│Runtime: 0 minutes │
|
||||
│Path: │
|
||||
│╭ Series Details ──────────────────────────────────────────────────────────────────────────────────────╮│
|
||||
││ Seasons │ History ││
|
||||
││────────────────────────────────────────────────────────────────────────────────────────────────────────││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
│╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯│
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
@@ -2,9 +2,14 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, ROOT_FOLDERS_BLOCKS};
|
||||
use crate::models::servarr_models::RootFolder;
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::root_folders::RootFoldersUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_root_folders_ui_accepts() {
|
||||
@@ -16,4 +21,75 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_root_folders_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
RootFoldersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_root_folders_ui_renders_empty_root_folders() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
|
||||
app.data.sonarr_data.root_folders = StatefulTable::default();
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
RootFoldersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_root_folders_ui_renders_with_root_folders() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
|
||||
app.data.sonarr_data.root_folders = StatefulTable::default();
|
||||
app.data.sonarr_data.root_folders.set_items(vec![
|
||||
RootFolder {
|
||||
path: "/tv".to_owned(),
|
||||
accessible: true,
|
||||
free_space: 1024 * 1024 * 1024 * 100,
|
||||
..RootFolder::default()
|
||||
},
|
||||
RootFolder {
|
||||
path: "/media/tv".to_owned(),
|
||||
accessible: true,
|
||||
free_space: 1024 * 1024 * 1024 * 50,
|
||||
..RootFolder::default()
|
||||
},
|
||||
]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
RootFoldersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_root_folders_ui_renders_add_root_folder() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into());
|
||||
app.data.sonarr_data.root_folders = StatefulTable::default();
|
||||
app.data.sonarr_data.edit_root_folder = Some(HorizontallyScrollableText::default());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
RootFoldersUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/root_folders/root_folders_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
╭────── Add Root Folder ───────╮
|
||||
<esc> cancel
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/root_folders/root_folders_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/root_folders/root_folders_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Loading ...
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/root_folders/root_folders_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
Path Free Space Unmapped Folders
|
||||
=> /tv 100.00 GB 0
|
||||
/media/tv 50.00 GB 0
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/sonarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Series ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/sonarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Series ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/sonarr_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Series ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Library │ Downloads │ Blocklist │ History │ Root Folders │ Indexers │ System │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Title Year Network Status Rating Type Quality Prof Language Size Monitor Tags │
|
||||
│=> Test Series 0 Contin Standar Any English 0.00 GB │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
@@ -1,10 +1,16 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bimap::BiMap;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::{
|
||||
models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock,
|
||||
ui::{DrawUi, sonarr_ui::SonarrUi},
|
||||
app::App,
|
||||
models::{
|
||||
servarr_data::sonarr::sonarr_data::ActiveSonarrBlock,
|
||||
sonarr_models::{DownloadRecord, DownloadStatus, Series, SonarrHistoryItem},
|
||||
stateful_table::StatefulTable,
|
||||
},
|
||||
ui::{DrawUi, sonarr_ui::SonarrUi, ui_test_utils::test_utils::render_to_string_with_app},
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -13,4 +19,88 @@ mod tests {
|
||||
assert!(SonarrUi::accepts(active_sonarr_block.into()));
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_ui_renders_downloads_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter(vec![(0, "Any".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter(vec![(0, "English".to_owned())]);
|
||||
app.data.sonarr_data.main_tabs.set_index(1); // Downloads tab
|
||||
app.data.sonarr_data.downloads = StatefulTable::default();
|
||||
app.data.sonarr_data.downloads.set_items(vec![
|
||||
DownloadRecord {
|
||||
id: 1,
|
||||
title: "Test Series S01E01".to_owned(),
|
||||
status: DownloadStatus::Downloading,
|
||||
size: 1500000000.0,
|
||||
sizeleft: 500000000.0,
|
||||
..DownloadRecord::default()
|
||||
},
|
||||
DownloadRecord {
|
||||
id: 2,
|
||||
title: "Another Series S02E05".to_owned(),
|
||||
status: DownloadStatus::Downloading,
|
||||
size: 1200000000.0,
|
||||
sizeleft: 400000000.0,
|
||||
..DownloadRecord::default()
|
||||
},
|
||||
]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SonarrUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_ui_renders_history_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter(vec![(0, "Any".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter(vec![(0, "English".to_owned())]);
|
||||
app.data.sonarr_data.main_tabs.set_index(2); // History tab
|
||||
app.data.sonarr_data.history = StatefulTable::default();
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.history
|
||||
.set_items(vec![SonarrHistoryItem::default()]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SonarrUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_ui_renders_library_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.data.sonarr_data.quality_profile_map = BiMap::from_iter(vec![(0, "Any".to_owned())]);
|
||||
app.data.sonarr_data.language_profiles_map =
|
||||
BiMap::from_iter(vec![(0, "English".to_owned())]);
|
||||
app.data.sonarr_data.main_tabs.set_index(0); // Library tab
|
||||
app.data.sonarr_data.series = StatefulTable::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series {
|
||||
id: 1,
|
||||
title: "Test Series".into(),
|
||||
quality_profile_id: 0,
|
||||
..Series::default()
|
||||
}]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SonarrUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/system/system_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭ Tasks ───────────────────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ Loading ... │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/system/system_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭ Log Details ─────────────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/system/system_details_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
╭ Tasks ───────────────────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/system/system_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Tasks ─────────────────────────────────────────────────╮╭ Queued Events ─────────────────────────────────────────╮
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ Loading ... ││ Loading ... │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
╰──────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────╯
|
||||
╭ Logs ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ Loading ... │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
source: src/ui/sonarr_ui/system/system_ui_tests.rs
|
||||
expression: output
|
||||
---
|
||||
╭ Tasks ─────────────────────────────────────────────────╮╭ Queued Events ─────────────────────────────────────────╮
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
╰──────────────────────────────────────────────────────────╯╰──────────────────────────────────────────────────────────╯
|
||||
╭ Logs ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
@@ -2,11 +2,14 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, SYSTEM_DETAILS_BLOCKS,
|
||||
};
|
||||
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::system::system_details_ui::SystemDetailsUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_system_details_ui_accepts() {
|
||||
@@ -18,4 +21,53 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_system_details_ui_renders_loading_tasks() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SystemTasks.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SystemDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_system_details_ui_renders_logs() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SystemLogs.into());
|
||||
app.data.sonarr_data.logs.set_items(vec![
|
||||
"2023-01-01T12:00:00Z | Info | Test log message 1"
|
||||
.to_owned()
|
||||
.into(),
|
||||
"2023-01-01T12:01:00Z | Warn | Test warning message"
|
||||
.to_owned()
|
||||
.into(),
|
||||
]);
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SystemDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_system_details_ui_renders_tasks() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SystemTasks.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SystemDetailsUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ActiveSonarrBlock, SYSTEM_DETAILS_BLOCKS,
|
||||
};
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::sonarr_ui::system::SystemUi;
|
||||
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
|
||||
|
||||
#[test]
|
||||
fn test_system_ui_accepts() {
|
||||
@@ -22,4 +24,33 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod snapshot_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_system_ui_renders_loading_state() {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::System.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SystemUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_system_ui_renders_system_menu() {
|
||||
let mut app = App::test_default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::System.into());
|
||||
|
||||
let output = render_to_string_with_app(120, 30, &mut app, |f, app| {
|
||||
SystemUi::draw(f, app, f.area());
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user