diff --git a/src/cli/gateway-cli/run.option-collisions.test.ts b/src/cli/gateway-cli/run.option-collisions.test.ts index 88ad3e57496..982fa30b74e 100644 --- a/src/cli/gateway-cli/run.option-collisions.test.ts +++ b/src/cli/gateway-cli/run.option-collisions.test.ts @@ -319,6 +319,41 @@ describe("gateway run option collisions", () => { expect(secondOptions.startupStartedAt).toBe(2000); }); + it("uses the startup snapshot only for the first in-process gateway start", async () => { + runGatewayLoop.mockImplementationOnce(async ({ start }: { start: GatewayLoopStart }) => { + await start({ startupStartedAt: 1000 }); + await start({ startupStartedAt: 2000 }); + }); + + await runGatewayCli(["gateway", "run", "--allow-unconfigured"]); + + expect(startGatewayServer).toHaveBeenCalledTimes(2); + expect(startGatewayServer).toHaveBeenNthCalledWith( + 1, + 18789, + expect.objectContaining({ + startupStartedAt: 1000, + startupConfigSnapshotRead: { + snapshot: configState.snapshot, + }, + }), + ); + expect(startGatewayServer).toHaveBeenNthCalledWith( + 2, + 18789, + expect.not.objectContaining({ + startupConfigSnapshotRead: expect.anything(), + }), + ); + expect(startGatewayServer).toHaveBeenNthCalledWith( + 2, + 18789, + expect.objectContaining({ + startupStartedAt: 2000, + }), + ); + }); + it("logs when first startup will build missing Control UI assets", async () => { controlUiState.root = null;