feat: add deterministic message interaction stages
This commit is contained in:
@@ -55,6 +55,20 @@ def valid_graph():
|
||||
|
||||
|
||||
class WorkflowGraphTests(unittest.TestCase):
|
||||
def test_workflow_removes_assistant_and_start_greetings(self):
|
||||
body = AssistantUpsert(
|
||||
name="无开场白工作流",
|
||||
type="workflow",
|
||||
greeting="旧助手级开场白",
|
||||
graph=valid_graph(),
|
||||
)
|
||||
body.graph["nodes"][0]["data"]["greeting"] = "旧 Start 开场白"
|
||||
|
||||
normalized = normalize_graph(body.graph)
|
||||
|
||||
self.assertEqual(body.greeting, "")
|
||||
self.assertNotIn("greeting", normalized["nodes"][0]["data"])
|
||||
|
||||
def test_revision_pins_the_normalized_workflow_snapshot(self):
|
||||
first = WorkflowEngine(valid_graph())
|
||||
same_graph = deepcopy(valid_graph())
|
||||
@@ -147,6 +161,7 @@ class WorkflowGraphTests(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(actions["legacy_none"]["resultAssignments"], {})
|
||||
self.assertEqual(actions["legacy_none"]["userInputPolicy"], "queue")
|
||||
self.assertNotIn("speech", actions["legacy_none"])
|
||||
|
||||
def test_action_advanced_settings_are_validated(self):
|
||||
graph = valid_graph()
|
||||
@@ -167,6 +182,46 @@ class WorkflowGraphTests(unittest.TestCase):
|
||||
self.assertTrue(any("结果变量映射必须是对象" in error for error in errors))
|
||||
self.assertTrue(any("用户输入策略无效" in error for error in errors))
|
||||
|
||||
def test_message_defaults_and_validation(self):
|
||||
graph = valid_graph()
|
||||
graph["nodes"].append(
|
||||
{
|
||||
"id": "message",
|
||||
"type": "message",
|
||||
"data": {"speech": "请确认重要信息"},
|
||||
}
|
||||
)
|
||||
normalized = normalize_graph(graph)
|
||||
message = next(
|
||||
node for node in normalized["nodes"] if node["type"] == "message"
|
||||
)
|
||||
self.assertFalse(message["data"]["showMessage"])
|
||||
self.assertFalse(message["data"]["requireConfirmation"])
|
||||
self.assertEqual(message["data"]["confirmLabel"], "确认")
|
||||
|
||||
message["data"].update(
|
||||
{
|
||||
"speech": "",
|
||||
"showMessage": True,
|
||||
"title": "重要提示",
|
||||
"message": "",
|
||||
"confirmLabel": "确认",
|
||||
"requireConfirmation": True,
|
||||
}
|
||||
)
|
||||
errors = validate_graph(normalized)
|
||||
self.assertTrue(any("弹窗消息必须为" in error for error in errors))
|
||||
|
||||
message["data"].update(
|
||||
{
|
||||
"speech": "请确认",
|
||||
"showMessage": False,
|
||||
"requireConfirmation": True,
|
||||
}
|
||||
)
|
||||
errors = validate_graph(normalized)
|
||||
self.assertTrue(any("等待确认时必须显示弹窗" in error for error in errors))
|
||||
|
||||
def test_voice_resource_creates_isolated_runtime_config(self):
|
||||
base = AssistantConfig(type="workflow", asr="default", voice="default")
|
||||
asr = RuntimeModelResource(
|
||||
|
||||
Reference in New Issue
Block a user