Add UI delivery presenters and event DTOs
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user