mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 02:41:07 +00:00
refactor: route more runtime-boundary tests through public seams
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
export type { ResolvedSlackAccount } from "./src/accounts.js";
|
||||
export type { SlackMessageEvent } from "./src/types.js";
|
||||
export { createSlackActions } from "./src/channel-actions.js";
|
||||
export { prepareSlackMessage } from "./src/monitor/message-handler/prepare.js";
|
||||
export { createInboundSlackTestContext } from "./src/monitor/message-handler/prepare.test-helpers.js";
|
||||
export { sendMessageSlack } from "./src/send.js";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export { buildTelegramMessageContextForTest } from "./src/bot-message-context.test-harness.js";
|
||||
export { handleTelegramAction } from "./src/action-runtime.js";
|
||||
export { telegramMessageActionRuntime } from "./src/channel-actions.js";
|
||||
export { sendMessageTelegram, sendPollTelegram, type TelegramApiOverride } from "./src/send.js";
|
||||
|
||||
@@ -14,7 +14,7 @@ const webMocks = vi.hoisted(() => ({
|
||||
readWebSelfId: vi.fn().mockReturnValue({ e164: "+1999" }),
|
||||
}));
|
||||
|
||||
vi.mock("../../extensions/whatsapp/src/session.js", () => webMocks);
|
||||
vi.mock("../../extensions/whatsapp/runtime-api.js", () => webMocks);
|
||||
|
||||
import { getReplyFromConfig } from "./reply.js";
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ const handleSlackAction = vi.hoisted(() => vi.fn(async (..._args: unknown[]) =>
|
||||
let discordMessageActions: typeof import("../../../../extensions/discord/runtime-api.js").discordMessageActions;
|
||||
let handleDiscordMessageAction: typeof import("./discord/handle-action.js").handleDiscordMessageAction;
|
||||
let telegramMessageActions: typeof import("../../../../extensions/telegram/runtime-api.js").telegramMessageActions;
|
||||
let signalMessageActions: typeof import("../../../../extensions/signal/src/message-actions.js").signalMessageActions;
|
||||
let createSlackActions: typeof import("../../../../extensions/slack/src/channel-actions.js").createSlackActions;
|
||||
let discordRuntimeModule: typeof import("../../../../extensions/discord/src/actions/runtime.js");
|
||||
let telegramChannelActionsModule: typeof import("../../../../extensions/telegram/src/channel-actions.js");
|
||||
let signalReactionModule: typeof import("../../../../extensions/signal/src/send-reactions.js");
|
||||
let signalMessageActions: typeof import("../../../../extensions/signal/api.js").signalMessageActions;
|
||||
let createSlackActions: typeof import("../../../../extensions/slack/test-api.js").createSlackActions;
|
||||
let discordRuntimeModule: typeof import("../../../../extensions/discord/runtime-api.js");
|
||||
let telegramTestApiModule: typeof import("../../../../extensions/telegram/test-api.js");
|
||||
let signalReactionModule: typeof import("../../../../extensions/signal/api.js");
|
||||
|
||||
function getDescribedActions(params: {
|
||||
describeMessageTool?: ChannelMessageActionAdapter["describeMessageTool"];
|
||||
@@ -198,13 +198,12 @@ beforeAll(async () => {
|
||||
vi.resetModules();
|
||||
({ discordMessageActions } = await import("../../../../extensions/discord/runtime-api.js"));
|
||||
({ handleDiscordMessageAction } = await import("./discord/handle-action.js"));
|
||||
discordRuntimeModule = await import("../../../../extensions/discord/src/actions/runtime.js");
|
||||
discordRuntimeModule = await import("../../../../extensions/discord/runtime-api.js");
|
||||
({ telegramMessageActions } = await import("../../../../extensions/telegram/runtime-api.js"));
|
||||
telegramChannelActionsModule =
|
||||
await import("../../../../extensions/telegram/src/channel-actions.js");
|
||||
({ signalMessageActions } = await import("../../../../extensions/signal/src/message-actions.js"));
|
||||
signalReactionModule = await import("../../../../extensions/signal/src/send-reactions.js");
|
||||
({ createSlackActions } = await import("../../../../extensions/slack/src/channel-actions.js"));
|
||||
telegramTestApiModule = await import("../../../../extensions/telegram/test-api.js");
|
||||
({ signalMessageActions } = await import("../../../../extensions/signal/api.js"));
|
||||
signalReactionModule = await import("../../../../extensions/signal/api.js");
|
||||
({ createSlackActions } = await import("../../../../extensions/slack/test-api.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -213,9 +212,8 @@ beforeEach(() => {
|
||||
vi.spyOn(discordRuntimeModule, "handleDiscordAction").mockImplementation(
|
||||
async (...args) => await handleDiscordAction(...args),
|
||||
);
|
||||
telegramChannelActionsModule.telegramMessageActionRuntime.handleTelegramAction = async (
|
||||
...args
|
||||
) => await handleTelegramAction(...args);
|
||||
telegramTestApiModule.telegramMessageActionRuntime.handleTelegramAction = async (...args) =>
|
||||
await handleTelegramAction(...args);
|
||||
vi.spyOn(signalReactionModule, "sendReactionSignal").mockImplementation(
|
||||
async (...args) => await sendReactionSignal(...args),
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
|
||||
vi.mock("../../../../extensions/slack/src/send.js", () => ({
|
||||
vi.mock("../../../../extensions/slack/test-api.js", () => ({
|
||||
sendMessageSlack: vi.fn().mockResolvedValue({ messageId: "1234.5678", channelId: "C123" }),
|
||||
}));
|
||||
|
||||
@@ -10,7 +10,7 @@ vi.mock("openclaw/plugin-sdk/plugin-runtime", () => ({
|
||||
}));
|
||||
|
||||
import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
||||
import { sendMessageSlack } from "../../../../extensions/slack/src/send.js";
|
||||
import { sendMessageSlack } from "../../../../extensions/slack/test-api.js";
|
||||
import { slackOutbound } from "../../../../test/channel-outbounds.js";
|
||||
|
||||
type SlackSendTextCtx = {
|
||||
|
||||
@@ -316,7 +316,7 @@ vi.mock("../channels/plugins/index.js", () => ({
|
||||
},
|
||||
] as unknown,
|
||||
}));
|
||||
vi.mock("../../extensions/whatsapp/src/session.js", () => ({
|
||||
vi.mock("../../extensions/whatsapp/runtime-api.js", () => ({
|
||||
webAuthExists: mocks.webAuthExists,
|
||||
getWebAuthAgeMs: mocks.getWebAuthAgeMs,
|
||||
readWebSelfId: mocks.readWebSelfId,
|
||||
|
||||
Reference in New Issue
Block a user