docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// 画布与资产纯函数回归;测试说明对应实际断言,不依赖浏览器或真实模型。
|
||||
package platform
|
||||
|
||||
import (
|
||||
@@ -6,8 +7,10 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// canvasFixture 同时供多组回归使用:含中文文本、脚本、不可连线图标及临时 selected。
|
||||
const canvasFixture = `{"schema_version":1,"nodes":[{"id":"a","type":"material","position":{"x":100,"y":200},"width":320,"height":220,"selected":true,"data":{"kind":"text","title":"灵感笔记","text":"正文","rotation":30,"fontSize":24,"textStyle":{"color":"#37352f","background":"transparent","bold":true,"italic":false,"underline":false,"align":"left","fontFamily":"sans","lineHeight":1.5}}},{"id":"b","type":"material","position":{"x":0,"y":0},"data":{"kind":"script","title":"Script","text":""}},{"id":"icon","type":"icon","position":{"x":500,"y":200},"width":80,"height":80,"data":{"kind":"icon","title":"火箭","text":"","icon":"Rocket","rotation":0}}],"edges":[{"id":"e","source":"a","target":"b","sourceHandle":"top","targetHandle":"bottom"}],"viewport":{"x":0,"y":0,"zoom":1}}`
|
||||
|
||||
// TestCanvasValidation 从合法快照逐项破坏类型、范围、引用和版本,检查临时 selected 不落库以及必需文档结构。
|
||||
func TestCanvasValidation(t *testing.T) {
|
||||
out, ok := normalizeCanvas(json.RawMessage(canvasFixture))
|
||||
if !ok || strings.Contains(string(out), "selected") {
|
||||
@@ -27,6 +30,8 @@ func TestCanvasValidation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestSlugValidation 检查小写连字符别名可用,拒绝空值、空格大写、路径穿越和超长别名。
|
||||
func TestSlugValidation(t *testing.T) {
|
||||
for _, v := range []string{"my-board", "workspace-2026"} {
|
||||
if !validSlug(&v) {
|
||||
@@ -41,8 +46,10 @@ func TestSlugValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
// Frame nodes follow the frontend contract: membership is data, not containment.
|
||||
// frameFixture 把重叠的 outside 留在框外,以区分几何包含与显式 frameId 成员关系。
|
||||
const frameFixture = `{"schema_version":1,"nodes":[{"id":"text","type":"material","position":{"x":100,"y":100},"data":{"kind":"text","title":"成员","text":"正文","frameId":"frame"}},{"id":"plain","type":"plainText","position":{"x":0,"y":0},"data":{"kind":"plain-text","title":"纯文本","text":"文字","frameId":"frame"}},{"id":"icon","type":"icon","position":{"x":10,"y":10},"data":{"kind":"icon","title":"图标","text":"","icon":"Star","frameId":"frame"}},{"id":"frame","type":"frame","position":{"x":0,"y":0},"width":600,"height":400,"zIndex":-1,"style":{"width":600,"height":400,"pointerEvents":"none"},"data":{"kind":"frame","title":"框选区","text":"","rotation":0,"labelMode":"fixed"}},{"id":"outside","type":"material","position":{"x":100,"y":100},"data":{"kind":"script","title":"重叠但未加入","text":""}}],"edges":[],"viewport":{"x":0,"y":0,"zoom":1}}`
|
||||
|
||||
// TestCanvasFrames 检查三种标签模式、显式成员关系、临时渲染字段剔除;框不可旋转/嵌套为成员,v1 边不可连到框。
|
||||
func TestCanvasFrames(t *testing.T) {
|
||||
for _, mode := range []string{"hidden", "fixed", "scaled"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
@@ -89,6 +96,7 @@ func TestCanvasFrames(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestCanvasPlainImages 验证 v1 plainImage 的类型与源地址契约,以及显式 frameId;v1 下纯图片不能作为连线端点。
|
||||
func TestCanvasPlainImages(t *testing.T) {
|
||||
fixture := `{"schema_version":1,"nodes":[{"id":"photo","type":"plainImage","position":{"x":20,"y":30},"width":320,"height":240,"data":{"kind":"plain-image","title":"Photo","text":"","src":"https://example.com/photo.png","rotation":30,"frameId":"frame"}},{"id":"frame","type":"frame","position":{"x":0,"y":0},"width":640,"height":400,"data":{"kind":"frame","title":"Frame","text":"","labelMode":"fixed"}}],"edges":[],"viewport":{"x":0,"y":0,"zoom":1}}`
|
||||
if _, ok := normalizeCanvas(json.RawMessage(fixture)); !ok {
|
||||
|
||||
Reference in New Issue
Block a user