Add confirmation cards and scenario smoke validation
This commit is contained in:
@@ -57,6 +57,33 @@ def test_chat_response_contains_ui_cards() -> None:
|
||||
assert any(card["type"] == "progress_card" for card in payload["cards"])
|
||||
|
||||
|
||||
def test_task_creation_with_policy_action_returns_confirmation_card() -> None:
|
||||
client = TestClient(app)
|
||||
|
||||
response = client.post(
|
||||
"/tasks",
|
||||
json={
|
||||
"project_id": "default",
|
||||
"goal": "Need approval",
|
||||
"inputs": {
|
||||
"policy_action": {
|
||||
"resource": "filesystem",
|
||||
"risk_level": "write",
|
||||
"action_name": "file.write",
|
||||
"preview_available": True,
|
||||
"metadata": {"path": "D:/Projects/test.txt"},
|
||||
}
|
||||
},
|
||||
"execution_mode": "agent_graph",
|
||||
},
|
||||
)
|
||||
|
||||
payload = response.json()
|
||||
|
||||
assert response.status_code == 200
|
||||
assert any(card["type"] == "confirmation_card" for card in payload["cards"])
|
||||
|
||||
|
||||
def test_cancel_endpoint_marks_task_cancelled() -> None:
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -166,6 +193,65 @@ def test_worker_websocket_heartbeat_and_poll() -> None:
|
||||
assert len(commands["commands"]) == 1
|
||||
|
||||
|
||||
def test_task_get_returns_artifact_card_from_worker_result() -> None:
|
||||
client = TestClient(app)
|
||||
created = client.post(
|
||||
"/tasks",
|
||||
json={
|
||||
"project_id": "default",
|
||||
"goal": "Artifact check",
|
||||
"inputs": {},
|
||||
"execution_mode": "agent_graph",
|
||||
},
|
||||
).json()
|
||||
registration = client.post(
|
||||
"/workers/register",
|
||||
json={
|
||||
"worker_id": "worker_artifact_pc",
|
||||
"name": "Artifact PC",
|
||||
"capabilities": ["file.read"],
|
||||
"version": "0.1.0",
|
||||
"machine": "DESKTOP-3",
|
||||
"os": "windows",
|
||||
},
|
||||
).json()
|
||||
client.post(
|
||||
f"/workers/{registration['session_id']}/commands",
|
||||
json={
|
||||
"task_id": created["task_id"],
|
||||
"node_id": "node_artifact",
|
||||
"command_name": "file.read",
|
||||
"args": {"path": "D:/artifact.txt"},
|
||||
},
|
||||
)
|
||||
with client.websocket_connect(f"/workers/ws/{registration['session_id']}") as websocket:
|
||||
websocket.send_json({"event_type": "poll"})
|
||||
commands = websocket.receive_json()["commands"]
|
||||
websocket.send_json(
|
||||
{
|
||||
"event_type": "result",
|
||||
"command_id": commands[0]["command_id"],
|
||||
"task_id": created["task_id"],
|
||||
"tool": "file.read",
|
||||
"status": "success",
|
||||
"started_at": "2026-07-03T10:00:00+00:00",
|
||||
"finished_at": "2026-07-03T10:00:01+00:00",
|
||||
"duration_ms": 1000,
|
||||
"stdout": "",
|
||||
"stderr": "",
|
||||
"result": {"content": "ok"},
|
||||
"artifacts": [{"type": "file", "path": "D:/artifact.txt"}],
|
||||
"error": None,
|
||||
}
|
||||
)
|
||||
websocket.receive_json()
|
||||
|
||||
response = client.get(f"/tasks/{created['task_id']}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert any(card["type"] == "artifact_card" for card in response.json()["cards"])
|
||||
|
||||
|
||||
def test_task_events_stream_returns_normalized_event_payload() -> None:
|
||||
client = TestClient(app)
|
||||
created = client.post(
|
||||
|
||||
Reference in New Issue
Block a user