from fastapi.testclient import TestClient

from src.main import app


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

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_owner_approved_result_capture_dry_run_v1"
    assert data["program_status"]["current_task_id"] == "P2-106"
    assert data["program_status"]["next_task_id"] == "P2-107"
    assert data["program_status"]["overall_completion_percent"] == 100
    assert data["prior_contract_readback"]["approved_without_execution_meta_24h"] == 63
    assert data["dry_run_truth"]["owner_approval_required"] is True
    assert data["dry_run_truth"]["owner_approval_received_count"] == 0
    assert data["dry_run_truth"]["dry_run_preview_generated_count"] == 0
    assert data["dry_run_truth"]["runtime_result_capture_write_enabled"] is False
    assert data["dry_run_truth"]["runtime_score_write_enabled"] is False
    assert data["dry_run_truth"]["telegram_send_enabled"] is False
    assert data["rollups"]["result_capture_template_count"] == 5
    assert data["rollups"]["score_fixture_count"] == 5
    assert data["rollups"]["dry_run_gate_count"] == 7
    assert data["rollups"]["operator_action_count"] == 5
    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
