diff --git a/tests/serialization/scene-document-json.test.ts b/tests/serialization/scene-document-json.test.ts index 2c0aa891..6e1d8ffc 100644 --- a/tests/serialization/scene-document-json.test.ts +++ b/tests/serialization/scene-document-json.test.ts @@ -1094,7 +1094,48 @@ describe("scene document JSON", () => { height: 0.12, materialId: null }); - expect(SPLINE_CORRIDOR_JUNCTION_EDGE_SCENE_DOCUMENT_VERSION).toBe( + expect(SPLINE_CORRIDOR_JUNCTION_EDGE_SCENE_DOCUMENT_VERSION).toBe(108); + }); + + it("migrates junctions without authored shape settings to straight junctions", () => { + const pathA = createScenePath({ id: "path-junction-shape-json-a" }); + const pathB = createScenePath({ id: "path-junction-shape-json-b" }); + const junction = createSplineCorridorJunction({ + id: "junction-shape-json", + center: { x: 1, y: 0, z: 2 }, + connections: [ + { pathId: pathA.id, progress: 0.25, clipDistance: 2.5 }, + { pathId: pathB.id, progress: 0.75, clipDistance: 2.5 } + ] + }); + const legacyDocument = JSON.parse( + serializeSceneDocument({ + ...createEmptySceneDocument({ + name: "Legacy Junction Shape Scene" + }), + paths: { + [pathA.id]: pathA, + [pathB.id]: pathB + }, + splineCorridorJunctions: { + [junction.id]: junction + } + }) + ) as { + version: number; + splineCorridorJunctions: Record; + }; + + legacyDocument.version = SPLINE_CORRIDOR_JUNCTION_EDGE_SCENE_DOCUMENT_VERSION; + delete legacyDocument.splineCorridorJunctions[junction.id]?.shapeMode; + + const migratedDocument = migrateSceneDocument(legacyDocument); + + expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); + expect( + migratedDocument.splineCorridorJunctions[junction.id]?.shapeMode + ).toBe("straight"); + expect(SPLINE_CORRIDOR_JUNCTION_SHAPE_SCENE_DOCUMENT_VERSION).toBe( SCENE_DOCUMENT_VERSION ); }); @@ -1108,6 +1149,7 @@ describe("scene document JSON", () => { radius: 2.5, materialId: "starter-concrete-checker", terrainMode: "paintOnly", + shapeMode: "curve", edge: { enabled: true, collisionEnabled: true,