test(runtime): fix stale harness and registry mocks

This commit is contained in:
Peter Steinberger
2026-04-07 01:15:59 +01:00
parent b8c8139138
commit 017c25b075
4 changed files with 20 additions and 23 deletions

View File

@@ -1,10 +1,7 @@
import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk/channel-contract";
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
import {
loadBundledPluginTestApiSync,
primeChannelOutboundSendMock,
} from "openclaw/plugin-sdk/testing";
import { primeChannelOutboundSendMock } from "openclaw/plugin-sdk/testing";
import { vi, type Mock } from "vitest";
import { slackOutbound } from "./outbound-adapter.js";
type OutboundSendMock = Mock<(...args: unknown[]) => Promise<Record<string, unknown>>>;
@@ -14,17 +11,6 @@ type SlackOutboundPayloadHarness = {
to: string;
};
let slackOutboundCache: ChannelOutboundAdapter | undefined;
function getSlackOutbound(): ChannelOutboundAdapter {
if (!slackOutboundCache) {
({ slackOutbound: slackOutboundCache } = loadBundledPluginTestApiSync<{
slackOutbound: ChannelOutboundAdapter;
}>("slack"));
}
return slackOutboundCache;
}
export function createSlackOutboundPayloadHarness(params: {
payload: ReplyPayload;
sendResults?: Array<{ messageId: string }>;
@@ -45,7 +31,7 @@ export function createSlackOutboundPayloadHarness(params: {
},
};
return {
run: async () => await getSlackOutbound().sendPayload!(ctx),
run: async () => await slackOutbound.sendPayload!(ctx),
sendMock: sendSlack,
to: ctx.to,
};