diff --git a/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts b/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts index a40a91b09a..2255443a07 100644 --- a/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts +++ b/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts @@ -139,7 +139,7 @@ describe("gateway server chat", () => { test("chat.send does not force-disable block streaming", async () => { await withGatewayChatHarness(async ({ ws, createSessionDir }) => { - const spy = vi.mocked(getReplyFromConfig) as unknown as ReturnType; + const spy = getReplyFromConfig; await connectOk(ws); await createSessionDir(); @@ -288,7 +288,7 @@ describe("gateway server chat", () => { test("smoke: supports abort and idempotent completion", async () => { await withGatewayChatHarness(async ({ ws, createSessionDir }) => { - const spy = vi.mocked(getReplyFromConfig) as unknown as ReturnType; + const spy = getReplyFromConfig; let aborted = false; await connectOk(ws); diff --git a/src/gateway/test-helpers.mocks.ts b/src/gateway/test-helpers.mocks.ts index 5ebdc7859e..19c6d2e91a 100644 --- a/src/gateway/test-helpers.mocks.ts +++ b/src/gateway/test-helpers.mocks.ts @@ -4,7 +4,10 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { Mock, vi } from "vitest"; +import type { MsgContext } from "../auto-reply/templating.js"; +import type { GetReplyOptions, ReplyPayload } from "../auto-reply/types.js"; import type { ChannelPlugin, ChannelOutboundAdapter } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js"; import type { AgentBinding } from "../config/types.agents.js"; import type { HooksConfig } from "../config/types.hooks.js"; @@ -19,6 +22,12 @@ type StubChannelOptions = { summary?: Record; }; +type GetReplyFromConfigFn = ( + ctx: MsgContext, + opts?: GetReplyOptions, + configOverride?: OpenClawConfig, +) => Promise; + const createStubOutboundAdapter = (channelId: ChannelPlugin["id"]): ChannelOutboundAdapter => ({ deliveryMode: "direct", sendText: async () => ({ @@ -169,7 +178,7 @@ const hoisted = vi.hoisted(() => ({ waitResults: new Map(), }, testTailscaleWhois: { value: null as TailscaleWhoisIdentity | null }, - getReplyFromConfig: vi.fn().mockResolvedValue(undefined), + getReplyFromConfig: vi.fn().mockResolvedValue(undefined), sendWhatsAppMock: vi.fn().mockResolvedValue({ messageId: "msg-1", toJid: "jid-1" }), })); @@ -202,7 +211,7 @@ export const testTailscaleWhois = hoisted.testTailscaleWhois; export const piSdkMock = hoisted.piSdkMock; export const cronIsolatedRun = hoisted.cronIsolatedRun; export const agentCommand: Mock<() => void> = hoisted.agentCommand; -export const getReplyFromConfig: Mock<() => void> = hoisted.getReplyFromConfig; +export const getReplyFromConfig: Mock = hoisted.getReplyFromConfig; export const testState = { agentConfig: undefined as Record | undefined,