From 1ade7a53af1e0507cc50a65d2e6070fbb271fe70 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 13 May 2026 00:43:49 +0100 Subject: [PATCH] test: dedupe cron scope mock reads --- src/agents/pi-tools.cron-scope.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/agents/pi-tools.cron-scope.test.ts b/src/agents/pi-tools.cron-scope.test.ts index c0291c5cc4e..3ba67da6e4d 100644 --- a/src/agents/pi-tools.cron-scope.test.ts +++ b/src/agents/pi-tools.cron-scope.test.ts @@ -30,6 +30,12 @@ import "./test-helpers/fast-bash-tools.js"; import "./test-helpers/fast-coding-tools.js"; import { createOpenClawCodingTools } from "./pi-tools.js"; +function firstOpenClawToolsOptions(): { cronSelfRemoveOnlyJobId?: string } | undefined { + return mocks.createOpenClawToolsOptions.mock.calls[0]?.[0] as + | { cronSelfRemoveOnlyJobId?: string } + | undefined; +} + describe("createOpenClawCodingTools cron scope", () => { beforeEach(() => { mocks.createOpenClawToolsOptions.mockClear(); @@ -44,8 +50,7 @@ describe("createOpenClawCodingTools cron scope", () => { }); expect(tools.map((tool) => tool.name)).toContain("cron"); - const [options] = mocks.createOpenClawToolsOptions.mock.calls.at(0) ?? []; - expect(options?.cronSelfRemoveOnlyJobId).toBe("job-current"); + expect(firstOpenClawToolsOptions()?.cronSelfRemoveOnlyJobId).toBe("job-current"); }); it("does not scope ordinary owner cron sessions", () => { @@ -55,7 +60,6 @@ describe("createOpenClawCodingTools cron scope", () => { senderIsOwner: true, }); - const [options] = mocks.createOpenClawToolsOptions.mock.calls.at(0) ?? []; - expect(options?.cronSelfRemoveOnlyJobId).toBeUndefined(); + expect(firstOpenClawToolsOptions()?.cronSelfRemoveOnlyJobId).toBeUndefined(); }); });