From d28349c48e8b24aaba1100d66e0d02a3d2ce666a Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 30 Mar 2026 12:07:35 +0900 Subject: [PATCH] fix(test): align channel mocks with runtime exports --- .../native-command.model-picker.test.ts | 4 +- .../src/auto-reply/heartbeat-runner.test.ts | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/extensions/discord/src/monitor/native-command.model-picker.test.ts b/extensions/discord/src/monitor/native-command.model-picker.test.ts index 190383b8b34..de8d0d6d036 100644 --- a/extensions/discord/src/monitor/native-command.model-picker.test.ts +++ b/extensions/discord/src/monitor/native-command.model-picker.test.ts @@ -5,7 +5,7 @@ import type { ModelsProviderData } from "openclaw/plugin-sdk/command-auth"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import * as dispatcherModule from "openclaw/plugin-sdk/reply-runtime"; import * as globalsModule from "openclaw/plugin-sdk/runtime-env"; -import * as timeoutModule from "openclaw/plugin-sdk/runtime-env"; +import * as commandTextModule from "openclaw/plugin-sdk/text-runtime"; import { beforeEach, describe, expect, it, vi } from "vitest"; import * as modelPickerPreferencesModule from "./model-picker-preferences.js"; import * as modelPickerModule from "./model-picker.js"; @@ -331,7 +331,7 @@ describe("Discord model picker interactions", () => { .mockResolvedValue(); const dispatchSpy = createDispatchSpy(); const withTimeoutSpy = vi - .spyOn(timeoutModule, "withTimeout") + .spyOn(commandTextModule, "withTimeout") .mockRejectedValue(new Error("timeout")); await runModelSelect({ context }); diff --git a/extensions/whatsapp/src/auto-reply/heartbeat-runner.test.ts b/extensions/whatsapp/src/auto-reply/heartbeat-runner.test.ts index 87bbc6a8666..583dca1ba1e 100644 --- a/extensions/whatsapp/src/auto-reply/heartbeat-runner.test.ts +++ b/extensions/whatsapp/src/auto-reply/heartbeat-runner.test.ts @@ -41,14 +41,6 @@ vi.mock("../../../../src/channels/plugins/whatsapp-heartbeat.js", () => ({ resolveWhatsAppHeartbeatRecipients: () => [], })); -vi.mock("openclaw/plugin-sdk/config-runtime", async (importOriginal) => { - const actual = await importOriginal(); - return { - ...actual, - loadConfig: () => ({ agents: { defaults: {} }, session: {} }), - }; -}); - vi.mock("openclaw/plugin-sdk/routing", async (importOriginal) => { const actual = await importOriginal(); return { @@ -91,18 +83,27 @@ vi.mock("openclaw/plugin-sdk/text-runtime", async (importOriginal) => { }; }); -vi.mock("openclaw/plugin-sdk/reply-runtime", () => ({ - getReplyFromConfig: vi.fn(async () => undefined), -})); +vi.mock("openclaw/plugin-sdk/reply-runtime", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + getReplyFromConfig: vi.fn(async () => undefined), + }; +}); -vi.mock("openclaw/plugin-sdk/config-runtime", () => ({ - loadSessionStore: () => state.store, - resolveSessionKey: () => "k", - resolveStorePath: () => "/tmp/store.json", - updateSessionStore: async (_path: string, updater: (store: typeof state.store) => void) => { - updater(state.store); - }, -})); +vi.mock("openclaw/plugin-sdk/config-runtime", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + loadConfig: () => ({ agents: { defaults: {} }, session: {} }), + loadSessionStore: () => state.store, + resolveSessionKey: () => "k", + resolveStorePath: () => "/tmp/store.json", + updateSessionStore: async (_path: string, updater: (store: typeof state.store) => void) => { + updater(state.store); + }, + }; +}); vi.mock("./session-snapshot.js", () => ({ getSessionSnapshot: () => state.snapshot,