This commit is contained in:
2026-05-24 15:32:36 +00:00
commit 1eb5350d09
20 changed files with 2852 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import { describe, expect, test } from "bun:test";
import { HttpError, MAX_SCENE_BYTES, normalizeScene, parseJsonBody } from "./scene";
describe("scene helpers", () => {
test("normalizes volatile app state fields", () => {
const scene = normalizeScene({
elements: [],
appState: {
selectedElementIds: { one: true },
viewModeEnabled: false,
},
files: {},
});
expect(scene.appState.selectedElementIds).toBeUndefined();
expect(scene.appState.viewModeEnabled).toBe(false);
});
test("rejects oversized payloads", () => {
const text = "x".repeat(MAX_SCENE_BYTES + 1);
expect(() => parseJsonBody(text)).toThrow(HttpError);
expect(() => parseJsonBody(text)).toThrow("Payload too large");
});
});