44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
|
|
package application
|
||
|
|
|
||
|
|
import (
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"img_infinite_canvas/internal/domain/design"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestCADContextIsModelInputButNotVisibleUserCopy(t *testing.T) {
|
||
|
|
messages := []design.AgentChatMessage{
|
||
|
|
{
|
||
|
|
Role: "user",
|
||
|
|
Contents: []design.AgentContent{
|
||
|
|
{Type: "text", Text: "Focus on the living room", TextSource: "input"},
|
||
|
|
{Type: "image", ImageURL: "/canvas-assets/floor-plan.webp", ImageName: "floor-plan crop.webp"},
|
||
|
|
{Type: "text", Text: "CAD semantic context: layer ROOMS, block ROOM_A", TextSource: "cad-context"},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
modelPrompt := promptFromAgentMessages(messages)
|
||
|
|
visiblePrompt := visiblePromptFromAgentMessages(messages)
|
||
|
|
if !strings.Contains(modelPrompt, "layer ROOMS") {
|
||
|
|
t.Fatalf("expected model prompt to retain CAD semantics, got %q", modelPrompt)
|
||
|
|
}
|
||
|
|
if strings.Contains(visiblePrompt, "layer ROOMS") {
|
||
|
|
t.Fatalf("expected visible user copy to hide CAD semantics, got %q", visiblePrompt)
|
||
|
|
}
|
||
|
|
if !strings.Contains(visiblePrompt, "Focus on the living room") || !strings.Contains(visiblePrompt, "floor-plan crop.webp") {
|
||
|
|
t.Fatalf("expected visible prompt and reference capsule directive, got %q", visiblePrompt)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestCADContextAloneDoesNotSatisfyPromptValidation(t *testing.T) {
|
||
|
|
messages := []design.AgentChatMessage{{
|
||
|
|
Role: "user",
|
||
|
|
Contents: []design.AgentContent{{Type: "text", Text: "CAD semantic context", TextSource: "cad-context"}},
|
||
|
|
}}
|
||
|
|
if hasUserPromptTextInAgentMessages(messages) {
|
||
|
|
t.Fatal("expected hidden CAD context not to count as user prompt text")
|
||
|
|
}
|
||
|
|
}
|