diff --git a/src/cli/command-secret-targets.import.test.ts b/src/cli/command-secret-targets.import.test.ts index 921ca1ed12a..2e1e4a9e16b 100644 --- a/src/cli/command-secret-targets.import.test.ts +++ b/src/cli/command-secret-targets.import.test.ts @@ -147,10 +147,11 @@ describe("command secret targets module import", () => { expect(targets.has("channels.telegram.gatewayToken")).toBe(false); expect(targets.has("channels.telegram.gatewayTokenRef")).toBe(false); expect(targets.has("agents.defaults.memorySearch.remote.apiKey")).toBe(true); - expect(listReadOnlyChannelPluginsForConfig).toHaveBeenCalledWith( - expect.any(Object), - expect.objectContaining({ includePersistedAuthState: false }), - ); + const pluginCall = listReadOnlyChannelPluginsForConfig.mock.calls[0] as unknown as + | [unknown, { includePersistedAuthState?: boolean }] + | undefined; + expect(typeof pluginCall?.[0]).toBe("object"); + expect(pluginCall?.[1]?.includePersistedAuthState).toBe(false); expect(listSecretTargetRegistryEntries).not.toHaveBeenCalled(); }); }); diff --git a/src/cli/logs-cli.test.ts b/src/cli/logs-cli.test.ts index 9ce7fa7738f..4338f10920d 100644 --- a/src/cli/logs-cli.test.ts +++ b/src/cli/logs-cli.test.ts @@ -426,12 +426,8 @@ describe("logs cli", () => { const messages = noticeRecords .filter((record) => record.type === "notice") .map((record) => record.message ?? ""); - expect(messages).toEqual( - expect.arrayContaining([expect.stringContaining("gateway disconnected")]), - ); - expect(messages).toEqual( - expect.arrayContaining([expect.stringContaining("gateway reconnected")]), - ); + expect(messages.some((message) => message.includes("gateway disconnected"))).toBe(true); + expect(messages.some((message) => message.includes("gateway reconnected"))).toBe(true); expect(stdoutWrites.join("")).toContain('"type":"meta"'); expect(exitSpy).toHaveBeenCalledWith(1); }); diff --git a/src/cli/node-cli/register.test.ts b/src/cli/node-cli/register.test.ts index f202fb1fbd7..0baa181b763 100644 --- a/src/cli/node-cli/register.test.ts +++ b/src/cli/node-cli/register.test.ts @@ -38,8 +38,6 @@ describe("registerNodeCli", () => { await program.parseAsync(["node", "start", "--json"], { from: "user" }); - expect(daemonMocks.runNodeDaemonStart).toHaveBeenCalledWith( - expect.objectContaining({ json: true }), - ); + expect(daemonMocks.runNodeDaemonStart.mock.calls[0]?.[0]?.json).toBe(true); }); }); diff --git a/src/cli/program.force.test.ts b/src/cli/program.force.test.ts index cda596c7a39..8440e058873 100644 --- a/src/cli/program.force.test.ts +++ b/src/cli/program.force.test.ts @@ -188,11 +188,11 @@ describe("gateway --force helpers", () => { expect(result.escalatedToSigkill).toBe(false); expect(result.killed).toEqual([{ pid: 4242 }]); - expect(execFileSync).toHaveBeenCalledWith( - "fuser", - ["-k", "-TERM", "18789/tcp"], - expect.objectContaining({ encoding: "utf-8" }), + const termCall = (execFileSync as unknown as Mock).mock.calls.find( + ([cmd, args]) => cmd === "fuser" && Array.isArray(args) && args.includes("-TERM"), ); + expect(termCall?.[1]).toEqual(["-k", "-TERM", "18789/tcp"]); + expect((termCall?.[2] as { encoding?: string } | undefined)?.encoding).toBe("utf-8"); }); it("uses fuser SIGKILL escalation when port stays busy", async () => { @@ -230,11 +230,11 @@ describe("gateway --force helpers", () => { expect(result.escalatedToSigkill).toBe(true); expect(result.waitedMs).toBe(100); - expect(execFileSync).toHaveBeenCalledWith( - "fuser", - ["-k", "-KILL", "18789/tcp"], - expect.objectContaining({ encoding: "utf-8" }), + const killCall = (execFileSync as unknown as Mock).mock.calls.find( + ([cmd, args]) => cmd === "fuser" && Array.isArray(args) && args.includes("-KILL"), ); + expect(killCall?.[1]).toEqual(["-k", "-KILL", "18789/tcp"]); + expect((killCall?.[2] as { encoding?: string } | undefined)?.encoding).toBe("utf-8"); vi.useRealTimers(); }); diff --git a/src/cli/program.smoke.test.ts b/src/cli/program.smoke.test.ts index 8dc3be74ef4..bfd9d6f305b 100644 --- a/src/cli/program.smoke.test.ts +++ b/src/cli/program.smoke.test.ts @@ -52,20 +52,25 @@ describe("cli program (smoke)", () => { it("runs tui with explicit timeout override", async () => { await runProgram(["tui", "--timeout-ms", "45000"]); - expect(runTui).toHaveBeenCalledWith(expect.objectContaining({ timeoutMs: 45000 })); + const options = runTui.mock.calls[0]?.[0] as { timeoutMs?: number } | undefined; + expect(options?.timeoutMs).toBe(45000); }); it("runs crestodian one-shot requests", async () => { await runProgram(["crestodian", "--message", "status"]); - expect(runCrestodian).toHaveBeenCalledWith( - expect.objectContaining({ message: "status", yes: false, json: false }), - ); + const options = runCrestodian.mock.calls[0]?.[0] as + | { message?: string; yes?: boolean; json?: boolean } + | undefined; + expect(options?.message).toBe("status"); + expect(options?.yes).toBe(false); + expect(options?.json).toBe(false); }); it("warns and ignores invalid tui timeout override", async () => { await runProgram(["tui", "--timeout-ms", "nope"]); expect(runtime.error).toHaveBeenCalledWith('warning: invalid --timeout-ms "nope"; ignoring'); - expect(runTui).toHaveBeenCalledWith(expect.objectContaining({ timeoutMs: undefined })); + const options = runTui.mock.calls[0]?.[0] as { timeoutMs?: number } | undefined; + expect(options?.timeoutMs).toBeUndefined(); }); it("runs setup wizard when wizard flags are present", async () => { diff --git a/src/cli/program/help.test.ts b/src/cli/program/help.test.ts index 188f80a58ed..a576c43e130 100644 --- a/src/cli/program/help.test.ts +++ b/src/cli/program/help.test.ts @@ -135,10 +135,11 @@ describe("configureProgramHelp", () => { const help = captureHelpOutput(program); expect(help).toContain("BANNER-LINE"); - expect(formatCliBannerLineMock).toHaveBeenCalledWith( - testProgramContext.programVersion, - expect.objectContaining({ mode: "default" }), - ); + const [version, options] = (formatCliBannerLineMock.mock.calls[0] as unknown as + | [string, { mode?: string }] + | undefined) ?? [undefined, undefined]; + expect(version).toBe(testProgramContext.programVersion); + expect(options?.mode).toBe("default"); expect(help).toContain("Examples:"); expect(help).toContain("https://docs.openclaw.ai/cli"); }); diff --git a/src/cli/system-cli.test.ts b/src/cli/system-cli.test.ts index 02f84cb3591..5e915756134 100644 --- a/src/cli/system-cli.test.ts +++ b/src/cli/system-cli.test.ts @@ -44,12 +44,11 @@ describe("system-cli", () => { it("runs system event with default wake mode and text output", async () => { await runCli(["system", "event", "--text", " hello world "]); - expect(callGatewayFromCli).toHaveBeenCalledWith( - "wake", - expect.objectContaining({ text: " hello world " }), - { mode: "next-heartbeat", text: "hello world" }, - { expectFinal: false }, - ); + const [method, payload, options, requestOptions] = callGatewayFromCli.mock.calls[0] ?? []; + expect(method).toBe("wake"); + expect((payload as { text?: string } | undefined)?.text).toBe(" hello world "); + expect(options).toEqual({ mode: "next-heartbeat", text: "hello world" }); + expect(requestOptions).toEqual({ expectFinal: false }); expect(runtimeLogs).toEqual(["ok"]); });