from fastapi.testclient import TestClient

from src.main import app


def test_get_ai_agent_owner_approved_result_capture_readback_api():
    client = TestClient(app)
    response = client.get("/api/v1/agents/agent-owner-approved-result-capture-readback")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_owner_approved_result_capture_readback_v1"
    assert data["program_status"]["current_task_id"] == "P2-107"
    assert data["program_status"]["next_task_id"] == "P2-108"
    assert data["program_status"]["overall_completion_percent"] == 100
    assert data["prior_dry_run_readback"]["source_schema_version"] == "ai_agent_owner_approved_result_capture_dry_run_v1"
    assert data["prior_dry_run_readback"]["result_capture_template_count"] == 5
    assert data["prior_dry_run_readback"]["dry_run_gate_count"] == 7
    assert data["readback_truth"]["p2_106_dry_run_loaded"] is True
    assert data["readback_truth"]["fixture_readback_allowed"] is True
    assert data["readback_truth"]["canonical_runtime_readback_enabled"] is False
    assert data["readback_truth"]["runtime_result_capture_write_enabled"] is False
    assert data["readback_truth"]["reviewer_queue_write_enabled"] is False
    assert data["readback_truth"]["telegram_send_enabled"] is False
    assert data["readback_truth"]["readback_digest_generated_count"] == 0
    assert data["readback_truth"]["promotion_approved_count"] == 0
    assert data["rollups"]["readback_digest_count"] == 5
    assert data["rollups"]["promotion_review_count"] == 5
    assert data["rollups"]["failure_lane_count"] == 4
    assert data["rollups"]["reviewer_queue_preview_count"] == 4
    assert data["rollups"]["operator_action_count"] == 5
    assert data["rollups"]["reviewer_queue_write_count"] == 0
    assert data["rollups"]["result_capture_write_count"] == 0
    assert data["rollups"]["score_write_count"] == 0
    assert data["rollups"]["learning_write_count"] == 0
    assert data["rollups"]["playbook_trust_write_count"] == 0
    assert data["rollups"]["telegram_send_count"] == 0
