from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def test_business_intel_uses_compact_workbench_contract():
    template = (ROOT / "templates/admin/business_intel.html").read_text(encoding="utf-8")

    assert 'data-density-guardrail="compact-business-workbench"' in template
    assert 'aria-label="AI 商業狀態模式"' in template
    assert "戰果追蹤" in template
    assert "閉環成效" in template
    assert "競品訊號" in template


def test_business_intel_keeps_business_signals_and_hides_explanatory_copy():
    template = (ROOT / "templates/admin/business_intel.html").read_text(encoding="utf-8")

    for marker in ["高信心未跟進", "平均信心分", "有效率", "競品監測"]:
        assert marker in template

    assert ".biz-command-copy,\n.biz-filter-note,\n.biz-signal .note,\n.biz-panel-head p,\n.biz-footer-copy" in template
    assert 'class="biz-command-copy"' in template
    assert "biz-filter-note" in template
    assert "biz-footer-copy" in template


def test_business_intel_preserves_commercial_workflow_and_non_raw_wording():
    template = (ROOT / "templates/admin/business_intel.html").read_text(encoding="utf-8")

    for marker in [
        "外部促銷活動監控",
        "PChome 業績提升解法矩陣",
        "策略族群雷達",
        "最近 AI 價格建議",
        "閉環學習紀錄",
        "競品比對品質",
    ]:
        assert marker in template

    for forbidden in [
        "candidate queue",
        "資料表：",
        "資料表:",
        "raw payload",
        "raw endpoint",
        "artifact",
        "manual_required",
    ]:
        assert forbidden not in template
