From 1c30cc2027b1d8342aa8396de28b4eb8b4606b5d Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 13 Apr 2026 21:27:29 +0200 Subject: [PATCH] Update project document serialization tests to include paths and migration logic --- .../project-document-json.test.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/serialization/project-document-json.test.ts b/tests/serialization/project-document-json.test.ts index d03751ff..0d165a7e 100644 --- a/tests/serialization/project-document-json.test.ts +++ b/tests/serialization/project-document-json.test.ts @@ -4,6 +4,7 @@ import { AUTHORED_OBJECT_STATE_SCENE_DOCUMENT_VERSION, DEFAULT_PROJECT_NAME, DEFAULT_SCENE_EDITOR_SNAP_STEP, + NPC_COLLIDER_SCENE_DOCUMENT_VERSION, PLAYER_START_GAMEPAD_CAMERA_LOOK_SCENE_DOCUMENT_VERSION, PROJECT_TIME_DAY_NIGHT_PROFILE_SCENE_DOCUMENT_VERSION, RUNNER_LOADING_SCREEN_SCENE_DOCUMENT_VERSION, @@ -11,6 +12,7 @@ import { createEmptyProjectDocument, createEmptyProjectScene } from "../../src/document/scene-document"; +import { createScenePath } from "../../src/document/paths"; import { createDefaultProjectTimeSettings } from "../../src/document/project-time-settings"; import { createDefaultWorldSettings, @@ -167,12 +169,68 @@ describe("project document JSON", () => { lightIntensityFactor: 0.19 } }; + document.scenes["scene-cellar"].paths["path-cellar-patrol"] = createScenePath( + { + id: "path-cellar-patrol", + name: "Cellar Patrol", + loop: true, + points: [ + { + id: "path-point-a", + position: { + x: -2, + y: 0, + z: 1 + } + }, + { + id: "path-point-b", + position: { + x: 0, + y: 0, + z: 3 + } + }, + { + id: "path-point-c", + position: { + x: 2, + y: 0, + z: 1 + } + } + ] + } + ); const serializedDocument = serializeProjectDocument(document); expect(parseProjectDocumentJson(serializedDocument)).toEqual(document); }); + it("migrates pre-path project documents to empty scene path registries", () => { + const migratedDocument = parseProjectDocumentJson( + JSON.stringify({ + version: NPC_COLLIDER_SCENE_DOCUMENT_VERSION, + name: "Legacy Pathless Project", + activeSceneId: "scene-main", + scenes: { + "scene-main": createEmptyProjectScene({ + id: "scene-main", + name: "Legacy Scene" + }) + }, + materials: createEmptyProjectDocument().materials, + textures: {}, + assets: {}, + time: createDefaultProjectTimeSettings() + }) + ); + + expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); + expect(migratedDocument.scenes["scene-main"]?.paths).toEqual({}); + }); + it("migrates pre-project-time multi-scene documents to default project time settings", () => { const migratedDocument = parseProjectDocumentJson( JSON.stringify({