fix(metrics): read latest sitewide visual qa artifact
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
This commit is contained in:
@@ -335,6 +335,59 @@ def test_scheduled_automation_health_summary_can_use_current_smoke_without_recor
|
||||
assert not history_path.exists()
|
||||
|
||||
|
||||
def test_scheduled_automation_health_summary_falls_back_to_visual_qa_artifact(tmp_path, monkeypatch):
|
||||
from datetime import datetime
|
||||
from services import ai_automation_smoke_service as smoke
|
||||
from services import ai_surface_html_readback_service as surface_service
|
||||
|
||||
history_path = tmp_path / "smoke_history.jsonl"
|
||||
history_path.write_text(
|
||||
json.dumps({
|
||||
"generated_at": datetime.now().isoformat(timespec="seconds"),
|
||||
"status": "ok",
|
||||
"summary": {"ok": 9, "warning": 0, "critical": 0, "total": 9},
|
||||
"checks": [],
|
||||
}, ensure_ascii=False) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setattr(smoke, "_HISTORY_PATH", str(history_path))
|
||||
monkeypatch.setattr(
|
||||
surface_service,
|
||||
"build_sitewide_visual_qa_readback",
|
||||
lambda **_kwargs: {
|
||||
"policy": "read_only_sitewide_visual_qa_readback_v1",
|
||||
"status": "ok",
|
||||
"artifact_path": "data/ai_automation/sitewide_visual_qa_latest.json",
|
||||
"artifact_exists": True,
|
||||
"artifact_generated_at": "2026-07-03T07:40:00",
|
||||
"next_machine_action": "keep_sitewide_visual_qa_monitoring",
|
||||
"summary": {
|
||||
"result_count": 147,
|
||||
"route_count": 49,
|
||||
"viewport_count": 3,
|
||||
"pass_count": 147,
|
||||
"failed_count": 0,
|
||||
"overflow_issue_count": 0,
|
||||
"visual_offender_count": 0,
|
||||
"stale": False,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
summary = smoke.build_scheduled_automation_health_summary(
|
||||
history_limit=5,
|
||||
freshness_max_age_hours=9999,
|
||||
)
|
||||
|
||||
visual_family = next(
|
||||
item for item in summary["families"]
|
||||
if item["key"] == "sitewide_visual_qa"
|
||||
)
|
||||
assert visual_family["status"] == "ok"
|
||||
assert visual_family["details"]["route_count"] == 49
|
||||
assert visual_family["details"]["failed_count"] == 0
|
||||
|
||||
|
||||
def test_scheduled_automation_health_summary_route_returns_compact_payload(tmp_path, monkeypatch):
|
||||
from datetime import datetime
|
||||
from flask import Flask
|
||||
|
||||
Reference in New Issue
Block a user