fix: formular trigger
This commit is contained in:
parent
64591fda3f
commit
f115bd9aa2
2 changed files with 39 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ class TriggerExecutor:
|
||||||
context: Dict[str, Any],
|
context: Dict[str, Any],
|
||||||
) -> Any:
|
) -> Any:
|
||||||
node_id = node.get("id", "")
|
node_id = node.get("id", "")
|
||||||
|
node_type = str(node.get("type") or "")
|
||||||
base = context.get("runEnvelope")
|
base = context.get("runEnvelope")
|
||||||
if not isinstance(base, dict):
|
if not isinstance(base, dict):
|
||||||
out = normalize_run_envelope(None, user_id=context.get("userId"))
|
out = normalize_run_envelope(None, user_id=context.get("userId"))
|
||||||
|
|
@ -31,4 +32,11 @@ class TriggerExecutor:
|
||||||
node_id,
|
node_id,
|
||||||
(out.get("trigger") or {}).get("type"),
|
(out.get("trigger") or {}).get("type"),
|
||||||
)
|
)
|
||||||
|
# Form start: port schema is FormPayload — downstream refs use payload.<field>.
|
||||||
|
# Do not emit the full run envelope on this port.
|
||||||
|
if node_type == "trigger.form":
|
||||||
|
payload = out.get("payload")
|
||||||
|
if not isinstance(payload, dict):
|
||||||
|
payload = {}
|
||||||
|
return {"payload": payload, "_success": True}
|
||||||
return out
|
return out
|
||||||
|
|
|
||||||
31
tests/unit/workflows/test_trigger_executor.py
Normal file
31
tests/unit/workflows/test_trigger_executor.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Copyright (c) 2025 Patrick Motsch
|
||||||
|
"""TriggerExecutor: form start output must match FormPayload (payload.* refs)."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from modules.workflows.automation2.executors.triggerExecutor import TriggerExecutor
|
||||||
|
from modules.workflows.automation2.runEnvelope import default_run_envelope
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_trigger_form_returns_payload_only():
|
||||||
|
ex = TriggerExecutor()
|
||||||
|
node = {
|
||||||
|
"id": "f1",
|
||||||
|
"type": "trigger.form",
|
||||||
|
"parameters": {"formFields": [{"name": "q", "type": "str", "label": "Q"}]},
|
||||||
|
}
|
||||||
|
env = default_run_envelope("form", entry_point_id="f1", payload={"q": "hello"})
|
||||||
|
out = await ex.execute(node, {"runEnvelope": env, "userId": "u1"})
|
||||||
|
assert out == {"payload": {"q": "hello"}, "_success": True}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_trigger_manual_still_returns_full_envelope():
|
||||||
|
ex = TriggerExecutor()
|
||||||
|
node = {"id": "m1", "type": "trigger.manual", "parameters": {}}
|
||||||
|
env = default_run_envelope("manual", payload={"x": 1})
|
||||||
|
out = await ex.execute(node, {"runEnvelope": env, "userId": "u1"})
|
||||||
|
assert isinstance(out, dict)
|
||||||
|
assert out.get("trigger", {}).get("type") == "manual"
|
||||||
|
assert out.get("payload") == {"x": 1}
|
||||||
Loading…
Reference in a new issue