From af7ae7d210d91b1e29a2f55a1aa46a731c35feea Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 2 May 2026 03:49:11 +0200 Subject: [PATCH] auto-git: [change] tests/serialization/scene-document-json.test.ts --- .../serialization/scene-document-json.test.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/serialization/scene-document-json.test.ts b/tests/serialization/scene-document-json.test.ts index 44371e4d..ce751715 100644 --- a/tests/serialization/scene-document-json.test.ts +++ b/tests/serialization/scene-document-json.test.ts @@ -40,6 +40,7 @@ import { NPC_ENTITY_FOUNDATION_SCENE_DOCUMENT_VERSION, NPC_DIALOGUE_REFERENCE_SCENE_DOCUMENT_VERSION, PATH_FOUNDATION_SCENE_DOCUMENT_VERSION, + PLAYER_START_EDGE_ASSIST_SCENE_DOCUMENT_VERSION, PLAYER_START_AIR_CONTROL_SCENE_DOCUMENT_VERSION, PLAYER_START_AIR_DIRECTION_CONTROL_SCENE_DOCUMENT_VERSION, PLAYER_START_COLLIDER_SETTINGS_SCENE_DOCUMENT_VERSION, @@ -102,6 +103,8 @@ import { parseSceneDocumentJson, serializeSceneDocument } from "../../src/serialization/scene-document-json"; +import { BUNDLED_FOLIAGE_PROTOTYPES } from "../../src/foliage/bundled-foliage-manifest"; +import { createFoliageLayer } from "../../src/foliage/foliage"; describe("scene document JSON", () => { it("round-trips the current empty schema", () => { @@ -134,6 +137,46 @@ describe("scene document JSON", () => { ); }); + it("round-trips authored foliage layer references in the current schema", () => { + const bundledPrototype = BUNDLED_FOLIAGE_PROTOTYPES[0]; + const layer = createFoliageLayer({ + id: "foliage-layer-roundtrip", + name: "Roundtrip Meadow", + prototypeIds: [bundledPrototype.id], + density: 1.25, + minScale: 0.8, + maxScale: 1.35, + seed: 42 + }); + const document = createEmptySceneDocument({ name: "Foliage Scene" }); + document.foliageLayers[layer.id] = layer; + + expect(parseSceneDocumentJson(serializeSceneDocument(document))).toEqual( + document + ); + }); + + it("migrates pre-foliage scene documents with empty foliage state", () => { + const document = createEmptySceneDocument({ + name: "Legacy Foliage-Free Scene" + }); + const legacyDocument = JSON.parse( + serializeSceneDocument(document) + ) as Record; + + legacyDocument.version = PLAYER_START_EDGE_ASSIST_SCENE_DOCUMENT_VERSION; + delete legacyDocument.foliagePrototypes; + delete legacyDocument.foliageLayers; + + const migratedDocument = parseSceneDocumentJson( + JSON.stringify(legacyDocument) + ); + + expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); + expect(migratedDocument.foliagePrototypes).toEqual({}); + expect(migratedDocument.foliageLayers).toEqual({}); + }); + it("round-trips camera rig control effects in interaction links, sequences, and scheduler routines", () => { const cameraRig = createCameraRigEntity({ id: "entity-camera-rig-main",