feat: restore original YouTube titles with character transitions

This commit is contained in:
2026-10-19 18:42:19 +02:00
parent 78b0c92e9b
commit a44d95bb71
6 changed files with 474 additions and 2 deletions
+71
View File
@@ -67,6 +67,77 @@ fn app(args: &[&str]) -> App {
)
}
#[test]
fn title_viewport_tracks_selected_two_line_rows_and_resize_without_changing_identity() {
let mut app = app(&["tubular"]);
let template =
youtube::search_results(r#"{"entries":[{"id":"jNQXAC9IVRw","title":"Listing title"}]}"#)
.unwrap()
.videos
.remove(0);
app.views[0].videos = (0..12)
.map(|index| {
let mut video = template.clone();
// Non-YouTube IDs keep this rendering check entirely offline.
video.id = format!("offline:{index}");
video.title = format!("Row {index:02}");
video
})
.collect();
app.views[0].selection.select(Some(9));
let now = Instant::now();
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(80, 24)).unwrap();
terminal
.draw(|frame| app.draw_at(frame, Duration::ZERO, now))
.unwrap();
assert_eq!(app.views[0].selection.offset(), 3);
assert_eq!(
app.views[0].videos[app.views[0].selection.selected().unwrap()].id,
"offline:9"
);
assert!(!app.titles.active());
terminal.backend_mut().resize(80, 17);
terminal
.draw(|frame| {
app.draw_at(
frame,
Duration::from_millis(20),
now + Duration::from_millis(20),
)
})
.unwrap();
assert_eq!(app.views[0].selection.offset(), 7);
assert_eq!(
app.views[0].videos[app.views[0].selection.selected().unwrap()].id,
"offline:9"
);
let rendered: String = terminal
.backend()
.buffer()
.content
.iter()
.map(|cell| cell.symbol())
.collect();
assert!(rendered.contains("Row 09"));
app.views[0].selection.select(Some(0));
terminal
.draw(|frame| {
app.draw_at(
frame,
Duration::from_millis(40),
now + Duration::from_millis(40),
)
})
.unwrap();
assert_eq!(app.views[0].selection.offset(), 0);
assert_eq!(
app.views[0].videos[app.views[0].selection.selected().unwrap()].id,
"offline:0"
);
}
#[test]
fn youtube_collections_isolate_mixed_provider_rows_and_removal_ids() {
let mut app = app(&["tubular"]);