From c3a717a0931225870672ae3d2efcf7c6f45c485a Mon Sep 17 00:00:00 2001 From: feraremag2680 Date: Sat, 10 Oct 2026 00:37:24 +0200 Subject: [PATCH] tests: pin the interface language in the harnesses added since #502 (#593) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tests: pin the interface language in the harnesses added since #502 #502 pinned it in every harness there was. These five arrived after its branch point, so the suite is red again on a machine whose display language has a catalog: - `commands.rs`, Clear Recent Files from the menu (#557). - `editing.rs`, `session_harness` (#462), which clicks "Don't save". - `stamps.rs`, the rotated-stamp test (#473), which clicks "OK". - `ui.rs`, removing one recent file from Home (#557), and the narrow tab strip (#416), which reads "Display theme:". The eight other `PdfCraftApp::new()` without the line never draw the shell, so `i18n::set_current` is never called and the thread-local stays on English. They compare saved state or a default, and are left alone — including the one that asserts on a `notify_tr` toast, which reads English for the same reason. Co-Authored-By: Claude Opus 5 * tests: pin the interface language in the date-format and Pages-panel harnesses too --------- Co-authored-by: Fernando Areán Co-authored-by: Claude Opus 5 Co-authored-by: Brandon Thomas --- crates/ui-egui/tests/commands.rs | 1 + crates/ui-egui/tests/date_format.rs | 3 +++ crates/ui-egui/tests/editing.rs | 1 + crates/ui-egui/tests/stamps.rs | 1 + crates/ui-egui/tests/ui.rs | 2 ++ crates/ui-egui/tests/viewer.rs | 1 + 6 files changed, 9 insertions(+) diff --git a/crates/ui-egui/tests/commands.rs b/crates/ui-egui/tests/commands.rs index 7119821e25..310602d852 100644 --- a/crates/ui-egui/tests/commands.rs +++ b/crates/ui-egui/tests/commands.rs @@ -251,6 +251,7 @@ fn recent_file(name: &str) -> pdfcraft_ui_egui::RecentFile { fn clear_recent_files_at_the_foot_of_open_recent_empties_the_list() { let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); app.open_bytes("doc.pdf", None, fixture(3)).unwrap(); app.recent.extend([recent_file("first.pdf"), recent_file("second.pdf")]); app diff --git a/crates/ui-egui/tests/date_format.rs b/crates/ui-egui/tests/date_format.rs index 161784c358..aa523d45e5 100644 --- a/crates/ui-egui/tests/date_format.rs +++ b/crates/ui-egui/tests/date_format.rs @@ -30,6 +30,7 @@ fn retype(h: &mut Harness<'static, PdfCraftApp>, text: &str) { fn fill_and_sign_dates_follow_the_date_format_preference_and_it_is_remembered() { let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); app.open_bytes("form.pdf", None, PDF.to_vec()).expect("opens"); app.set_option("left", "closed").unwrap(); app.set_option("dialog", "preferences").unwrap(); @@ -99,6 +100,7 @@ fn fill_and_sign_dates_follow_the_date_format_preference_and_it_is_remembered() fn month_names_follow_the_date_language_or_else_the_interface_language() { let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); app.set_option("date-format", "d mmmm yyyy").unwrap(); app.set_option("language", "cs").unwrap(); app.set_option("dialog", "preferences").unwrap(); @@ -130,6 +132,7 @@ fn month_names_follow_the_date_language_or_else_the_interface_language() { fn a_date_the_pdf_cannot_hold_is_refused_with_a_warning_first() { let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); app.open_bytes("form.pdf", None, PDF.to_vec()).expect("opens"); app.set_option("left", "closed").unwrap(); // Japanese weekday names: Fill & Sign text can't hold them yet. diff --git a/crates/ui-egui/tests/editing.rs b/crates/ui-egui/tests/editing.rs index 668852bb69..61410be2b0 100644 --- a/crates/ui-egui/tests/editing.rs +++ b/crates/ui-egui/tests/editing.rs @@ -416,6 +416,7 @@ impl Drop for TempPdfs { fn session_harness(setup: impl FnOnce(&mut PdfCraftApp) + 'static) -> Harness<'static, PdfCraftApp> { let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); app.reopen_last_session = true; setup(&mut app); app diff --git a/crates/ui-egui/tests/stamps.rs b/crates/ui-egui/tests/stamps.rs index 66144da500..46798e8c01 100644 --- a/crates/ui-egui/tests/stamps.rs +++ b/crates/ui-egui/tests/stamps.rs @@ -49,6 +49,7 @@ fn natural_image_stamps_keep_displayed_bounds_on_rotated_pages() { for degrees in [0, 90, 180, 270] { let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); app.open_bytes("form.pdf", None, include_bytes!("data/form.pdf").to_vec()).unwrap(); let id = app.views[0].id; app.session.apply(id, pdfcraft_engine::Edit::RotatePages { pages: vec![0], degrees }).unwrap(); diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index 970c5173e0..46a5e3dc2e 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -72,6 +72,7 @@ fn home_removes_one_recent_file_or_clears_them_all() { // Tall enough that the Recent list is on screen without scrolling. let mut h = Harness::builder().with_size(egui::vec2(1400.0, 1600.0)).build_eframe(|_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); for name in ["first.pdf", "second.pdf", "third.pdf"] { app.recent.push(pdfcraft_ui_egui::RecentFile { name: name.into(), path: format!("/nowhere/{name}"), pages: 1, size: 0 }); } @@ -176,6 +177,7 @@ fn narrow_tab_strips_accept_vertical_wheel_scrolling() { for width in [600.0, 900.0] { let mut h = Harness::builder().with_size(egui::vec2(width, 700.0)).build_eframe(|_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); for i in 0..12 { app.open_bytes(&format!("narrow-{i:02}.pdf"), None, FIXTURE.to_vec()).unwrap(); } diff --git a/crates/ui-egui/tests/viewer.rs b/crates/ui-egui/tests/viewer.rs index ebac7540a9..af89def4b9 100644 --- a/crates/ui-egui/tests/viewer.rs +++ b/crates/ui-egui/tests/viewer.rs @@ -682,6 +682,7 @@ fn pages_panel_harness(sizes: &[(u32, u32)]) -> Harness<'static, PdfCraftApp> { let bytes = sized_fixture(sizes); let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |_cc| { let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); app.open_bytes("cheques.pdf", None, bytes).unwrap(); app.right = Some(pdfcraft_ui_egui::RightPanel::Pages); app