from __future__ import annotations

import json

from fastapi import FastAPI
from fastapi.testclient import TestClient

from src.api.v1.agents import router


def test_ai_technology_radar_readback_endpoint_returns_committed_snapshot():
    app = FastAPI()
    app.include_router(router, prefix="/api/v1")
    client = TestClient(app)

    response = client.get("/api/v1/agents/ai-technology-radar-readback")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_technology_radar_readback_v1"
    assert data["summary"]["overall_completion_percent"] == 42.2
    assert data["summary"]["ai_technology_radar_completion_percent"] == 100.0
    assert data["summary"]["technology_count"] == 21
    assert data["summary"]["source_count"] == 52
    assert data["summary"]["changed_technologies"] == 5
    assert data["summary"]["review_queue_count"] == 5
    assert data["summary"]["source_failures"] == 0
    assert len(data["primary_source_alignment"]) == 6
    assert data["policy"]["read_only"] is True
    assert data["policy"]["sdk_installation_approved"] is False
    assert data["policy"]["telegram_send_approved"] is False
    assert data["policy"]["openclaw_replacement_approved"] is False

    serialized = json.dumps(data, ensure_ascii=False)
    assert "/Users/" not in serialized
    assert ".claude/projects" not in serialized
    assert ".codex" not in serialized
    assert "192.168." not in serialized
