Files
uconsole_asw_game/tests/test_parity.py
T
db9979andClaude Opus 5.5 f6b1223c8e Web radio room, admin room and manual pages in the CIC design
- Radio station without the chart: HF/DF bearing scope (strobe fan per
  intercept, logged bearings dashed, own course), HF receiver channels with
  digital frequency, ground/sky-wave badge, S-meter and log button, and a
  message teletype. No contact dock; the contact detail opens under the
  station panel when a channel is selected.
- Radio projection publishes the measured HF carrier (frequency_khz) and
  propagation mode, as the uConsole tooltip already shows; browser validator,
  projection test and schema test updated.
- /admin (setup, login, room, crew, options) and /manual-en|de restyled on the
  shared tokens and fonts; the PDF build keeps its own print stylesheet.
- Fix: the CIC grid now always fills the viewport height (the operations grid
  row no longer collapses to content when the tab list is hidden).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 13:13:54 +02:00

62 lines
2.7 KiB
Python

"""Web and uConsole show the same operational information."""
from src.commander import projections
from src.core.game import Game
from src.core.station import Station
from src.ui import layout
def test_navigation_projection_carries_the_turn_radius():
game = Game(seed=9090, start_menu=False, audio_enabled=False)
game.ship.speed = 12.0
navigation = projections._own_navigation(game)
assert "turn_radius_nm" in navigation
radius = game.ship.turn_radius_nm
# Straight ahead the radius is infinite, which the projection sends as null.
assert navigation["turn_radius_nm"] == (radius if radius != float("inf") else None)
def test_ciws_release_is_projected_and_commandable():
from src.commander.bridge import _opz_set_ciws
game = Game(seed=9091, start_menu=False, audio_enabled=False)
assert _opz_set_ciws(game, {"enabled": False}, {}) is True
assert game.ciws_authorized is False
def test_local_radio_lists_logged_bearings_and_fixes():
game = Game(seed=9092, start_menu=False, audio_enabled=False)
game.hfdf_log = [dict(track_id="H-1", label="H-ABC123", bearing=45.0,
observer_x=100.0, observer_y=200.0, t=game.sim_t)]
game.hfdf_fixes = {"H-1": dict(label="H-ABC123", x=110.0, y=190.0,
sigma_nm=2.5, covariance_nm2=(1, 0, 1),
t=game.sim_t)}
game.station, game.station_page = Station.RADIO, 0
with layout.capture_text() as text:
game.draw()
shown = " ".join(entry["text"] for entry in text)
assert "H-ABC123" in shown and "045.0" in shown and "2.5" in shown
def test_web_styles_use_tokens_and_the_pygame_theme_covers_chrome():
import re
from pathlib import Path
from src.ui import theme
import sys
sys.path.insert(0, str(Path(__file__).parent))
from commander_web import client_css_files
files = client_css_files()
assert files[0].name == "tokens.css"
tokens = files[0].read_text(encoding="utf-8")
root = tokens[:tokens.index("}")]
for token in ("--aff-unknown", "--aff-friend", "--aff-neutral", "--aff-hostile"):
assert token + ":" in root
# Every colour literal lives in the token file; the rest uses var(--...).
assert tokens.count("}") == 1
commander = files[0].parents[1]
for path in files[1:] + [commander / "admin.css", commander / "manual.css"]:
assert not re.findall(r"#[0-9a-fA-F]{3,8}\b", path.read_text(encoding="utf-8")), path.name
for name in ("COLOR_PANEL_BG", "COLOR_FEED_BG", "COLOR_OVERLAY_BG",
"COLOR_SELECT_BG", "COLOR_ALARM_BG", "COLOR_TAB_ACTIVE"):
assert name in theme.CONFIG_COLORS_STANDARD
assert name in theme.CONFIG_COLORS_HIGH_CONTRAST