From c0a16650d5d384317ae166a6d113c7b731f0d4b3 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 17 Apr 2026 16:46:36 +0100 Subject: [PATCH] test(commands): fix command fixture typing --- src/commands/agent.acp.test.ts | 8 +++++--- src/commands/channel-setup/plugin-install.test.ts | 2 +- src/commands/message.test.ts | 1 + src/commands/status.test.ts | 9 +++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/commands/agent.acp.test.ts b/src/commands/agent.acp.test.ts index 2a1b9057c7a..6903a040d7f 100644 --- a/src/commands/agent.acp.test.ts +++ b/src/commands/agent.acp.test.ts @@ -4,6 +4,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import "./agent-command.test-mocks.js"; import * as acpManagerModule from "../acp/control-plane/manager.js"; +import { AcpRuntimeError } from "../acp/runtime/errors.js"; import * as embeddedModule from "../agents/pi-embedded.js"; import * as configIoModule from "../config/io.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; @@ -401,9 +402,10 @@ describe("agentCommand ACP runtime routing", () => { return { kind: "stale", sessionKey, - error: Object.assign(new Error(`ACP metadata is missing for session ${sessionKey}.`), { - code: "ACP_SESSION_INIT_FAILED", - }), + error: new AcpRuntimeError( + "ACP_SESSION_INIT_FAILED", + `ACP metadata is missing for session ${sessionKey}.`, + ), }; }, }); diff --git a/src/commands/channel-setup/plugin-install.test.ts b/src/commands/channel-setup/plugin-install.test.ts index f62b73cb5e3..ff30abdf7a3 100644 --- a/src/commands/channel-setup/plugin-install.test.ts +++ b/src/commands/channel-setup/plugin-install.test.ts @@ -30,7 +30,7 @@ vi.mock("../../config/plugin-auto-enable.js", () => ({ const resolveBundledPluginSources = vi.fn(); const getChannelPluginCatalogEntry = vi.fn(); -const listChannelPluginCatalogEntries = vi.fn(() => []); +const listChannelPluginCatalogEntries = vi.fn((..._args: unknown[]) => []); vi.mock("../../channels/plugins/catalog.js", () => { return { getChannelPluginCatalogEntry: (...args: unknown[]) => getChannelPluginCatalogEntry(...args), diff --git a/src/commands/message.test.ts b/src/commands/message.test.ts index 9f937bd4334..a975be8bcf8 100644 --- a/src/commands/message.test.ts +++ b/src/commands/message.test.ts @@ -4,6 +4,7 @@ import type { RuntimeEnv } from "../runtime.js"; import { captureEnv } from "../test-utils/env.js"; type RunMessageActionParams = { + cfg?: unknown; action: string; params: Record; }; diff --git a/src/commands/status.test.ts b/src/commands/status.test.ts index b9d9d2318dc..1dd5eb9c30f 100644 --- a/src/commands/status.test.ts +++ b/src/commands/status.test.ts @@ -25,6 +25,7 @@ function createDefaultSessionStoreEntry() { cacheRead: 2_000, cacheWrite: 1_000, totalTokens: 5_000, + totalTokensFresh: true as boolean, contextTokens: 10_000, model: "pi:opus", sessionId: "abc123", @@ -188,7 +189,11 @@ async function createStatusServiceSummary( } function createSessionStatusRows() { - const agents = mocks.listGatewayAgentsBasic().agents ?? [{ id: "main", name: "Main" }]; + const agents = (mocks.listGatewayAgentsBasic().agents ?? [ + { id: "main", name: "Main" }, + ]) as Array<{ + id: string; + }>; const byAgent = agents.map((agent: { id: string }) => { const path = mocks.resolveStorePath("sessions", { agentId: agent.id }); const store = mocks.loadSessionStore(path) as Record< @@ -198,7 +203,7 @@ function createSessionStatusRows() { const recent = Object.entries(store).map(([key, entry]) => { const contextTokens = typeof entry.contextTokens === "number" ? entry.contextTokens : null; const freshTotal = - typeof entry.totalTokens === "number" && entry.totalTokensFresh !== false + typeof entry.totalTokens === "number" && (entry.totalTokensFresh ?? true) ? entry.totalTokens : null; return {