feat(canvas): AI 拆图 - 完善规划、图层编辑与素材复用
This commit is contained in:
1 parent
09f9b8e902
commit
5707102fbc
56 files changed
+3541
-162
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLayerPlanningDeliversOwnedPixelsToVisionModel(t *testing.T) {
|
||||
s, _, pixels := cloudAgentVisionFixture(t)
|
||||
input := canvasGenerationInput{
|
||||
Mode: "text", Prompt: "规划图层", Metadata: map[string]interface{}{"edit": "layer-planning"},
|
||||
ReferenceImages: []providerMedia{{StorageKey: "resource:ref-one", URL: "https://invalid.example/stale.png", DataURL: "data:image/png;base64,c3RhbGU="}},
|
||||
}
|
||||
if err := s.hydrateGenerationMedia("user", &input, providerMediaHydrationPolicy{preferURL: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := "data:image/png;base64," + base64.StdEncoding.EncodeToString(pixels)
|
||||
if input.ReferenceImages[0].DataURL != want || input.ReferenceImages[0].URL != "" {
|
||||
t.Fatal("planning did not use the authorized resource's actual pixels")
|
||||
}
|
||||
content, err := textChatContent(input)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
raw, err := json.Marshal(content)
|
||||
if err != nil || !strings.Contains(string(raw), want) || strings.Contains(string(raw), "invalid.example") {
|
||||
t.Fatalf("vision payload lost stored pixels: %v", err)
|
||||
}
|
||||
foreign := canvasGenerationInput{Mode: "text", Metadata: input.Metadata, ReferenceImages: []providerMedia{{StorageKey: "resource:ref-one"}}}
|
||||
if err := s.hydrateGenerationMedia("other-user", &foreign, providerMediaHydrationPolicy{preferURL: true}); err == nil {
|
||||
t.Fatal("planning allowed another user's resource")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user