test: Implemented UI snapshot tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user