test(ui): cover runtime tooltips and current region shortcut

This commit is contained in:
AnhNgoo
2026-10-28 10:31:19 +07:00
parent 712f45965b
commit dd48d09605
2 changed files with 42 additions and 0 deletions
+20
View File
@@ -44,6 +44,7 @@ const SHORTCUTS: &[(&str, &str, &str, Option<&str>)] = &[
("home.alignLeft", "", "⌘L", None),
("home.alignCenter", "", "⌘E", None),
("selection.row", "", "Shift+Space", Some("Shift+Space")),
("selection.currentRegion", "", "Control+Shift+8", Some("Ctrl+Shift+8")),
("selection.column", "", "Control+Space", Some("Ctrl+Space")),
("view.showObjects", "", "Control+6", Some("Ctrl+6")),
("formulas.showFormulas", "Show Formulas", "⌘`", Some("Ctrl+`")),
@@ -747,4 +748,23 @@ mod tooltip_shortcut_tests {
}
}
}
#[test]
fn ribbon_tip_text_obeys_runtime_os() {
use egui::os::OperatingSystem;
for (os, expected) in [(OperatingSystem::Windows, "Flash Fill (Ctrl+E)"), (OperatingSystem::Mac, "Flash Fill (Control+E)")] {
let ctx = egui::Context::default();
ctx.set_os(os);
let mut actual = String::new();
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
actual = super::tip_text(ui, "Flash Fill");
});
output.textures_delta.clear();
assert_eq!(actual, expected, "{os:?}");
}
}
}
+22
View File
@@ -229,3 +229,25 @@ fn command_palette_and_ribbon_tooltips_share_shortcuts() {
assert_eq!(command_shortcut("selection.row", false), Some("Shift+Space"));
assert_eq!(command_shortcut("unverified.command", false), None);
}
/// Current Region must show the physical Control shortcut on both platforms.
#[test]
fn command_search_shows_current_region_shortcut() {
use egui::os::OperatingSystem;
for (os, expected) in
[(OperatingSystem::Windows, "Select Current Region (Ctrl+Shift+8)"), (OperatingSystem::Mac, "Select Current Region (Control+Shift+8)")]
{
let mut h = harness();
h.ctx.set_os(os);
h.run_steps(2);
h.state_mut().open_dialog("commandSearch", json!({}));
h.run_steps(6);
h.state_mut().dialog.as_mut().unwrap().search = "selection.currentRegion".into();
h.run_steps(3);
h.get_by_label_contains(expected);
}
}