44406b72db
Moteva-style AI design workbench replica. Home prompt creates a project; the project page provides an infinite canvas with node drag, zoom/pan, a design chat panel, history replay, image asset upload, and project save/regenerate. - Backend: go-zero, DDD layering, sqlc/pgx, optional PostgreSQL; memory or Redis cache; asynq job queue; MinIO/S3/R2/OSS object storage; sky-valley/pi agent runtime adapter. - Frontend: Next.js App Router + Vite artifact build, TypeScript, i18n, shadcn/ui components, auth (OTP/Turnstile/Google/WeChat). - Deploy: Docker Compose and k3s manifests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package application
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"img_infinite_canvas/internal/domain/design"
|
|
)
|
|
|
|
func TestProjectThumbnailUsesCanvasPreview(t *testing.T) {
|
|
project := design.Project{
|
|
Brief: "still day 官网首页",
|
|
Nodes: []design.Node{
|
|
{
|
|
ID: "small",
|
|
Type: design.NodeTypeImage,
|
|
Title: "Small",
|
|
Content: "http://localhost:19000/canvas-assets/small.png",
|
|
Width: 240,
|
|
Height: 240,
|
|
Status: "success",
|
|
},
|
|
{
|
|
ID: "main",
|
|
Type: design.NodeTypeImage,
|
|
Title: "Main",
|
|
Content: "http://localhost:19000/canvas-assets/main.png",
|
|
Width: 1024,
|
|
Height: 768,
|
|
Status: "success",
|
|
},
|
|
},
|
|
}
|
|
|
|
got := projectThumbnail(project)
|
|
if !strings.HasPrefix(got, projectCanvasPreviewPrefix) {
|
|
t.Fatalf("expected canvas preview thumbnail, got %s", got)
|
|
}
|
|
var preview projectCanvasPreview
|
|
raw, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(got, projectCanvasPreviewPrefix))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := json.Unmarshal(raw, &preview); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(preview.Nodes) != 2 {
|
|
t.Fatalf("expected two preview nodes, got %#v", preview.Nodes)
|
|
}
|
|
if preview.Nodes[1].Content != "http://localhost:19000/canvas-assets/main.png" {
|
|
t.Fatalf("expected generated image in canvas preview, got %#v", preview.Nodes[1])
|
|
}
|
|
}
|
|
|
|
func TestProjectThumbnailFallsBackToPromptVariant(t *testing.T) {
|
|
project := design.Project{Brief: "电商产品图"}
|
|
if got := projectThumbnail(project); got != "commerce" {
|
|
t.Fatalf("expected commerce fallback, got %s", got)
|
|
}
|
|
}
|