test(i18n): guard the remaining non-English lookups on the catalogs

Five tests unwrapped a non-English Lang (or fell back to the system
language) without craft-i18n; they now skip those languages via
needs_catalogs() and keep their English cases. Help search drops a silent
early return for the same guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Martin BallandClaude Opus 5.5 committed 2026-11-08 22:30:48 +00:00
1 parent 786b45a8a5
commit 667e83fd11
6 files changed
+24 -2

No files matched your search

+4
View File
@@ -583,6 +583,10 @@ mod tests {
#[test]
fn menu_i_key_does_not_leak_dotless_text_into_zoom_in_any_ui_language() {
for code in ["az", "tr", "en", "de"] {
// English runs in every build; the others need the craft-i18n catalogs.
if code != "en" && !crate::i18n::needs_catalogs() {
continue;
}
let lang = crate::i18n::Lang::from_code(code).unwrap();
crate::i18n::with_language(lang, || {
for text in ["I", "i", "İ", "ı"] {
@@ -228,6 +228,10 @@ fn sample_params(kind: &str) -> Value {
#[test]
fn curves_dialog_fits_its_graph_and_controls() {
for language in ["en", "ru"] {
// English runs in every build; Russian needs the craft-i18n catalogs.
if language != "en" && !crate::i18n::needs_catalogs() {
continue;
}
let _language = crate::i18n::language_scope(crate::i18n::Lang::from_code(language).unwrap());
for theme in crate::theme::ThemeKind::ALL {
for size in [egui::vec2(1280.0, 900.0), egui::vec2(900.0, 720.0)] {
@@ -283,6 +283,9 @@ fn underlined_text_marks_the_mnemonic_once_and_keeps_the_prefix() {
/// Access keys preserve visible spelling and underline only the locale-correct I pair.
#[test]
fn azerbaijani_and_turkish_mnemonics_keep_the_two_i_pairs_distinct() {
if !crate::i18n::needs_catalogs() {
return;
}
for code in ["az", "tr"] {
let lang = crate::i18n::Lang::from_code(code).unwrap();
crate::i18n::with_language(lang, || {
+4 -1
View File
@@ -303,9 +303,12 @@ fn help_search_finds_commands_by_any_word() {
/// In another UI language both the translated and the English names match.
#[test]
fn help_search_matches_the_ui_language_and_english() {
if !crate::i18n::needs_catalogs() {
return;
}
let app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
let items = menu_items(&app);
let Some(fr) = crate::i18n::Lang::from_code("fr") else { return };
let fr = crate::i18n::Lang::from_code("fr").expect("fr registered");
let ids = |q: &str| search_items(&items, q, fr).iter().map(|i| i.id.clone()).collect::<Vec<_>>();
assert!(!ids(&crate::i18n::tr(fr, "Layer").to_lowercase()).is_empty(), "French menu name");
assert!(ids("distort").contains(&"edit.transform.distort".to_string()), "English still matches");
@@ -56,7 +56,11 @@ fn mask_toggle_context_menu_follows_the_clicked_layer_and_existing_translations(
use egui_kittest::{Harness, kittest::Queryable};
for language in ["en", "fr"] {
let lang = crate::i18n::Lang::from_pref(language);
// English runs in every build; French needs the craft-i18n catalogs.
if language != "en" && !crate::i18n::needs_catalogs() {
continue;
}
let lang = crate::i18n::Lang::from_code(language).expect("registered language");
let _language = crate::i18n::language_scope(lang);
let mut s = photocraft_engine::Session::new();
s.execute("file.new", json!({"width": 10, "height": 10})).unwrap();
+4
View File
@@ -146,6 +146,10 @@ fn the_prompt_is_translated_and_still_names_its_file() {
let png = adobe_png();
let template = "The document “{name}” has an embedded color profile that does not match the current {mode} working space.";
for code in ["en", "de", "fr", "ja"] {
// English runs in every build; the others need the craft-i18n catalogs.
if code != "en" && !crate::i18n::needs_catalogs() {
continue;
}
let services = Services {
import: Some(Box::new(|name, bytes, opts| {
photocraft_io::import_with_options(name, bytes, opts).map(|r| (r.document, r.warnings)).map_err(|e| e.to_string())