Files
ewoooc/tests/test_ai_calls_text_density_guardrails.py
ogt 9dc0393f5e
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
style(obs): compact ai calls workbench copy
2026-07-02 20:07:36 +08:00

38 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_ai_calls_uses_compact_workbench_contract():
template = (ROOT / "templates/admin/ai_calls_dashboard.html").read_text(encoding="utf-8")
assert 'data-density-guardrail="compact-ai-calls-workbench"' in template
assert 'aria-label="AI 流量狀態模式"' in template
assert "流量監控" in template
assert "成本守門" in template
assert "知識命中" in template
def test_ai_calls_keeps_core_signals_and_hides_explanatory_copy():
template = (ROOT / "templates/admin/ai_calls_dashboard.html").read_text(encoding="utf-8")
for marker in ["呼叫總量", "用量", "成本", "延遲", "知識命中", "錯誤"]:
assert marker in template
assert ".calls-subtitle, .calls-note, .calls-context-note, .calls-footer-copy { display:none; }" in template
assert 'class="calls-subtitle"' in template
assert 'class="calls-note"' in template
assert "calls-context-note" in template
assert "calls-footer-copy" in template
def test_ai_calls_preserves_workbench_tables_and_non_raw_wording():
template = (ROOT / "templates/admin/ai_calls_dashboard.html").read_text(encoding="utf-8")
for marker in ["情境 × 知識命中矩陣", "最近作戰素材", "最近呼叫 100 筆"]:
assert marker in template
for forbidden in ["權杖量", "權杖/次", ">權杖<", "Agent 上下文", "RAG × MCP"]:
assert forbidden not in template