from __future__ import annotations

import os

from fastapi.testclient import TestClient

os.environ.setdefault("DATABASE_URL", "postgresql+asyncpg://test:test@localhost/test")

from src.main import app


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

    response = client.get("/api/v1/agents/agent-12-agent-war-room")

    assert response.status_code == 200
    payload = response.json()
    assert payload["schema_version"] == "ai_agent_12_agent_war_room_v1"
    assert payload["program_status"]["current_task_id"] == "P2-142"
    assert payload["program_status"]["next_task_id"] == "P2-143"
    assert payload["program_status"]["overall_completion_percent"] == 72
    assert payload["program_status"]["runtime_authority"] == "12_agent_war_room_read_only_no_live_write"
    assert payload["rollups"]["agent_role_count"] == 12
    assert payload["rollups"]["read_only_review_completed_count"] == 12
    assert payload["rollups"]["subagent_batch_limit"] == 6
    assert payload["rollups"]["subagent_batch_count"] == 2
    assert payload["rollups"]["total_work_units"] == 82
    assert payload["rollups"]["approval_required_total"] == 61
    assert payload["rollups"]["blocker_total"] == 54
    assert payload["rollups"]["live_write_count"] == 0
    assert payload["rollups"]["telegram_send_count"] == 0
    assert payload["rollups"]["bot_api_call_count"] == 0
    assert payload["rollups"]["production_write_count"] == 0
    assert payload["telegram_contract"]["direct_send_allowed"] is False
    assert payload["display_redaction_contract"]["conversation_transcript_display_allowed"] is False
