Skip to content

Commit f874925

Browse files
authored
test(whatsapp): initialize runtime in auto-reply harness (#105760)
1 parent b7a7f3f commit f874925

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎extensions/whatsapp/src/auto-reply.test-harness.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { EventEmitter } from "node:events";
44
import fs from "node:fs/promises";
55
import os from "node:os";
66
import path from "node:path";
7+
import { createPluginRuntimeMock } from "openclaw/plugin-sdk/plugin-test-runtime";
78
import { resetInboundDedupe } from "openclaw/plugin-sdk/reply-runtime";
89
import { resetLogger, setLoggerOverride } from "openclaw/plugin-sdk/runtime-env";
910
import { mockPinnedHostnameResolution } from "openclaw/plugin-sdk/test-env";
@@ -13,6 +14,7 @@ import type { WebInboundMessageInput, WebListenerCloseReason } from "./inbound.j
1314
import type { WhatsAppSendResult } from "./inbound/send-result.js";
1415
import { createAcceptedWhatsAppSendResult as createAcceptedWhatsAppSendResultForHarness } from "./inbound/send-result.test-helper.js";
1516
import { createTestWebInboundMessage } from "./inbound/test-message.test-helper.js";
17+
import { setWhatsAppRuntime } from "./runtime.js";
1618
import {
1719
resetBaileysMocks as _resetBaileysMocks,
1820
resetLoadConfigMock as _resetLoadConfigMock,
@@ -224,6 +226,8 @@ export function installWebAutoReplyUnitTestHooks(opts?: { pinDns?: boolean }) {
224226
resetWebAutoReplySessionSockets();
225227
_resetBaileysMocks();
226228
_resetLoadConfigMock();
229+
// Scoped test files must seed the plugin slot instead of inheriting another file's runtime.
230+
setWhatsAppRuntime(createPluginRuntimeMock());
227231
if (opts?.pinDns) {
228232
resolvePinnedHostnameSpy = mockPinnedHostnameResolution([TEST_NET_IP]);
229233
}

0 commit comments

Comments
 (0)