from pathlib import Path


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


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

    assert 'data-density-guardrail="compact-promotion-workbench"' in template
    assert 'aria-label="AI 晉升狀態模式"' in template
    assert "AI 例外" in template
    assert "去重守門" in template
    assert "防污染" in template


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

    for marker in ["待決策", "知識庫", "30 日採用", "污染攔截"]:
        assert marker in template

    assert ".gate-subtitle, .gate-signal small, .gate-review-copy, .gate-footer-copy { display:none; }" in template
    assert 'class="gate-subtitle"' in template
    assert "gate-review-copy" in template
    assert "gate-footer-copy" in template


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

    for marker in [
        "AI 晉升例外台",
        "例外佇列",
        "待決策片段",
        "採用晉升",
        "否決污染",
        "30 日狀態分布",
        "策略權重 Top",
        "最近 10 筆 ai_insights",
    ]:
        assert marker in template

    for forbidden in [
        "人工審核",
        "人工拒",
        "manual_required",
        "raw payload",
        "raw endpoint",
        "資料表:",
    ]:
        assert forbidden not in template
