Merge pull request #3251 from vangel76/tests-pin-english-3244

Tests: Match System resolves to English in ui-egui test builds
This commit is contained in:
FredApps authored and GitHub committed 2026-11-14 17:30:28 +01:00
commit f029bbadb2
3 files changed
+34 -7

No files matched your search

Generated
+1
View File
@@ -2106,6 +2106,7 @@ dependencies = [
"effectcraft-segment",
"effectcraft-text",
"effectcraft-time",
"effectcraft-ui-egui",
"eframe",
"egui",
"egui_extras",
+10
View File
@@ -45,7 +45,17 @@ craft-update = { workspace = true }
pollster = { workspace = true }
sys-locale = { workspace = true }
[features]
# Tests only, never enable in a product: Settings ▸ General ▸ Language ▸ Match System resolves to
# English, so English label lookups pass on any system language (#3244). The self dev-dependency
# below turns it on wherever dev-dependencies are built: this crate's integration tests, its
# examples (`snapshot` shots are deterministic English unless a step sets a language) and
# workspace test builds of the apps (`cargo test --workspace`).
test-support = []
[dev-dependencies]
# This crate's own integration tests build it with `test-support` (see `[features]`).
effectcraft-ui-egui = { workspace = true, features = ["test-support"] }
# Fonts for kittest: the workspace `egui` features are what test roots resolve, but stating them
# here documents the requirement (kittest's own dev-dependencies do not propagate to consumers).
egui = { workspace = true, features = ["default_fonts", "monochrome_emoji_fonts"] }
+23 -7
View File
@@ -84,7 +84,14 @@ pub(crate) fn swedish(app: &EffectcraftApp) -> bool {
/// Settings ▸ General ▸ Language ▸ Match System: the operating system's interface language
/// where EffectCraft has it, else English (#229), as After Effects installs in the system's
/// language. The browser build follows the locales its page passes in ([`set_system_locales`]).
///
/// Test builds (this crate's unit tests, and its integration tests through the `test-support`
/// feature) resolve Match System to English, so tests that look up English labels pass on any
/// system language (#3244); tests about a translation choose their language explicitly.
fn system_language() -> &'static str {
if cfg!(any(test, feature = "test-support")) {
return "en";
}
#[cfg(not(target_arch = "wasm32"))]
{
static LANGUAGE: std::sync::OnceLock<&'static str> = std::sync::OnceLock::new();
@@ -9184,13 +9191,22 @@ mod tests {
}
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
assert_eq!(app.session.prefs.general.language, "system", "the default");
assert_eq!(japanese(&app), system_language() == "ja");
assert_eq!(simplified(&app), system_language() == "zh-hans");
assert_eq!(traditional(&app), system_language() == "zh-hant");
assert_eq!(spanish(&app), system_language() == "es");
assert_eq!(czech(&app), system_language() == "cs");
assert_eq!(polish(&app), system_language() == "pl");
assert_eq!(swedish(&app), system_language() == "sv");
assert_eq!(system_language(), "en", "test builds pin Match System to English (#3244)");
assert_eq!(language(&app), "en");
for (flag, name) in [
(japanese(&app), "ja"),
(simplified(&app), "zh-hans"),
(traditional(&app), "zh-hant"),
(ukrainian(&app), "uk"),
(spanish(&app), "es"),
(brazilian_portuguese(&app), "pt-br"),
(czech(&app), "cs"),
(polish(&app), "pl"),
(georgian(&app), "ka"),
(swedish(&app), "sv"),
] {
assert!(!flag, "Match System shows {name} in a test build");
}
app.session.execute("prefs.set", json!({"key":"general.language", "value":"ja"})).unwrap();
assert!(japanese(&app));
app.session.execute("prefs.set", json!({"key":"general.language", "value":"zh-hans"})).unwrap();