diff --git a/src/agents/pi-embedded-runner/compaction-successor-transcript.test.ts b/src/agents/pi-embedded-runner/compaction-successor-transcript.test.ts index b70c6b4c9d45..987fb8ded95d 100644 --- a/src/agents/pi-embedded-runner/compaction-successor-transcript.test.ts +++ b/src/agents/pi-embedded-runner/compaction-successor-transcript.test.ts @@ -126,19 +126,23 @@ describe("rotateTranscriptAfterCompaction", () => { expect(header.cwd).toBe(dir); const messages = successor.buildSessionContext().messages; expect( - messages.map((message) => - message.role === "compactionSummary" - ? { - role: message.role, - summary: message.summary, - tokensBefore: message.tokensBefore, - } - : { - role: message.role, - content: message.content, - timestamp: message.timestamp, - }, - ), + messages.map((message) => { + if (message.role === "compactionSummary") { + return { + role: message.role, + summary: message.summary, + tokensBefore: message.tokensBefore, + }; + } + if (!("content" in message)) { + throw new Error(`expected ${message.role} message content`); + } + return { + role: message.role, + content: message.content, + timestamp: message.timestamp, + }; + }), ).toEqual([ { role: "compactionSummary", diff --git a/src/gateway/config-reload.test.ts b/src/gateway/config-reload.test.ts index d9ad99cc3c85..2239384d9490 100644 --- a/src/gateway/config-reload.test.ts +++ b/src/gateway/config-reload.test.ts @@ -634,7 +634,7 @@ type ReloaderHarness = ReturnType; function getOnlyRestartCall(harness: ReloaderHarness): [GatewayReloadPlan, OpenClawConfig] { expect(harness.onRestart).toHaveBeenCalledTimes(1); - const call = harness.onRestart.mock.calls.at(0); + const call = harness.onRestart.mock.calls[0]; if (!call) { throw new Error("expected one restart call"); } @@ -643,13 +643,24 @@ function getOnlyRestartCall(harness: ReloaderHarness): [GatewayReloadPlan, OpenC function getOnlyHotReloadCall(harness: ReloaderHarness): [GatewayReloadPlan, OpenClawConfig] { expect(harness.onHotReload).toHaveBeenCalledTimes(1); - const call = harness.onHotReload.mock.calls.at(0); + const call = harness.onHotReload.mock.calls[0]; if (!call) { throw new Error("expected one hot reload call"); } return call; } +function getOnlyPromoteSnapshotCall(promoteSnapshot: { + mock: { calls: Array }; +}): readonly [ConfigFileSnapshot, string] { + expect(promoteSnapshot).toHaveBeenCalledTimes(1); + const call = promoteSnapshot.mock.calls[0]; + if (!call) { + throw new Error("expected one promote snapshot call"); + } + return call; +} + describe("startGatewayConfigReloader", () => { beforeEach(() => { vi.useFakeTimers(); @@ -958,7 +969,7 @@ describe("startGatewayConfigReloader", () => { expect(readSnapshot).toHaveBeenCalledTimes(1); expect(harness.onHotReload).toHaveBeenCalledTimes(1); - const [promotedSnapshot, promotionReason] = promoteSnapshot.mock.calls.at(0) ?? []; + const [promotedSnapshot, promotionReason] = getOnlyPromoteSnapshotCall(promoteSnapshot); expect(promotedSnapshot?.hash).toBe("internal-1"); expect(promotionReason).toBe("in-process-write"); @@ -997,7 +1008,7 @@ describe("startGatewayConfigReloader", () => { expect(harness.log.info).toHaveBeenCalledWith( "config reload skipped by writer intent (caller handles follow-up)", ); - const [promotedSnapshot, promotionReason] = promoteSnapshot.mock.calls.at(0) ?? []; + const [promotedSnapshot, promotionReason] = getOnlyPromoteSnapshotCall(promoteSnapshot); expect(promotedSnapshot?.hash).toBe("internal-none"); expect(promotionReason).toBe("in-process-write");