from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
APP_JS = (ROOT / 'ui_builder' / 'static' / 'app.js').read_text(encoding='utf-8')
CSS = (ROOT / 'ui_builder' / 'static' / 'styles.css').read_text(encoding='utf-8')


def test_onair_prefers_ack_confirmed_sequence_owner():
    assert 'if (sequenceStillOwnsRuntimeOverlay(id)) return true;' in APP_JS
    assert 'Input aliases (GUID/title/number)' in APP_JS


def test_new_quick_panel_items_use_active_editor_tab():
    assert 'activeEditorGroupId = String(state.quickPanelActiveTab || "")' in APP_JS
    assert 'draftGroups.some((group) => group.id === activeEditorGroupId) ? activeEditorGroupId : ""' in APP_JS


def test_quick_panel_editor_tabs_are_collapsible():
    assert 'data-prematch-group-collapse' in APP_JS
    assert 'collapsedEditorGroups' in APP_JS
    assert '.prematch-editor-group.is-collapsed .prematch-editor-group-drop' in CSS


def test_quick_panel_selectors_are_draggable_between_tabs():
    assert 'data-quick-selector-drag' in APP_JS
    assert 'dragSelectorId' in APP_JS
    assert 'selector.group_id = targetGroupId' in APP_JS
