from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
JS = (ROOT / "hockey_data/static/admin-directories.js").read_text(encoding="utf-8")
CSS = (ROOT / "hockey_data/static/admin-directories.css").read_text(encoding="utf-8")
AGENT = (ROOT / "hockey_data/agent_bridge.py").read_text(encoding="utf-8")


def test_mapping_data_group_count_is_right_aligned_before_fixed_arrow():
    assert ".hockey-map-data-group summary b{margin-left:auto" in CSS
    assert ".hockey-map-data-group summary::after{width:14px;flex:0 0 14px;text-align:center}" in CSS
    assert ".hockey-map-data-group summary>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}" in CSS


def test_mapping_inventory_raw_order_remains_available_on_server():
    # Build81 intentionally sorts the operator-facing picker by vMix number.
    # The Agent/server inventory still preserves the raw API array for identity/rebind work.
    assert "function mappingInventoryInputs(profile)" in JS


def test_server_preserves_agent_inventory_array_order():
    # receive_inventory iterates the Agent-provided inputs and appends in that order.
    assert "for raw_input in inputs:" in AGENT
    assert "clean_inputs.append({" in AGENT
    assert '"inputs": clean_inputs' in AGENT
