fix(test): remove tests that check specific translation content

Remove three tests that asserted exact translated strings for German,
French, and Chinese locales. These tests broke whenever translation
files were updated externally.

Replace content-checking tests with behavioral assertions:
- Translated values are non-empty strings (not the raw key)
- Fallback and None-locale return the English translation
- Placeholder interpolation injects the kwarg value

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-14 08:47:56 +00:00
parent f0f9165958
commit 08fabe154a
+19 -23
View File
@@ -70,34 +70,28 @@ class TestTranslate:
reload_translations()
@pytest.mark.unit
def test_translate_english_key(self) -> None:
"""English keys should resolve to English text."""
def test_translate_known_key_returns_non_empty_string(self) -> None:
"""A valid key should resolve to a non-empty string (not the key itself)."""
result = translate("nav.dashboard", "en")
assert result == "Dashboard"
assert isinstance(result, str)
assert result != ""
assert result != "nav.dashboard"
@pytest.mark.unit
def test_translate_german_key(self) -> None:
"""German locale should return German text."""
result = translate("nav.dashboard", "de")
assert result == "Übersicht"
@pytest.mark.unit
def test_translate_french_key(self) -> None:
"""French locale should return French text."""
result = translate("nav.dashboard", "fr")
assert result == "Tableau de bord"
@pytest.mark.unit
def test_translate_chinese_key(self) -> None:
"""Chinese locale should return Chinese text."""
result = translate("nav.dashboard", "zh")
assert result == "仪表盘"
def test_translate_non_english_locale_returns_value(self) -> None:
"""Non-English locales should return a non-empty translated value."""
for locale in ("de", "fr", "zh"):
result = translate("nav.dashboard", locale)
assert isinstance(result, str)
assert result != ""
assert result != "nav.dashboard"
@pytest.mark.unit
def test_translate_fallback_to_english(self) -> None:
"""Unknown locale falls back to English."""
"""Unknown locale falls back to English translation."""
result = translate("nav.dashboard", "xx")
assert result == "Dashboard"
english = translate("nav.dashboard", "en")
assert result == english
@pytest.mark.unit
def test_translate_missing_key_returns_key(self) -> None:
@@ -109,13 +103,15 @@ class TestTranslate:
def test_translate_none_locale_uses_default(self) -> None:
"""None locale defaults to English."""
result = translate("nav.dashboard", None)
assert result == "Dashboard"
english = translate("nav.dashboard", "en")
assert result == english
@pytest.mark.unit
def test_translate_with_kwargs(self) -> None:
"""Placeholders should be interpolated via kwargs."""
result = translate("footer.copyright", "en", year="2025")
assert result == "DocuElevate 2025"
assert "2025" in result
assert result != "footer.copyright"
@pytest.mark.unit
def test_translate_with_kwargs_german(self) -> None: