fix: preserve video selection order for playback
This commit is contained in:
+14
-4
@@ -68,7 +68,7 @@ fn app(args: &[&str]) -> App {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn playback_checks_follow_ids_across_feed_sort_and_clear_on_replacement() {
|
||||
fn playback_checks_preserve_check_order_across_feed_sort_and_clear_on_replacement() {
|
||||
let mut app = app(&["tubular"]);
|
||||
app.view_index = 1;
|
||||
app.feed_channels = vec!["https://www.youtube.com/@fixture".into()];
|
||||
@@ -87,7 +87,7 @@ fn playback_checks_follow_ids_across_feed_sort_and_clear_on_replacement() {
|
||||
.iter()
|
||||
.map(|video| video.id.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
["rQ_J9WH6CGk", "jNQXAC9IVRw"],
|
||||
["jNQXAC9IVRw", "rQ_J9WH6CGk"],
|
||||
);
|
||||
finish_feed_fixture(
|
||||
&mut app,
|
||||
@@ -96,6 +96,16 @@ fn playback_checks_follow_ids_across_feed_sort_and_clear_on_replacement() {
|
||||
);
|
||||
let view = &mut app.views[1];
|
||||
assert_eq!(view.selection.selected(), Some(1));
|
||||
assert_eq!(
|
||||
view.playback_videos()
|
||||
.iter()
|
||||
.map(|video| video.id.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
["jNQXAC9IVRw", "rQ_J9WH6CGk"],
|
||||
);
|
||||
view.selection.select(Some(2));
|
||||
view.toggle_checked();
|
||||
view.toggle_checked();
|
||||
assert_eq!(
|
||||
view.playback_videos()
|
||||
.iter()
|
||||
@@ -251,7 +261,7 @@ fn playback_checks_survive_spawn_failure_clear_after_spawn_and_fall_back_to_hove
|
||||
app.options.player = "/nonexistent/tubular-test-player".into();
|
||||
app.key(KeyEvent::new(KeyCode::Enter, modifiers));
|
||||
assert!(app.player_launch.is_none());
|
||||
assert!(app.views[0].checked.contains("rQ_J9WH6CGk"));
|
||||
assert!(app.views[0].checked.iter().any(|id| id == "rQ_J9WH6CGk"));
|
||||
assert_eq!(app.views[0].playback_videos()[0].id, "rQ_J9WH6CGk");
|
||||
app.options.player = "/usr/bin/true".into();
|
||||
app.key(KeyEvent::new(KeyCode::Enter, modifiers));
|
||||
@@ -6069,7 +6079,7 @@ fn escape_discards_checks_without_consuming_view_history() {
|
||||
app.views[0].loaded = true;
|
||||
app.views[1].loaded = true;
|
||||
app.switch_view(1);
|
||||
app.views[1].checked.insert("jNQXAC9IVRw".into());
|
||||
app.views[1].checked.push("jNQXAC9IVRw".into());
|
||||
app.key(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
|
||||
assert!(app.views[1].checked.is_empty());
|
||||
assert_eq!(app.view_index, 1);
|
||||
|
||||
+14
-18
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user