2026-07-16 16:40:47 +08:00
|
|
|
package logic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"img_infinite_canvas/internal/domain/design"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCanvasNodeSemanticContextRoundTrip(t *testing.T) {
|
|
|
|
|
nodes := []design.Node{{
|
|
|
|
|
ID: "cad-1",
|
|
|
|
|
Type: design.NodeTypeImage,
|
|
|
|
|
Title: "plan.svg",
|
|
|
|
|
LayerRole: "cad-vector",
|
|
|
|
|
SemanticContext: "CAD semantic context: layer ROOMS",
|
2026-07-16 20:45:56 +08:00
|
|
|
RenderContent: "https://assets.example/plan-preview.webp",
|
2026-07-16 16:40:47 +08:00
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
roundTrip := toDomainNodes(toAPINodes(nodes))
|
2026-07-16 20:45:56 +08:00
|
|
|
if len(roundTrip) != 1 || roundTrip[0].SemanticContext != nodes[0].SemanticContext || roundTrip[0].RenderContent != nodes[0].RenderContent {
|
|
|
|
|
t.Fatalf("expected CAD context and render content round trip, got %#v", roundTrip)
|
2026-07-16 16:40:47 +08:00
|
|
|
}
|
|
|
|
|
}
|