From c1c79b5dc6542503139e123a85e482d290d0c6b8 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 11 Apr 2026 11:20:06 +0200 Subject: [PATCH] Add test for migrating Player Start entities to default to first-person navigation --- .../serialization/scene-document-json.test.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/serialization/scene-document-json.test.ts b/tests/serialization/scene-document-json.test.ts index a8f46167..66e23130 100644 --- a/tests/serialization/scene-document-json.test.ts +++ b/tests/serialization/scene-document-json.test.ts @@ -10,6 +10,7 @@ import { LOCAL_LIGHTS_AND_SKYBOX_SCENE_DOCUMENT_VERSION, MODEL_ASSET_PIPELINE_SCENE_DOCUMENT_VERSION, PLAYER_START_COLLIDER_SETTINGS_SCENE_DOCUMENT_VERSION, + SCENE_TRANSITION_ENTITIES_SCENE_DOCUMENT_VERSION, SCENE_DOCUMENT_VERSION, SPATIAL_AUDIO_SCENE_DOCUMENT_VERSION, TRIGGER_ACTION_TARGET_FOUNDATION_SCENE_DOCUMENT_VERSION, @@ -610,6 +611,47 @@ describe("scene document JSON", () => { ); }); + it("migrates version 24 Player Start entities to default to first-person navigation", () => { + const playerStart = { + id: "entity-player-start-legacy-navigation", + kind: "playerStart" as const, + position: { + x: 0, + y: 0, + z: 1 + }, + yawDegrees: 180, + collider: { + mode: "capsule" as const, + eyeHeight: 1.6, + capsuleRadius: 0.3, + capsuleHeight: 1.8, + boxSize: { + x: 0.6, + y: 1.8, + z: 0.6 + } + } + }; + const legacyDocument = { + ...createEmptySceneDocument({ name: "Legacy Player Navigation Scene" }), + version: SCENE_TRANSITION_ENTITIES_SCENE_DOCUMENT_VERSION, + entities: { + [playerStart.id]: playerStart + } + }; + + const migratedDocument = migrateSceneDocument(legacyDocument); + + expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); + expect(migratedDocument.entities[playerStart.id]).toEqual( + createPlayerStartEntity({ + ...playerStart, + navigationMode: "firstPerson" + }) + ); + }); + it("round-trips the initial typed entity registry without mixing entities into model instances", () => { const playerStart = createPlayerStartEntity({ id: "entity-player-start-main"