Files
hockey_new/tests/test_build55_agent_and_account_events.py

56 lines
2.4 KiB
Python

from pathlib import Path
from hockey_data.service import HockeyDataService
from tests.support import LocalTestDatabase
JS = Path("ui_builder/static/app.js").read_text(encoding="utf-8")
HTML = Path("ui_builder/static/index.html").read_text(encoding="utf-8")
AGENT_JS = Path("hockey_data/static/agent-devices.js").read_text(encoding="utf-8")
AGENT_CSS = Path("hockey_data/static/agent-devices.css").read_text(encoding="utf-8")
ROUTER = Path("hockey_data/router.py").read_text(encoding="utf-8")
DATABASE = Path("hockey_data/database.py").read_text(encoding="utf-8")
def test_vmix_agent_is_small_topbar_indicator():
assert 'document.querySelector(".runtime-topbar .runtime-actions")' in AGENT_JS
assert 'toolbar.prepend(root)' in AGENT_JS
assert 'hockey-agent-chip-copy' not in AGENT_JS
assert 'width: 35px;' in AGENT_CSS
assert 'height: 35px;' in AGENT_CSS
assert 'top: calc(100% + 9px);' in AGENT_CSS
assert 'bottom: auto;' in AGENT_CSS
assert 'position: fixed;' not in AGENT_CSS.split('.hockey-agent-panel > header', 1)[0]
def test_account_switch_now_controls_runtime_toasts_without_disabling_triggers():
"""Muted operator toasts never disable automatic broadcast triggers or error messages."""
from tests.ui_contract_support import ui_contract
ui_contract("toasts_triggers")
def test_user_preference_defaults_toasts_on_and_persists_per_account(tmp_path):
db = LocalTestDatabase(tmp_path / "prefs.sqlite")
db.create_all()
service = HockeyDataService.__new__(HockeyDataService)
service.database = db
first = service.user_preference(wfl_user_id="operator-a")
second = service.user_preference(wfl_user_id="operator-b")
assert first["triggers_enabled"] is True
assert first["toasts_enabled"] is True
assert second["triggers_enabled"] is True
assert second["toasts_enabled"] is True
saved = service.save_toasts_preference(wfl_user_id="operator-a", enabled=False)
assert saved["triggers_enabled"] is True
assert saved["toasts_enabled"] is False
assert service.user_preference(wfl_user_id="operator-a")["toasts_enabled"] is False
assert service.user_preference(wfl_user_id="operator-b")["triggers_enabled"] is True
def test_additive_schema_repair_includes_user_preferences():
assert 'UserPreference,' in DATABASE
repair_block = DATABASE[DATABASE.index('for model in ('):DATABASE.index('self._validate_game_table()')]
assert 'UserPreference,' in repair_block