Files
ai-agent/internal/builders/ai_workflow_builder_test.go
T
mlogclub d1f39ae57e feat: Enhance AI Workflow with Variable Contracts and Input Mapping
- Added ConfigSchema, InputSchema, OutputSchema, and DefaultInputs to AIWorkflowNodeSpecResponse.
- Implemented BuildAIWorkflowNodeSpecs to include variable contracts for start and send_reply nodes.
- Introduced applyAutoInputMappings to automatically map inputs based on node connections.
- Enhanced validation to check for required input mappings in workflows.
- Updated workflow editor to support variable selection for node inputs.
- Translated node names and labels to Chinese for better localization.
- Added tests for variable mapping and validation logic.
2026-06-22 18:33:39 +08:00

41 lines
1.0 KiB
Go

package builders
import (
"testing"
workflowregistry "agent-desk/internal/ai/workflow/registry"
)
func TestBuildAIWorkflowNodeSpecsIncludesVariableContracts(t *testing.T) {
specs := BuildAIWorkflowNodeSpecs(workflowregistry.DefaultRegistry().List())
var startFound bool
var sendReplyFound bool
for _, spec := range specs {
switch spec.Type {
case workflowregistry.NodeTypeStart:
startFound = true
if !hasResponseVariable(spec.OutputSchema, "userMessage") {
t.Fatalf("expected start output userMessage, got %#v", spec.OutputSchema)
}
case workflowregistry.NodeTypeSendReply:
sendReplyFound = true
if !hasResponseVariable(spec.InputSchema, "replyText") {
t.Fatalf("expected send_reply input replyText, got %#v", spec.InputSchema)
}
}
}
if !startFound || !sendReplyFound {
t.Fatalf("expected start and send_reply specs in response")
}
}
func hasResponseVariable(items []workflowregistry.VariableSpec, name string) bool {
for _, item := range items {
if item.Name == name {
return true
}
}
return false
}