Verify canonical partition restoration and frontend protocol fixture
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user