fix: preserve video selection order for playback

This commit is contained in:
2026-10-25 12:06:13 +01:00
parent 090f077eeb
commit ae87bb8b36
6 changed files with 75 additions and 60 deletions
+14 -18
View File
@@ -576,7 +576,7 @@ fn empty_errors_and_query_controls_do_not_create_results_or_commands() {
}
#[test]
fn episode_checks_follow_returned_order_and_cached_screen_history() {
fn episode_checks_preserve_check_order_and_cached_screen_history() {
use ratatui::{Terminal, backend::TestBackend};
let directory = Directory::new();
@@ -595,7 +595,7 @@ fn episode_checks_follow_returned_order_and_cached_screen_history() {
.map(|video| video.id)
.collect::<Vec<_>>()
};
assert_eq!(ids(&browser), ["miruro:first:3", "miruro:first:7"]);
assert_eq!(ids(&browser), ["miruro:first:7", "miruro:first:3"]);
assert!(browser.hints().contains("play checked"));
assert!(browser.hints().contains("clear checks"));
let mut terminal = Terminal::new(TestBackend::new(120, 32)).unwrap();
@@ -610,6 +610,11 @@ fn episode_checks_follow_returned_order_and_cached_screen_history() {
.map(|cell| cell.symbol())
.collect();
assert!(text.contains("2 checked"));
browser.select(Action::VideoLast);
browser.key(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
assert_eq!(ids(&browser), ["miruro:first:3"]);
browser.key(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
assert_eq!(ids(&browser), ["miruro:first:3", "miruro:first:7"]);
if let Content::Series {
data: Some(data), ..
@@ -618,13 +623,13 @@ fn episode_checks_follow_returned_order_and_cached_screen_history() {
data.reverse();
}
browser.screen_mut().rebuild_display();
assert_eq!(ids(&browser), ["miruro:first:7", "miruro:first:3"]);
assert_eq!(ids(&browser), ["miruro:first:3", "miruro:first:7"]);
browser.history(false);
assert!(browser.screen().checked.is_empty());
browser.history(true);
assert_eq!(ids(&browser), ["miruro:first:7", "miruro:first:3"]);
assert_eq!(ids(&browser), ["miruro:first:3", "miruro:first:7"]);
browser.screen_mut().selection.select(None);
assert_eq!(ids(&browser), ["miruro:first:7", "miruro:first:3"]);
assert_eq!(ids(&browser), ["miruro:first:3", "miruro:first:7"]);
browser.select(Action::VideoLast);
browser.key(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::CONTROL));
assert!(browser.screen().checked.is_empty());
@@ -676,20 +681,14 @@ fn catalog_and_saved_show_rows_cannot_be_checked() {
enter_series(&mut browser);
assert_eq!(browser.screen().len(), 2);
browser.key(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
assert_eq!(
browser.screen().checked,
BTreeSet::from(["miruro:first:3".into()])
);
assert_eq!(browser.screen().checked, ["miruro:first:3"]);
browser.edit_search();
browser.key(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
assert_eq!(browser.input.as_deref(), Some(" "));
assert!(browser.screen().checked.is_empty());
browser.input = None;
browser.history(false);
assert_eq!(
browser.screen().checked,
BTreeSet::from(["miruro:first:3".into()])
);
assert_eq!(browser.screen().checked, ["miruro:first:3"]);
}
#[test]
@@ -715,10 +714,7 @@ fn collection_checks_prune_hidden_and_removed_episodes_without_resurrection() {
browser.rebuild_collections();
assert_eq!(browser.screen().checked.len(), 2);
browser.key(KeyEvent::new(KeyCode::Char('f'), KeyModifiers::NONE));
assert_eq!(
browser.screen().checked,
BTreeSet::from([second.id.clone()])
);
assert_eq!(browser.screen().checked, [second.id.clone()]);
assert_eq!(browser.screen().playback_videos()[0].id, second.id);
browser.key(KeyEvent::new(KeyCode::Char('f'), KeyModifiers::NONE));
assert!(browser.screen().checked.is_empty());
@@ -757,7 +753,7 @@ fn episode_launch_retains_checks_on_failure_and_clears_only_after_spawn() {
);
browser.key(KeyEvent::new(KeyCode::Enter, modifiers));
assert!(browser.screen().error.is_some());
assert_eq!(browser.screen().checked, BTreeSet::from([first.id.clone()]));
assert_eq!(browser.screen().checked, [first.id.clone()]);
assert_eq!(browser.screen().playback_videos()[0].id, first.id);
browser.key(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
browser.options.player = "/usr/bin/true".into();