fix(api): 在週報顯示報表資料源沉澱
All checks were successful
Code Review / ai-code-review (push) Successful in 12s
CD Pipeline / tests (push) Successful in 1m39s
CD Pipeline / build-and-deploy (push) Successful in 3m51s
CD Pipeline / post-deploy-checks (push) Successful in 1m56s

This commit is contained in:
Your Name
2026-06-18 19:35:19 +08:00
parent a396f25b8f
commit a46e31bad3
3 changed files with 100 additions and 1 deletions

View File

@@ -453,6 +453,49 @@ def test_weekly_report_keeps_nonzero_source_status_visible() -> None:
assert "Tokens: <code>1,200</code>" in body
def test_weekly_report_includes_report_source_health_assets() -> None:
report = WeeklyReportMessage(
week_range="2026-W25",
report_date="2026-06-18 19:40",
alert_total=4,
ai_proposal_count=1,
commits_count=2,
deploy_count=1,
stats_source_ok=True,
k3s_source_ok=True,
git_source_ok=True,
cost_source_ok=False,
report_source_confidence_percent=40,
report_source_ok_count=2,
report_source_total_count=5,
report_source_gap_ids=[
"report-source-gap:incident_summary",
"report-source-gap:resolution_stats",
"report-source-gap:ai_performance",
],
report_asset_state_lines=[
"KM: draft_ready 3/6",
"PlayBook: draft_required 0/3",
"腳本: readback_only 1/1",
"排程: no_send_preview 3/3",
"Verifier: source_health_ready 1/4",
],
)
body = report.format()
assert "報表資料源 / 沉澱" in body
assert "來源: <code>2/5</code>" in body
assert "信心: <code>40%</code>" in body
assert "report-source-gap:incident_summary" in body
assert "report-source-gap:resolution_stats" in body
assert "report-source-gap:ai_performance" in body
assert "KM: draft_ready 3/6" in body
assert "PlayBook: draft_required 0/3" in body
assert "Verifier: source_health_ready 1/4" in body
assert "不自動改排程" in body
def test_telegram_html_chunks_preserve_complete_lines() -> None:
"""歷史/詳情長訊息不得用 text[:500] 切壞 HTML tag。"""
lines = [