feat: add assertions for condition branch and port edge order in workflow tests
This commit is contained in:
@@ -92,6 +92,24 @@ func TestAIAgentServiceCreatesDefaultWorkflow(t *testing.T) {
|
||||
assertConditionBranchesHavePortEdges(t, stored, "policy_route_1")
|
||||
assertConditionBranchesHavePortEdges(t, stored, "ticket_confirm_route_1")
|
||||
assertConditionBranchesHavePortEdges(t, stored, "answerability_route_1")
|
||||
assertConditionBranchOrder(t, stored, "policy_route_1", []string{
|
||||
"handoff",
|
||||
"direct",
|
||||
"clarify",
|
||||
"end_conversation",
|
||||
"ticket",
|
||||
"knowledge",
|
||||
"default",
|
||||
})
|
||||
assertConditionPortEdgeOrder(t, stored, "policy_route_1", []string{
|
||||
"handoff",
|
||||
"direct",
|
||||
"clarify",
|
||||
"end_conversation",
|
||||
"ticket",
|
||||
"knowledge",
|
||||
"default",
|
||||
})
|
||||
}
|
||||
|
||||
func TestAIWorkflowServiceDefaultAgentWorkflowDefinitionIsValid(t *testing.T) {
|
||||
@@ -317,6 +335,37 @@ func assertConditionBranchesHavePortEdges(t *testing.T, def dsl.Definition, node
|
||||
}
|
||||
}
|
||||
|
||||
func assertConditionBranchOrder(t *testing.T, def dsl.Definition, nodeID string, want []string) {
|
||||
t.Helper()
|
||||
branches := conditionBranches(t, def, nodeID)
|
||||
if len(branches) != len(want) {
|
||||
t.Fatalf("expected %s branch order %v, got %#v", nodeID, want, branches)
|
||||
}
|
||||
for index, branch := range branches {
|
||||
if branch.ID != want[index] {
|
||||
t.Fatalf("expected %s branch order %v, got branch %d = %s", nodeID, want, index, branch.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertConditionPortEdgeOrder(t *testing.T, def dsl.Definition, nodeID string, want []string) {
|
||||
t.Helper()
|
||||
got := make([]string, 0, len(want))
|
||||
for _, edge := range def.Edges {
|
||||
if edge.SourceNodeID == nodeID {
|
||||
got = append(got, edge.SourcePortID)
|
||||
}
|
||||
}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("expected %s port edge order %v, got %v", nodeID, want, got)
|
||||
}
|
||||
for index, sourcePortID := range got {
|
||||
if sourcePortID != want[index] {
|
||||
t.Fatalf("expected %s port edge order %v, got edge %d = %s", nodeID, want, index, sourcePortID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func workflowPortEdgeExists(def dsl.Definition, sourceID string, targetID string, sourcePortID string) bool {
|
||||
for _, edge := range def.Edges {
|
||||
if edge.SourceNodeID == sourceID && edge.TargetNodeID == targetID && edge.SourcePortID == sourcePortID {
|
||||
|
||||
Reference in New Issue
Block a user