Home: test the file row layout on Open files

Recent files are cards since #249, so the row test now opens two
documents with synthetic paths and checks the Open files list: the row
that fits shows name and path in full; the long one shows the name cut at
its end, then the path cut at its start, at least 12 px apart, and both in
full on hover. Without the row fix the name shows as "Quar…" under the
path.
This commit is contained in:
Patrick Wozniak
2026-10-14 19:05:12 +02:00
parent f1e0a758d1
commit 639c4d7db0
+19 -15
View File
@@ -223,27 +223,31 @@ fn a_first_run_offers_templates_on_recents_and_recent_files_replace_them() {
}
#[test]
fn a_long_name_and_path_share_their_row_without_overlapping() {
let mut u = first_run();
let name = "Maengelliste-Fenster-Grad-Schlupf-2026-10-15-mit-einem-langen-Rest.figcraft";
let long = format!("/Users/someone/dev/Personal/haus/ProjektHaus/02-Haus/04-maengel/2026-10-15/{name}");
let short = "/tmp/stage1.figcraft";
u.app.session.prefs.recent_files = vec![long.clone(), short.into()];
fn an_open_files_long_name_and_path_share_their_row_without_overlapping() {
let name = "Quarterly planning: onboarding flow review with annotations and handoff notes";
let long = "/Users/alex/Documents/Clients/Northwind Traders/2026 Website relaunch/Design reviews/Week 42/onboarding-flow-review.figcraft";
let short = "/tmp/wireframes.figcraft";
let mut s = Session::new();
s.execute("file.rename", &json!({"name": name})).unwrap();
s.docs[0].path = Some(long.into());
s.execute("file.new", &json!({"name": "Wireframes"})).unwrap();
s.docs[1].path = Some(short.into());
let mut u = Ui::new(s);
u.app.ui.home = true;
u.app.session.prefs.getting_started_dismissed = true;
let s = settle(&mut u);
assert!(has_text(&s, "Open files"));
// A row that fits shows its name and path in full.
assert!(has_text(&s, "stage1.figcraft") && has_text(&s, short));
assert!(has_text(&s, "Wireframes") && has_text(&s, short));
// One that doesn't: the name, then the end of its path, side by side.
let all = texts(&s);
let rect = |(_, p, size): &(String, Pos2, egui::Vec2)| Rect::from_min_size(*p, *size);
let shown_name = all.iter().find(|(t, _, _)| t.starts_with("Ma")).expect("the name");
let name_rect = rect(shown_name);
assert!(shown_name.0.starts_with("Maengelliste-Fenster") && shown_name.0.ends_with('…'), "{:?}", shown_name.0);
let detail = all
.iter()
.find(|e| e.0 != shown_name.0 && e.0.ends_with(".figcraft") && (rect(e).center().y - name_rect.center().y).abs() < 2.0)
.expect("the path on the name's row");
let detail = all.iter().find(|(t, _, _)| t.ends_with("/onboarding-flow-review.figcraft")).expect("the path");
let detail_rect = rect(detail);
let shown_name =
all.iter().find(|e| e.0.starts_with('Q') && (rect(e).center().y - detail_rect.center().y).abs() < 2.0).expect("the name on the path's row");
let name_rect = rect(shown_name);
assert!(shown_name.0.starts_with("Quarterly planning: onboarding") && shown_name.0.ends_with('…'), "{:?}", shown_name.0);
assert!(name_rect.max.x + 12.0 <= detail_rect.min.x, "{:?} {name_rect:?} overlaps {:?} {detail_rect:?}", shown_name.0, detail.0);
assert!(detail.0.starts_with('…') && long.ends_with(detail.0.trim_start_matches('…')), "{:?}", detail.0);
// Hovered, the row shows them in full.
@@ -251,7 +255,7 @@ fn a_long_name_and_path_share_their_row_without_overlapping() {
for _ in 0..60 {
u.frame(vec![]);
}
assert!(texts(&shapes(&mut u)).iter().any(|(t, _, _)| t.contains(&long)), "no tooltip with the full path");
assert!(texts(&shapes(&mut u)).iter().any(|(t, _, _)| t.contains(long)), "no tooltip with the full path");
}
#[test]