Files
pgames-manager/backend/tests/test_version_languages.py
T
mrleo1nidandClaude Sonnet 5.5 a1f5ef8e2d
CI / frontend (push) Failing after 20s
CI / backend (push) Successful in 51s
feat: language dropdowns on versions and on the game page
- Each ready version gets a "Languages" dropdown next to Play: the original language
  first, then translations with their completion; picking one starts the version in
  that language
- The game header gets the same dropdown, aggregated over published, ready versions.
  Each language points at the version that has it best (most complete, the main
  version on a tie); an original language counts as complete
- The old row of language tags linking to the translation editor is replaced
- Backend: versions carry source_name (the name of the original language)
- pages/languages.ts holds the aggregation logic with tests; LanguageMenu closes on
  outside click and Escape

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 18:41:26 +03:00

21 lines
928 B
Python

from app import translation as tr
def manifest():
return {"files": {"game.json": {"hash": "x", "size": 1}}}
def test_source_language_name_and_translations(monkeypatch):
game = {"sourceLang": "en", "locales": {"ru": {"name": "Русский", "progress": 0.5}, "de": {"progress": 1}}}
monkeypatch.setattr(tr, "file_json", lambda m, path: game)
result = tr.version_languages(manifest())
assert result["source_lang"] == "en"
assert result["source_name"] == tr.LANG_NAMES["en"]
assert [(lang["code"], lang["progress"]) for lang in result["languages"]] == [("de", 1), ("ru", 0.5)]
def test_unknown_or_missing_source_language_has_no_name(monkeypatch):
monkeypatch.setattr(tr, "file_json", lambda m, path: {"sourceLang": "und"})
assert tr.version_languages(manifest())["source_name"] is None
assert tr.version_languages(None) == {"source_lang": None, "source_name": None, "languages": []}