diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index fc98bdcff9..eb6b0cde72 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -1690,6 +1690,26 @@ fn menu_items_side_by_side_have_different_labels() { assert!(same.is_empty(), "{} pairs of menu items look alike:\n{}", same.len(), same.join("\n")); } +/// Whether a menu label shows an id: a dotted command id, inside backticks or outside them, or +/// `key`, the command or effect id of its item, on its own. +fn label_shows_an_id(label: &str, key: &str) -> bool { + let plain = label.replace('`', " "); + !command_ids(&plain).is_empty() || plain.trim() == key +} + +#[test] +fn label_shows_an_id_finds_ids_in_backticks_and_bare_keys() { + let key = "type.convertListToText"; + assert!(label_shows_an_id("type.convertListToText", key)); + assert!(label_shows_an_id("`type.convertListToText`", key)); + assert!(label_shows_an_id("`type.convertListToText", key)); + assert!(label_shows_an_id("Convert (`slice.list`)", key)); + assert!(label_shows_an_id("roughen", "roughen")); + assert!(label_shows_an_id("`roughen`", "roughen")); + assert!(!label_shows_an_id("Convert to Text", key)); + assert!(!label_shows_an_id("Roughen…", "roughen")); +} + /// Menu items show words, never the command or effect id their catalog row is keyed by. #[test] fn menu_items_never_show_an_id() { @@ -1698,7 +1718,7 @@ fn menu_items_never_show_an_id() { if let crate::menus::Item::Cmd(l, id, p) = item { let key = menu_item_effect(id, p).unwrap_or(id); let shown = shown_menu_label(lang, item).unwrap_or_default(); - if !command_ids(shown).is_empty() && command_ids(l).is_empty() { + if label_shows_an_id(shown, key) && !label_shows_an_id(l, key) { out.push(format!("{}: {l:?} ({key}) shows {shown:?}", lang.0.code)); } }