fix(api): 在日報月報 preview 顯示資料源沉澱
Some checks failed
Code Review / ai-code-review (push) Successful in 17s
CD Pipeline / tests (push) Successful in 1m43s
CD Pipeline / build-and-deploy (push) Failing after 8m19s
CD Pipeline / post-deploy-checks (push) Has been skipped

This commit is contained in:
Your Name
2026-06-18 20:01:44 +08:00
parent a8717d52c5
commit 77fe2a85fd
4 changed files with 372 additions and 30 deletions

View File

@@ -3,6 +3,29 @@ from fastapi.testclient import TestClient
from src.main import app
def test_daily_report_preview_exposes_source_health_no_send_preview():
client = TestClient(app)
response = client.get("/api/v1/stats/daily/preview")
assert response.status_code == 200
data = response.json()
assert "report_date" in data
assert "alert_total" in data
assert "km_new_entries" in data
assert "playbook_count" in data
assert "source_ok_count" in data
assert "source_total_count" in data
assert "source_confidence_percent" in data
assert "source_gap_ids" in data
assert "formatted_preview" in data
preview = data["formatted_preview"]
assert "AWOOOI 日度巡檢報告" in preview
assert "報表資料源 / 沉澱" in preview
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
assert "不自動改排程" in preview
def test_weekly_report_preview_exposes_source_health_no_send_preview():
client = TestClient(app)
response = client.get("/api/v1/stats/weekly/preview")
@@ -25,3 +48,25 @@ def test_weekly_report_preview_exposes_source_health_no_send_preview():
assert "報表資料源 / 沉澱" in preview
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
assert "不自動改排程" in preview
def test_monthly_report_preview_exposes_source_health_no_send_preview():
client = TestClient(app)
response = client.get("/api/v1/stats/monthly/preview")
assert response.status_code == 200
data = response.json()
assert "report_month" in data
assert "source_ok_count" in data
assert "source_total_count" in data
assert "source_confidence_percent" in data
assert "source_gap_ids" in data
assert "no_send_preview_count" in data
assert "formatted_preview" in data
preview = data["formatted_preview"]
assert "月報 no-send preview" in preview
assert "報表資料源 / 沉澱" in preview
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
assert "實發: 0" in preview
assert "不代表已授權發送或自動修復" in preview