Support canvas frame nodes and explicit membership snapshots
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -234,6 +235,28 @@ func TestOnboardingAndSharing(t *testing.T) {
|
||||
if call("GET", workspacePath, tokens[0], nil, 200)["slug"] != "research-team" {
|
||||
t.Fatal("rename changed slug")
|
||||
}
|
||||
|
||||
// Frames round-trip through PostgreSQL with all label modes and explicit memberships.
|
||||
for index, mode := range []string{"hidden", "fixed", "scaled"} {
|
||||
version := strconv.Itoa(4 + index)
|
||||
raw := strings.Replace(frameFixture, `"labelMode":"fixed"`, `"labelMode":"`+mode+`"`, 1)
|
||||
call("PATCH", canvasPath, tokens[0], response{"document": json.RawMessage(raw)}, 200, `"`+version+`"`)
|
||||
persisted := call("GET", canvasPath, tokens[0], nil, 200)
|
||||
normalized, _ := normalizeCanvas(json.RawMessage(raw))
|
||||
want, _ := json.Marshal(json.RawMessage(normalized))
|
||||
got, _ := json.Marshal(persisted["document"])
|
||||
if !bytes.Equal(want, got) {
|
||||
t.Fatal("frame snapshot not preserved")
|
||||
}
|
||||
}
|
||||
invalidFrame := strings.Replace(frameFixture, `"frameId":"frame"`, `"frameId":"missing"`, 1)
|
||||
rejected := call("PATCH", canvasPath, tokens[0], response{"document": json.RawMessage(invalidFrame)}, 400, `"7"`)
|
||||
if rejected["error"] != "invalid_canvas" {
|
||||
t.Fatal("unexpected frame error")
|
||||
}
|
||||
if call("GET", canvasPath, tokens[0], nil, 200)["version"] != float64(7) {
|
||||
t.Fatal("invalid frame changed saved version")
|
||||
}
|
||||
layout := call("POST", boardPath+"/layouts", tokens[0], response{"material_id": articleID, "x": 1, "y": 2, "width": 320, "height": 200, "z_index": 1}, 201, `"2"`)
|
||||
call("GET", boardPath+"/layouts", tokens[1], nil, 200)
|
||||
call("POST", boardPath+"/grants", tokens[0], response{"account_id": accounts[2], "role": "viewer"}, 204)
|
||||
|
||||
Reference in New Issue
Block a user