Files
ewoooc/tests/test_host_health_text_density_guardrails.py
ogt e54549b724
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
fix(obs): quote runtime autoheal action
2026-07-02 20:46:39 +08:00

47 lines
1.7 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_host_health_uses_compact_runtime_workbench_contract():
template = (ROOT / "templates/admin/host_health.html").read_text(encoding="utf-8")
assert 'data-density-guardrail="compact-runtime-workbench"' in template
assert 'aria-label="AI runtime 狀態模式"' in template
assert "主機級聯" in template
assert "自癒閉環" in template
assert "成本節流" in template
def test_host_health_keeps_runtime_signals_and_hides_explanatory_copy():
template = (ROOT / "templates/admin/host_health.html").read_text(encoding="utf-8")
for marker in ["建議服務離線", "AIOps 未解", "自癒成功率", "節流供應商"]:
assert marker in template
assert ".runtime-subtitle, .runtime-signal small, .runtime-footer-copy { display:none; }" in template
assert 'class="runtime-subtitle"' in template
assert "runtime-footer-copy" in template
def test_host_health_preserves_ai_runtime_workflows_and_non_raw_wording():
template = (ROOT / "templates/admin/host_health.html").read_text(encoding="utf-8")
for marker in [
"AI 建議服務主機",
"健康趨勢摘要",
"自癒閉環 7 日",
"工具層與節流",
"成本節流狀態",
"工具服務 24h 工作量",
"最近 10 筆事件",
"最近 10 筆自癒",
"啟動自癒",
"onclick='triggerAutoHeal({{ h.label|tojson }})'",
]:
assert marker in template
for forbidden in ["Runtime", "raw payload", "raw endpoint", "manual_required", "candidate queue", "資料表:"]:
assert forbidden not in template