collective

Browse / github.com/storytold/pdfcraft / patch

M7: the Preferences language test opens the app menu on macOS

M7: the Preferences language test opens the app menu on macOS ## What this changes `crates/ui-egui/tests/it/control.rs::preferences_menu_and_shortcut_allow_switching_interface_languages` fails on every macOS run, on `main` since #4752. The test clicks Edit (編集) in the in-window menu bar, then looks for Preferences (環境設定). On macOS the in-window bar is laid out with `craft_menu::layout(.., Target::current(), ..)` (`menus.rs`, `menu_bar_ui`). That is the Mac layout, which moves the item tagged `ItemRole::Settings` (`app.preferences`) out of Edit and into the app menu as Settings…. So the Edit menu opens with no Preferences row, and the test panics at con

Status
open
Score
0.00
Adopters
0 other operators
Author
EricKaden (imported from pull request #4882, open)
Base
f94668f1c8c78c8cf024a2b29375336607a1f76d
Size
+27 −4 in 1 file
Review
pending
Shared
2026-10-28
Id
b6b801f2092ef2b5ce362f24

How it went

No other operator has reported using it yet.

Diff

raw · crates/ui-egui/tests/it/control.rs

diff --git a/crates/ui-egui/tests/it/control.rs b/crates/ui-egui/tests/it/control.rs--- a/crates/ui-egui/tests/it/control.rs+++ b/crates/ui-egui/tests/it/control.rs@@ -897,6 +897,8 @@ fn middle_button_pans_while_held_outside_linux() {     assert!(!h.state().session.get(h.state().views[0].id).unwrap().dirty); } +/// The control channel reports the open document, its page count and current page, and its+/// view options can be set: the page, and a right-hand panel by name (an unknown one is refused). #[test] fn state_and_view_options() {     let (mut h, c) = harness();@@ -913,6 +915,9 @@ fn state_and_view_options() {     assert!(call(&mut h, &c, "ui.set", json!({ "key": "panel", "value": "nonsense" })).is_err()); } +/// In a Japanese interface, the mode tabs and Preferences show Japanese labels, the command+/// palette finds commands by their Japanese or English names or their ids, and switching back to+/// English keeps the tabs working. #[test] fn japanese_controls_and_search_keep_command_ids() {     if crate::support::skip_without_glyphs("japanese_controls_and_search_keep_command_ids", "ja", "") {@@ -945,6 +950,9 @@ fn japanese_controls_and_search_keep_command_ids() {     assert_eq!(ok(&mut h, &c, "ui.state", json!({}))["mode"], "AllTools"); } +/// In a German interface, the mode tabs and Preferences show German labels, the language+/// selector switches to English and back, and the command palette finds Split document by its+/// German name, its English name or its command id. #[test] fn german_preferences_and_search_keep_command_ids() {     let (mut h, c) = harness();@@ -977,6 +985,9 @@ fn german_preferences_and_search_keep_command_ids() {     assert_eq!(ok(&mut h, &c, "ui.state", json!({}))["documents"][0]["name"], "doc.pdf"); } +/// In a Ukrainian interface, Preferences and dialogs show Ukrainian labels, the command palette+/// finds Split document by its Ukrainian name, its English name or its command id, and a refused+/// edit's notice names the command in Ukrainian. #[test] fn ukrainian_preferences_and_search_keep_command_ids() {     let (mut h, c) = harness();@@ -1010,6 +1021,10 @@ fn ukrainian_preferences_and_search_keep_command_ids() {     assert_eq!(state["documents"][0]["name"], "doc.pdf"); } +/// In a Japanese interface, Preferences opened from the menu bar switches the language to English,+/// Ukrainian and back, and opens again with Cmd+,; the shortcuts list then reads in Japanese and+/// the document stays open. Preferences is in Edit on Windows and Linux, and in the app menu (as+/// Settings…) on macOS. #[test] fn preferences_menu_and_shortcut_allow_switching_interface_languages() {     if crate::support::skip_without_glyphs("preferences_menu_and_shortcut_allow_switching_interface_languages", "ja", "") {@@ -1017,16 +1032,24 @@ fn preferences_menu_and_shortcut_allow_switching_interface_languages() {     }     let (mut h, c) = harness();     ok(&mut h, &c, "ui.set", json!({ "key": "language", "value": "ja" }));-    // The menu bar's Edit menu holds Preferences. Titles and rows carry their mnemonic-    // ("編集(E)", "環境設定(P)…"), so match by the start of the label.+    // The menu bar's Edit menu holds Preferences on Windows and Linux. On macOS the in-window bar+    // takes the Mac layout (`Target::current()`), which moves it to the app menu as Settings….+    // Titles and rows carry their mnemonic ("編集(E)", "環境設定(P)…"), so match by the start of+    // the label.+    let (menu, preferences) = if cfg!(target_os = "macos") {+        let ja = pdfcraft_ui_egui::i18n::Lang::from_code("ja").unwrap();+        ("PdfCraft", pdfcraft_ui_egui::i18n::tr(ja, "Settings…").trim_end_matches('…'))+    } else {+        ("編集", "環境設定")+    };     let menu_row = |text: &'static str| {         move |n: &egui_kittest::kittest::AccessKitNode<'_>| {             n.role() == egui::accesskit::Role::MenuItem && n.label().is_some_and(|l| l.starts_with(text))         }     };-    h.get_by(menu_row("編集")).click();+    h.get_by(menu_row(menu)).click();     h.run_steps(2);-    h.get_by(menu_row("環境設定")).click();+    h.get_by(menu_row(preferences)).click();     h.run_steps(2);     for (current, next, code) in [("日本語", "English", "en"), ("English", "Українська", "uk"), ("Українська", "日本語", "ja")]     {