From 1cc4fc3cb6daccfaad7e9f4e94ce31dc6cfd5608 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 18 May 2026 13:25:25 +0200 Subject: [PATCH] Add test case for clock-only frame updates when scene building fails --- .../editor-simulation-controller.test.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/domain/editor-simulation-controller.test.ts b/tests/domain/editor-simulation-controller.test.ts index 38392b31..ffa7ad64 100644 --- a/tests/domain/editor-simulation-controller.test.ts +++ b/tests/domain/editor-simulation-controller.test.ts @@ -159,4 +159,36 @@ describe("EditorSimulationController", () => { expect(frameListener).toHaveBeenCalledTimes(2); expect(uiListener).not.toHaveBeenCalled(); }); + + it("versions clock-only frame updates when the runtime scene cannot build", () => { + const document = createEmptySceneDocument(); + document.time.startTimeOfDayHours = 9; + const controller = new EditorSimulationController({ + requestAnimationFrame: () => 1, + cancelAnimationFrame: () => undefined, + buildRuntimeScene: () => { + throw new Error("Invalid runtime scene"); + } + }); + const frameListener = vi.fn(); + + controller.updateInputs({ + document, + loadedModelAssets: {} + }); + + const initialFrame = controller.getFrameSnapshot(); + expect(initialFrame.runtimeScene).toBeNull(); + + controller.subscribeFrame(frameListener); + controller.stepHours(1); + + const steppedFrame = controller.getFrameSnapshot(); + expect(steppedFrame.runtimeScene).toBeNull(); + expect(steppedFrame.clock?.timeOfDayHours).toBe(10); + expect(steppedFrame.frameVersion).toBeGreaterThan( + initialFrame.frameVersion + ); + expect(frameListener).toHaveBeenLastCalledWith(steppedFrame); + }); });