feat: 工作流画布支持草稿试运行(target=draft 执行当前草稿图)
This commit is contained in:
1 parent
3384f2e51c
commit
222595d6c4
7 files changed
+198
-32
No files matched your search
@@ -705,3 +705,44 @@ async def test_embed_ticket_round_trip(harness: Harness, monkeypatch: pytest.Mon
|
||||
|
||||
replay = await harness.client.post("/api/workflows/embed/verify", json={"ticket": ticket})
|
||||
assert replay.status_code == 401
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draft_run_executes_current_draft_without_publishing(harness: Harness) -> None:
|
||||
"""target=draft runs the CURRENT draft graph (version id "draft"), no publish needed."""
|
||||
store = harness.app.state.workflow_store
|
||||
definition = await store.create_definition({"name": "draft-run", "owner_id": "user-a", "draft_graph": REPORT_GRAPH})
|
||||
|
||||
response = await harness.client.post(
|
||||
f"/api/workflows/{definition['id']}/runs",
|
||||
json={"inputs": {"topic": "储能"}, "target": "draft", "idempotencyKey": "draft-1"},
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
run = response.json()
|
||||
assert run["versionId"] == "draft"
|
||||
assert run["status"] in ("queued", "running")
|
||||
|
||||
await harness.drive()
|
||||
|
||||
events = await harness.events(run["runId"])
|
||||
types = [event["event"] for event in events]
|
||||
assert "run.started" in types
|
||||
assert "run.completed" in types
|
||||
final = await harness.client.get(f"/api/workflows/runs/{run['runId']}")
|
||||
assert final.status_code == 200
|
||||
assert final.json()["status"] == "completed"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draft_run_without_graph_is_rejected(harness: Harness) -> None:
|
||||
store = harness.app.state.workflow_store
|
||||
definition = await store.create_definition(
|
||||
{"name": "empty-draft", "owner_id": "user-a", "draft_graph": {"nodes": [], "edges": []}}
|
||||
)
|
||||
|
||||
response = await harness.client.post(
|
||||
f"/api/workflows/{definition['id']}/runs",
|
||||
json={"inputs": {}, "target": "draft"},
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert response.json()["detail"]["code"] == "WORKFLOW_DRAFT_EMPTY"
|
||||
Reference in new issue
Block a user