diff --git a/extensions/zalo/src/monitor.webhook.test.ts b/extensions/zalo/src/monitor.webhook.test.ts index 988d36a42dd..7dbf632f2da 100644 --- a/extensions/zalo/src/monitor.webhook.test.ts +++ b/extensions/zalo/src/monitor.webhook.test.ts @@ -1,7 +1,7 @@ import type { RequestListener } from "node:http"; -import { createEmptyPluginRegistry } from "openclaw/plugin-sdk/testing"; -import { setActivePluginRegistry } from "openclaw/plugin-sdk/testing"; import { afterEach, describe, expect, it, vi } from "vitest"; +import { createEmptyPluginRegistry } from "../../../src/plugins/registry-empty.js"; +import { setActivePluginRegistry } from "../../../src/plugins/runtime.js"; import { withServer } from "../../../test/helpers/http-test-server.js"; import type { OpenClawConfig, PluginRuntime } from "../runtime-api.js"; import { diff --git a/extensions/zalo/test-support/lifecycle-test-support.ts b/extensions/zalo/test-support/lifecycle-test-support.ts index 1e81ca75c5e..b5a28f23ddd 100644 --- a/extensions/zalo/test-support/lifecycle-test-support.ts +++ b/extensions/zalo/test-support/lifecycle-test-support.ts @@ -1,7 +1,6 @@ import { request as httpRequest } from "node:http"; import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk/zalo"; import { expect, vi } from "vitest"; -import { createPluginRuntimeMock } from "../../../test/helpers/plugins/plugin-runtime-mock.js"; import type { ResolvedZaloAccount } from "../src/types.js"; export function createLifecycleConfig(params: { @@ -123,8 +122,30 @@ export function createImageLifecycleCore() { path: "/tmp/zalo-photo.jpg", contentType: "image/jpeg", })); - const core = createPluginRuntimeMock({ + const core = { channel: { + routing: { + resolveAgentRoute: vi.fn(() => ({ + agentId: "main", + accountId: "default", + sessionKey: "agent:main:zalo:direct:chat-123", + })) as unknown as PluginRuntime["channel"]["routing"]["resolveAgentRoute"], + }, + session: { + resolveStorePath: vi.fn( + () => "/tmp/zalo-sessions.json", + ) as unknown as PluginRuntime["channel"]["session"]["resolveStorePath"], + readSessionUpdatedAt: vi.fn( + () => undefined, + ) as unknown as PluginRuntime["channel"]["session"]["readSessionUpdatedAt"], + recordInboundSession: + recordInboundSessionMock as unknown as PluginRuntime["channel"]["session"]["recordInboundSession"], + }, + text: { + resolveMarkdownTableMode: vi.fn( + () => "code", + ) as unknown as PluginRuntime["channel"]["text"]["resolveMarkdownTableMode"], + }, media: { fetchRemoteMedia: fetchRemoteMediaMock as unknown as PluginRuntime["channel"]["media"]["fetchRemoteMedia"], @@ -134,14 +155,16 @@ export function createImageLifecycleCore() { reply: { finalizeInboundContext: finalizeInboundContextMock as unknown as PluginRuntime["channel"]["reply"]["finalizeInboundContext"], + resolveEnvelopeFormatOptions: vi.fn(() => ({ + template: "channel+name+time", + })) as unknown as PluginRuntime["channel"]["reply"]["resolveEnvelopeFormatOptions"], + formatAgentEnvelope: vi.fn( + (opts: { body: string }) => opts.body, + ) as unknown as PluginRuntime["channel"]["reply"]["formatAgentEnvelope"], dispatchReplyWithBufferedBlockDispatcher: vi.fn( async () => undefined, ) as unknown as PluginRuntime["channel"]["reply"]["dispatchReplyWithBufferedBlockDispatcher"], }, - session: { - recordInboundSession: - recordInboundSessionMock as unknown as PluginRuntime["channel"]["session"]["recordInboundSession"], - }, commands: { shouldComputeCommandAuthorized: vi.fn( () => false, @@ -154,7 +177,7 @@ export function createImageLifecycleCore() { ) as unknown as PluginRuntime["channel"]["commands"]["isControlCommandMessage"], }, }, - }); + } as PluginRuntime; return { core, finalizeInboundContextMock,