Add UI delivery presenters and event DTOs

This commit is contained in:
2026-07-03 21:32:59 +03:00
parent 8423d8e8ad
commit eb320fc246
7 changed files with 249 additions and 16 deletions
+46
View File
@@ -30,6 +30,31 @@ def test_post_tasks_creates_planned_task() -> None:
assert response.status_code == 200
assert payload["status"] == "running"
assert payload["progress"]["total"] == 2
assert any(card["type"] == "plan_card" for card in payload["cards"])
assert any(card["type"] == "progress_card" for card in payload["cards"])
def test_chat_response_contains_ui_cards() -> None:
client = TestClient(app)
response = client.post(
"/chat",
json={
"project_id": "default",
"conversation_id": "conv_demo",
"message": "Build plan",
"attachments": [],
"mode": "auto",
"preferences": {"show_plan": True},
},
)
payload = response.json()
assert response.status_code == 200
assert payload["response_type"] == "task_started"
assert any(card["type"] == "plan_card" for card in payload["cards"])
assert any(card["type"] == "progress_card" for card in payload["cards"])
def test_cancel_endpoint_marks_task_cancelled() -> None:
@@ -48,6 +73,7 @@ def test_cancel_endpoint_marks_task_cancelled() -> None:
assert response.status_code == 200
assert response.json()["status"] == "cancelled"
assert any(card["type"] == "error_card" for card in response.json()["cards"])
def test_worker_registration_is_exposed_via_list_endpoint() -> None:
@@ -138,3 +164,23 @@ def test_worker_websocket_heartbeat_and_poll() -> None:
assert heartbeat_ack["status"] in {"online", "busy"}
assert commands["type"] == "commands"
assert len(commands["commands"]) == 1
def test_task_events_stream_returns_normalized_event_payload() -> None:
client = TestClient(app)
created = client.post(
"/tasks",
json={
"project_id": "default",
"goal": "Event check",
"inputs": {},
"execution_mode": "agent_graph",
},
).json()
with client.stream("GET", f"/tasks/{created['task_id']}/events") as response:
body = response.read().decode()
assert response.status_code == 200
assert "event_type" in body
assert "progress_card_ref" in body or "task_planned" in body