from fastapi.testclient import TestClient

from src.main import app


def test_get_ai_agent_report_truth_actionability_review_api():
    client = TestClient(app)
    response = client.get("/api/v1/agents/agent-report-truth-actionability-review")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_report_truth_actionability_review_v1"
    assert data["program_status"]["current_task_id"] == "P2-403J"
    assert data["program_status"]["next_task_id"] == "P2-403K"
    assert data["report_truth"]["all_zero_weekly_report_is_actionable_anomaly"] is True
    assert data["report_truth"]["freshness_gate_implemented"] is False
    assert data["report_truth"]["telegram_report_send_allowed"] is False
    assert data["rollups"]["zero_signal_finding_count"] == 5
    assert data["rollups"]["critical_finding_count"] == 1
    assert data["rollups"]["high_finding_count"] == 3
    assert data["rollups"]["cadence_contract_count"] == 3
    assert data["rollups"]["missing_cadence_contract_count"] == 1
    assert data["rollups"]["actionability_lane_count"] == 4
    assert data["telegram_routing_consolidation"]["canonical_room_name"] == "AwoooI SRE 戰情室"
    assert data["telegram_routing_consolidation"]["canonical_room_env"] == "SRE_GROUP_CHAT_ID"
    assert data["telegram_routing_consolidation"]["other_bot_or_group_alerts_allowed"] is False
    assert data["telegram_routing_consolidation"]["direct_telegram_api_send_allowed"] is False
    assert data["rollups"]["telegram_route_finding_count"] == 4
    assert data["rollups"]["legacy_or_direct_route_count"] == 4
    assert data["rollups"]["operator_action_count"] == 5
