Create/list/resolve endpoints for tracking AI-applied changes to flows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Tests for AI suggestion endpoints."""
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_create_and_list_suggestions(client, auth_headers, test_tree):
|
|
"""Can create and list suggestions for a tree."""
|
|
tree_id = test_tree["id"]
|
|
|
|
# Create suggestion
|
|
resp = await client.post(
|
|
"/api/v1/ai/suggestions",
|
|
json={
|
|
"tree_id": tree_id,
|
|
"action_type": "generate_branch",
|
|
"target_node_id": "some-node",
|
|
"changes_json": {"before": {}, "after": {"id": "new-node"}},
|
|
},
|
|
headers=auth_headers,
|
|
)
|
|
assert resp.status_code == 201
|
|
suggestion_id = resp.json()["id"]
|
|
assert resp.json()["status"] == "pending"
|
|
|
|
# List suggestions
|
|
resp = await client.get(
|
|
f"/api/v1/ai/suggestions/tree/{tree_id}",
|
|
headers=auth_headers,
|
|
)
|
|
assert resp.status_code == 200
|
|
assert len(resp.json()) >= 1
|
|
|
|
# Resolve suggestion
|
|
resp = await client.patch(
|
|
f"/api/v1/ai/suggestions/{suggestion_id}",
|
|
json={"status": "accepted"},
|
|
headers=auth_headers,
|
|
)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["status"] == "accepted"
|
|
assert resp.json()["resolved_at"] is not None
|