Verify canonical partition restoration and frontend protocol fixture
Foundry Go checks / check (push) Failing after 3m6s
Foundry Go checks / check (pull_request) Failing after 2m36s

This commit is contained in:
2026-11-07 22:40:39 +08:00
parent 12458e10dc
commit b7499e3815
3 changed files with 74 additions and 0 deletions
+27
View File
@@ -1,8 +1,10 @@
package platform
import (
"bytes"
"encoding/json"
"fmt"
"os"
"testing"
)
@@ -149,3 +151,28 @@ func TestCanonicalValidationRejectsPartialChangesAndWrongEdgeOwner(t *testing.T)
t.Fatal("cross-child connection acquired a child owner")
}
}
func TestCanonicalFrontendProtocolFixture(t *testing.T) {
raw, err := os.ReadFile("testdata/foundry-model-operation-v2.json")
if err != nil {
t.Fatal(err)
}
var input modelBatch
decoder := json.NewDecoder(bytes.NewReader(raw))
decoder.DisallowUnknownFields()
if err = decoder.Decode(&input); err != nil {
t.Fatal(err)
}
if input.ProtocolVersion != canvasModelProtocol || !uuidSlugPattern.MatchString(input.RequestID) || input.Expected[modelRootID] != 3 {
t.Fatal("frontend fixture envelope is incompatible")
}
before := modelTestDocument()
before.Versions[modelRootID] = 3
after, touched, err := applyModelOperations(before, input.Operations)
if err != nil {
t.Fatal(err)
}
if !touched[modelRootID] || after.Versions[modelRootID] != 4 || after.Elements["a"]["data"].(map[string]any)["title"] != "renamed" || after.Elements["a"]["data"].(map[string]any)["text"] != "preserved" {
t.Fatal("frontend fixture did not apply exactly its intended field change")
}
}