from __future__ import annotations

from fastapi.testclient import TestClient

from src.main import app


def test_final_release_candidate_readback_endpoint() -> None:
    client = TestClient(app)

    response = client.get("/api/v1/agents/agent-result-capture-final-release-candidate-readback")

    assert response.status_code == 200
    payload = response.json()
    assert payload["schema_version"] == "ai_agent_result_capture_final_release_candidate_readback_v1"
    assert payload["program_status"]["current_task_id"] == "P2-133"
    assert payload["program_status"]["next_task_id"] == "P2-134"
    assert payload["program_status"]["overall_completion_percent"] == 100
    assert payload["program_status"]["runtime_authority"] == "result_capture_final_release_candidate_readback_only_no_live_write"
    assert payload["rollups"]["final_release_candidate_readback_count"] == 5
    assert payload["rollups"]["rollback_candidate_readback_count"] == 5
    assert payload["rollups"]["candidate_acceptance_hold_count"] == 5
    assert payload["rollups"]["live_apply_candidate_hold_count"] == 5
    assert payload["rollups"]["blocked_final_candidate_transition_count"] == 6
    assert payload["rollups"]["operator_action_count"] == 5
    assert payload["rollups"]["gateway_queue_write_count"] == 0
    assert payload["rollups"]["telegram_send_count"] == 0
    assert payload["rollups"]["production_write_count"] == 0
