Files
uconsole_asw_game/tests/test_editor_field_labels.py
T
Claude 27b17839d9 Translate raw state names on the uConsole and in the web client
Engine telegraph orders, the boat's battery phase, sonar fusion states and
TMA geometry were drawn as internal names (HALF, SUBMERGED, NUR BOW, KEINE);
the web showed sonar array, tow state, ROE, tube and weapon states raw, and
the mission editor showed field.placement.* / field.reach.* keys. All now
come from EN/DE catalog entries, with regression tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdXs5tkJ6kzdeubNWqPHtG
2026-09-27 11:00:17 +00:00

28 lines
1.1 KiB
Python

"""Every field row the editors show has a catalog label (no raw key on screen)."""
import copy
import json
from pathlib import Path
from src.core.i18n import load_catalog
from src.ui import editor_widgets as widgets
def _template(name):
root = Path(__file__).parents[1] / "data" / "editor_templates"
return json.loads((root / name).read_text(encoding="utf-8"))
def test_mission_editor_rows_have_labels():
catalog = load_catalog("en")
mission = _template("mission.json")
unit = {"id": "u1", "kind": "surface", "placement": {"kind": "fixed", "sector": "",
"x": 1.0, "y": 2.0}}
subsets = [mission["world"], mission["player"], mission["environment"],
dict(mission["objective"], reach={"x": 1.0, "y": 1.0, "radius_nm": 2.0}),
unit, *mission["units"]["exact"], *mission["units"]["random_groups"],
*mission["events"]]
labels = {row.label for subset in subsets
for row in widgets.mapping_rows(copy.deepcopy(subset))}
assert sorted(label for label in labels if label not in catalog) == []