from fastapi.testclient import TestClient from app.main import app from app.schemas.graph import HTML5VisualPayload import app.routers.sandbox as sandbox_router def test_repair_endpoint_accepts_blank_render_error(monkeypatch): class FakeTutor: def repair_visual(self, original_html: str, error_message: str) -> HTML5VisualPayload: assert error_message.startswith("BlankRender:") return HTML5VisualPayload(html_code="fixed", animation_type="3d") monkeypatch.setattr(sandbox_router, "_get_tutor", lambda: FakeTutor()) response = TestClient(app).post( "/sandbox/repair", json={ "original_html": "original", "error_message": "BlankRender: no renderable objects were added within 900ms", "node_id": "n1", "animation_type": "3d", }, ) assert response.status_code == 200 body = response.json() assert body["visual"]["html_code"] == "fixed" assert body["visual"]["animation_type"] == "3d"