test(lidarr): extract and cover the track row style branch

The snapshot harness renders to a plain string, so colour and text modifiers never reach the assertion. The track row's downloaded and missing arms were therefore invisible to the suite: swapping either arm for the other, or inverting the has_file condition, all left the full run green.

Move the branch into decorate_track_row_with_style, mirroring the row decorators already extracted in the other library detail views, and unit test both arms directly against Row equality. All three mutations now fail the suite.
This commit is contained in:
Dark-Alex-17 committed 2026-09-10 16:19:25 -06:00
1 parent db8e97a700
commit fbf711f428
2 files changed
+51 -15

No files matched your search

+18 -14
View File
@@ -157,7 +157,6 @@ fn draw_tracks_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
title,
duration,
track_file_id,
has_file,
..
} = track;
@@ -187,19 +186,16 @@ fn draw_tracks_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let secs = duration_secs % 60;
let duration_str = format!("{mins}:{secs:02}");
let row = Row::new(vec![
Cell::from(track_number.clone()),
Cell::from(title.clone()),
Cell::from(duration_str),
Cell::from(audio_info),
Cell::from(quality),
]);
if *has_file {
row.downloaded()
} else {
row.missing()
}
decorate_track_row_with_style(
track,
Row::new(vec![
Cell::from(track_number.clone()),
Cell::from(title.clone()),
Cell::from(duration_str),
Cell::from(audio_info),
Cell::from(quality),
]),
)
};
let is_searching = active_lidarr_block == ActiveLidarrBlock::SearchTracks;
@@ -225,6 +221,14 @@ fn draw_tracks_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
}
}
fn decorate_track_row_with_style<'a>(track: &Track, row: Row<'a>) -> Row<'a> {
if track.has_file {
row.downloaded()
} else {
row.missing()
}
}
fn draw_album_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
match app.data.lidarr_data.album_details_modal.as_ref() {
Some(album_details_modal) if !app.is_loading => {
@@ -1,14 +1,20 @@
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use ratatui::widgets::{Cell, Row};
use strum::IntoEnumIterator;
use crate::app::App;
use crate::models::lidarr_models::Track;
use crate::models::servarr_data::lidarr::lidarr_data::{
ALBUM_DETAILS_BLOCKS, ActiveLidarrBlock, TRACK_DETAILS_BLOCKS,
};
use crate::models::stateful_table::StatefulTable;
use crate::ui::DrawUi;
use crate::ui::lidarr_ui::library::album_details_ui::AlbumDetailsUi;
use crate::ui::lidarr_ui::library::album_details_ui::{
AlbumDetailsUi, decorate_track_row_with_style,
};
use crate::ui::styles::ManagarrStyle;
use crate::ui::ui_test_utils::test_utils::render_to_string_with_app;
#[test]
@@ -25,6 +31,32 @@ mod tests {
});
}
#[test]
fn test_decorate_track_row_with_style_downloaded_when_track_has_file() {
let track = Track {
has_file: true,
..Track::default()
};
let row = Row::new(vec![Cell::from("test".to_owned())]);
let style = decorate_track_row_with_style(&track, row.clone());
assert_eq!(style, row.downloaded());
}
#[test]
fn test_decorate_track_row_with_style_missing_when_track_has_no_file() {
let track = Track {
has_file: false,
..Track::default()
};
let row = Row::new(vec![Cell::from("test".to_owned())]);
let style = decorate_track_row_with_style(&track, row.clone());
assert_eq!(style, row.missing());
}
mod snapshot_tests {
use crate::ui::ui_test_utils::test_utils::TerminalSize;
use rstest::rstest;