diff --git a/src/commands/agent.runtime-config.test.ts b/src/commands/agent.runtime-config.test.ts index 6869337517e..03db12f2baf 100644 --- a/src/commands/agent.runtime-config.test.ts +++ b/src/commands/agent.runtime-config.test.ts @@ -63,6 +63,15 @@ async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-agent-" }); } +function requireResolveCommandConfigParams(callIndex = 0): ResolveCommandConfigParams { + const call = resolveCommandConfigWithSecretsMock.mock.calls.at(callIndex); + if (!call) { + throw new Error(`expected command config resolution call ${callIndex}`); + } + const [params] = call; + return params; +} + function mockConfig(home: string, storePath: string): OpenClawConfig { const cfg = { agents: { @@ -153,7 +162,7 @@ describe("agentCommand runtime config", () => { targetIds: new Set(["models.providers.*.apiKey"]), runtime, }); - const targetIds = resolveCommandConfigWithSecretsMock.mock.calls[0]?.[0].targetIds; + const targetIds = requireResolveCommandConfigParams().targetIds; expect(targetIds.has("models.providers.*.apiKey")).toBe(true); expect(targetIds.has("channels.telegram.botToken")).toBe(false); expect(setRuntimeConfigSnapshotMock).toHaveBeenCalledWith(resolvedConfig, sourceConfig); @@ -180,7 +189,7 @@ describe("agentCommand runtime config", () => { runtimeTargetsChannelSecrets: true, }); - const targetIds = resolveCommandConfigWithSecretsMock.mock.calls[0]?.[0].targetIds; + const targetIds = requireResolveCommandConfigParams().targetIds; expect(targetIds.has("channels.telegram.botToken")).toBe(true); }); });