From 7dc76c4f3967488c9d844a8bea20ceaa1bc2ce5a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 01:31:26 -0800 Subject: [PATCH] Tests: point the empty description line test at a row that has no sentence Show Slice Numbers now has a sentence. The test goes to the first category other than Units that still has a row without one (Slices when none is left) and points at that row. --- crates/ui-egui/src/prefs_dialog/tests.rs | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index aa94c8b190..cc7e452b30 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -1836,8 +1836,11 @@ fn a_row_without_a_description_leaves_the_line_empty() { description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at(&texts, "General:"))]); let (texts, _) = description_frame(&mut a, &ctx, vec![]); assert!(painted(&texts, general), "the General row's sentence shows: {texts:?}"); - // Go to the Slices category and point at a row with no sentence. - let button = at(&texts, "Slices"); + // Go to the first other category that still has a row with no sentence (Slices when none is + // left) and point at that row. + let bare = settings().find(|s| s.category != "Units" && descriptions::description(s.key).is_none()); + let category = bare.map_or("Slices", |s| s.category); + let button = at(&texts, category); let press = |pressed| egui::Event::PointerButton { pos: button, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(button), press(true), press(false)]); let (texts, _) = description_frame(&mut a, &ctx, vec![]); @@ -1851,13 +1854,19 @@ fn a_row_without_a_description_leaves_the_line_empty() { description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]); let (after, _) = description_frame(&mut a, &ctx, vec![]); empty(&after, "on the line after changing category"); - assert_eq!(descriptions::description("showSliceNumbers"), None); - description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at(&texts, "Show Slice Numbers"))]); - let (after, _) = description_frame(&mut a, &ctx, vec![]); - empty(&after, "on Show Slice Numbers"); - description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]); - let (after, _) = description_frame(&mut a, &ctx, vec![]); - empty(&after, "on the line after Show Slice Numbers"); + if bare.is_some() { + // A checkbox shows its label as it is; other rows show it with a colon. + let (label, pos) = settings() + .filter(|s| s.category == category && descriptions::description(s.key).is_none()) + .find_map(|s| texts.iter().find(|(t, _)| *t == s.label || *t == format!("{}:", s.label)).map(|(_, r)| (s.label, r.center()))) + .unwrap_or_else(|| panic!("no row of {category} without a sentence is drawn: {texts:?}")); + description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(pos)]); + let (after, _) = description_frame(&mut a, &ctx, vec![]); + empty(&after, &format!("on {label}")); + description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]); + let (after, _) = description_frame(&mut a, &ctx, vec![]); + empty(&after, &format!("on the line after {label}")); + } assert_eq!(preferences_window(&ctx).size(), size); }