diff --git a/src/commands/onboard-remote.test.ts b/src/commands/onboard-remote.test.ts index 9f27beaab35..1d08a8f2838 100644 --- a/src/commands/onboard-remote.test.ts +++ b/src/commands/onboard-remote.test.ts @@ -264,8 +264,8 @@ describe("promptRemoteGatewayConfig", () => { const next = await promptRemoteGatewayConfig({} as OpenClawConfig, prompter); expect(next.gateway?.remote?.url).toBe("ws://127.0.0.1:18789"); - expect(select).not.toHaveBeenCalledWith( - expect.objectContaining({ message: "Connection method" }), + expect(vi.mocked(select).mock.calls.map(([params]) => params.message)).not.toContain( + "Connection method", ); }); @@ -391,7 +391,9 @@ describe("promptRemoteGatewayConfig", () => { const next = await promptRemoteGatewayConfig(cfg, prompter); expect(next.gateway?.remote?.token).toBe("preexisting-remote-token"); - expect(text).not.toHaveBeenCalledWith(expect.objectContaining({ message: "Gateway token" })); + expect(vi.mocked(text).mock.calls.map(([params]) => params.message)).not.toContain( + "Gateway token", + ); }); it("keeps an existing remote gateway password when user confirms via masked-preview prompt", async () => { @@ -427,6 +429,8 @@ describe("promptRemoteGatewayConfig", () => { const next = await promptRemoteGatewayConfig(cfg, prompter); expect(next.gateway?.remote?.password).toBe("preexisting-remote-password"); - expect(text).not.toHaveBeenCalledWith(expect.objectContaining({ message: "Gateway password" })); + expect(vi.mocked(text).mock.calls.map(([params]) => params.message)).not.toContain( + "Gateway password", + ); }); }); diff --git a/src/commands/status-all/channels.test.ts b/src/commands/status-all/channels.test.ts index 31250f0647e..d65ef74f207 100644 --- a/src/commands/status-all/channels.test.ts +++ b/src/commands/status-all/channels.test.ts @@ -77,31 +77,20 @@ describe("buildChannelsTable", () => { }, ); - expect(table.rows).toContainEqual( - expect.objectContaining({ - id: "discord", - state: "ok", - detail: expect.not.stringContaining("unavailable"), - }), - ); - expect(table.details[0]?.rows[0]).toEqual( - expect.objectContaining({ - Status: "OK", - Notes: expect.stringContaining("credential available in gateway runtime"), - }), - ); + const row = table.rows.find((entry) => entry.id === "discord"); + expect(row?.state).toBe("ok"); + expect(row?.detail).not.toContain("unavailable"); + const detailRow = table.details[0]?.rows[0]; + expect(detailRow?.Status).toBe("OK"); + expect(detailRow?.Notes).toContain("credential available in gateway runtime"); }); it("warns when a configured token is unavailable and there is no live account proof", async () => { const table = await buildChannelsTable({ channels: { discord: { enabled: true } } }); - expect(table.rows).toContainEqual( - expect.objectContaining({ - id: "discord", - state: "warn", - detail: expect.stringContaining("unavailable"), - }), - ); + const row = table.rows.find((entry) => entry.id === "discord"); + expect(row?.state).toBe("warn"); + expect(row?.detail).toContain("unavailable"); }); it("shows configured official external channels when the plugin is missing", async () => { diff --git a/src/commands/status-overview-rows.test.ts b/src/commands/status-overview-rows.test.ts index c934c6c8eea..31ee7410381 100644 --- a/src/commands/status-overview-rows.test.ts +++ b/src/commands/status-overview-rows.test.ts @@ -9,67 +9,60 @@ import { createStatusCommandOverviewRowsParams, } from "./status.test-support.ts"; +function findRowValue(rows: Array<{ Item: string; Value: string }>, item: string) { + return rows.find((row) => row.Item === item)?.Value; +} + describe("status-overview-rows", () => { it("builds command overview rows from the shared surface", () => { - expect(buildStatusCommandOverviewRows(createStatusCommandOverviewRowsParams())).toEqual( - expect.arrayContaining([ - { Item: "OS", Value: `macOS · node ${process.versions.node}` }, - { - Item: "Memory", - Value: - "1 files · 2 chunks · plugin memory · ok(vector ready) · warn(fts ready) · muted(cache warm)", - }, - { Item: "Plugin compatibility", Value: "warn(1 notice · 1 plugin)" }, - { Item: "Sessions", Value: "2 active · default gpt-5.5 (12k ctx) · store.json" }, - ]), + const rows = buildStatusCommandOverviewRows(createStatusCommandOverviewRowsParams()); + + expect(findRowValue(rows, "OS")).toBe(`macOS · node ${process.versions.node}`); + expect(findRowValue(rows, "Memory")).toBe( + "1 files · 2 chunks · plugin memory · ok(vector ready) · warn(fts ready) · muted(cache warm)", + ); + expect(findRowValue(rows, "Plugin compatibility")).toBe("warn(1 notice · 1 plugin)"); + expect(findRowValue(rows, "Sessions")).toBe( + "2 active · default gpt-5.5 (12k ctx) · store.json", ); }); it("marks skipped memory inspection as not checked in fast status output", () => { - expect( - buildStatusCommandOverviewRows( - createStatusCommandOverviewRowsParams({ - memory: null, - memoryPlugin: { enabled: true, slot: "memory-lancedb-pro" }, - }), - ), - ).toEqual( - expect.arrayContaining([ - { - Item: "Memory", - Value: "muted(enabled (plugin memory-lancedb-pro) · not checked)", - }, - ]), + const rows = buildStatusCommandOverviewRows( + createStatusCommandOverviewRowsParams({ + memory: null, + memoryPlugin: { enabled: true, slot: "memory-lancedb-pro" }, + }), + ); + + expect(findRowValue(rows, "Memory")).toBe( + "muted(enabled (plugin memory-lancedb-pro) · not checked)", ); }); it("builds status-all overview rows from the shared surface", () => { - expect( - buildStatusAllOverviewRows({ - surface: { - ...baseStatusOverviewSurface, - tailscaleMode: "off", - tailscaleHttpsUrl: null, - gatewayConnection: { url: "wss://gateway.example.com", urlSource: "config" }, - }, - osLabel: "macOS", - configPath: "/tmp/openclaw.json", - secretDiagnosticsCount: 2, - agentStatus: { - bootstrapPendingCount: 1, - totalSessions: 2, - agents: [{ id: "main", lastActiveAgeMs: 60_000 }], - }, - tailscaleBackendState: "Running", - }), - ).toEqual( - expect.arrayContaining([ - { Item: "Version", Value: VERSION }, - { Item: "OS", Value: "macOS" }, - { Item: "Config", Value: "/tmp/openclaw.json" }, - { Item: "Security", Value: "Run: openclaw security audit --deep" }, - { Item: "Secrets", Value: "2 diagnostics" }, - ]), - ); + const rows = buildStatusAllOverviewRows({ + surface: { + ...baseStatusOverviewSurface, + tailscaleMode: "off", + tailscaleHttpsUrl: null, + gatewayConnection: { url: "wss://gateway.example.com", urlSource: "config" }, + }, + osLabel: "macOS", + configPath: "/tmp/openclaw.json", + secretDiagnosticsCount: 2, + agentStatus: { + bootstrapPendingCount: 1, + totalSessions: 2, + agents: [{ id: "main", lastActiveAgeMs: 60_000 }], + }, + tailscaleBackendState: "Running", + }); + + expect(findRowValue(rows, "Version")).toBe(VERSION); + expect(findRowValue(rows, "OS")).toBe("macOS"); + expect(findRowValue(rows, "Config")).toBe("/tmp/openclaw.json"); + expect(findRowValue(rows, "Security")).toBe("Run: openclaw security audit --deep"); + expect(findRowValue(rows, "Secrets")).toBe("2 diagnostics"); }); }); diff --git a/src/commands/tasks.test.ts b/src/commands/tasks.test.ts index ee5f4daa9a2..659db6563c0 100644 --- a/src/commands/tasks.test.ts +++ b/src/commands/tasks.test.ts @@ -265,10 +265,8 @@ describe("tasks commands", () => { }; expect(payload.maintenance.sessions.pruned).toBe(1); expect(payload.maintenance.sessions.runningCronJobs).toBe(1); - expect(payload.maintenance.sessions.stores[0]).toMatchObject({ - pruned: 1, - preservedRunning: 1, - }); + expect(payload.maintenance.sessions.stores[0]?.pruned).toBe(1); + expect(payload.maintenance.sessions.stores[0]?.preservedRunning).toBe(1); const updated = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record; expect(updated["agent:main:cron:done-job:run:old-run"]).toBeUndefined();