from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def test_budget_uses_compact_workbench_contract(): template = (ROOT / "templates/admin/budget.html").read_text(encoding="utf-8") assert 'data-density-guardrail="compact-budget-workbench"' in template assert 'aria-label="AI 成本狀態模式"' in template assert "成本守門" in template assert "節流狀態" in template assert "知識策略" in template def test_budget_keeps_cost_signals_and_hides_explanatory_copy(): template = (ROOT / "templates/admin/budget.html").read_text(encoding="utf-8") for marker in ["當月花費", "預算使用率", "預警", "已節流"]: assert marker in template assert ".gov-subtitle, .gov-action-note, .gov-note, .gov-footer-copy { display:none; }" in template assert 'class="gov-subtitle"' in template assert "gov-action-note" in template assert "gov-footer-copy" in template def test_budget_preserves_cost_governance_tables_and_non_raw_wording(): template = (ROOT / "templates/admin/budget.html").read_text(encoding="utf-8") for marker in ["預算線與節流狀態", "每日成本堆疊趨勢", "Top 5 成本使用情境", "AI 價格決策 7 日"]: assert marker in template for forbidden in ["raw", "endpoint", "artifact", "DB writes", "prune", "manual_required"]: assert forbidden not in template