d1f39ae57e
- 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.
41 lines
1.0 KiB
Go
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
|
|
}
|