from pathlib import Path ROOT = Path(__file__).resolve().parents[1] JS = (ROOT / "hockey_data" / "static" / "tournament-menu.js").read_text(encoding="utf-8") ROUTER = (ROOT / "hockey_data" / "router.py").read_text(encoding="utf-8") def test_account_switch_clears_account_bound_runtime_state(): assert 'account: "hockey.accountId"' in JS assert 'previousAccountId !== currentAccountId' in JS assert 'localStorage.removeItem(storage.session)' in JS assert 'localStorage.removeItem(storage.game)' in JS assert 'localStorage.removeItem(storage.vmixDevice)' in JS assert 'await ensureAccountScopedRuntimeState();' in JS def test_match_session_retries_without_stale_agent(): assert 'const selectedDeviceId = currentAgentDeviceId();' in JS assert 'Retry the operator session without Agent' in JS assert 'JSON.stringify({ ...sessionPayload, vmix_device_id: "" })' in JS def test_agent_assignment_cannot_break_operator_session_creation(): assert 'result["agent_warning"] = str(agent_error)[:300]' in ROUTER assert 'result["agent_assignment"] = None' in ROUTER