mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-07 07:58:36 +00:00
test(slack): narrow event runtime mocks
This commit is contained in:
@@ -4,18 +4,15 @@ const enqueueSystemEventMock = vi.hoisted(() => vi.fn());
|
||||
let registerSlackChannelEvents: typeof import("./channels.js").registerSlackChannelEvents;
|
||||
let createSlackSystemEventTestHarness: typeof import("./system-event-test-harness.js").createSlackSystemEventTestHarness;
|
||||
|
||||
async function createChannelRuntimeMock() {
|
||||
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/infra-runtime")>(
|
||||
"openclaw/plugin-sdk/infra-runtime",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
enqueueSystemEvent: (...args: unknown[]) => enqueueSystemEventMock(...args),
|
||||
};
|
||||
}
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => enqueueSystemEventMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => enqueueSystemEventMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/security-runtime", () => ({
|
||||
readStoreAllowFromForDmPolicy: async () => [],
|
||||
}));
|
||||
|
||||
type SlackChannelHandler = (args: {
|
||||
event: Record<string, unknown>;
|
||||
|
||||
@@ -17,6 +17,10 @@ vi.mock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => enqueueSystemEventMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/security-runtime", () => ({
|
||||
readStoreAllowFromForDmPolicy: async () => [],
|
||||
}));
|
||||
|
||||
vi.mock("../../interactive-dispatch.js", () => ({
|
||||
dispatchSlackPluginInteractiveHandler: (params: {
|
||||
data: string;
|
||||
|
||||
@@ -7,15 +7,15 @@ let registerSlackMemberEvents: typeof import("./members.js").registerSlackMember
|
||||
let initSlackHarness: typeof import("./system-event-test-harness.js").createSlackSystemEventTestHarness;
|
||||
type MemberOverrides = import("./system-event-test-harness.js").SlackSystemEventTestOverrides;
|
||||
|
||||
async function createChannelRuntimeMock() {
|
||||
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/infra-runtime")>(
|
||||
"openclaw/plugin-sdk/infra-runtime",
|
||||
);
|
||||
return { ...actual, enqueueSystemEvent: memberMocks.enqueue };
|
||||
}
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => memberMocks.enqueue(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => memberMocks.enqueue(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/security-runtime", () => ({
|
||||
readStoreAllowFromForDmPolicy: async () => [],
|
||||
}));
|
||||
|
||||
type MemberHandler = (args: { event: Record<string, unknown>; body: unknown }) => Promise<void>;
|
||||
|
||||
|
||||
@@ -4,31 +4,24 @@ import {
|
||||
type SlackSystemEventTestOverrides,
|
||||
} from "./system-event-test-harness.js";
|
||||
|
||||
const messageQueueMock = vi.fn();
|
||||
const messageAllowMock = vi.fn();
|
||||
const { messageQueueMock, messageAllowMock } = vi.hoisted(() => ({
|
||||
messageQueueMock: vi.fn(),
|
||||
messageAllowMock: vi.fn(),
|
||||
}));
|
||||
|
||||
async function createChannelRuntimeMock() {
|
||||
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/infra-runtime")>(
|
||||
"openclaw/plugin-sdk/infra-runtime",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
enqueueSystemEvent: (...args: unknown[]) => messageQueueMock(...args),
|
||||
};
|
||||
}
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => messageQueueMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => messageQueueMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/security-runtime", () => ({
|
||||
readStoreAllowFromForDmPolicy: async () => [],
|
||||
}));
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", createChannelRuntimeMock);
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/conversation-runtime", async () => {
|
||||
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/conversation-runtime")>(
|
||||
"openclaw/plugin-sdk/conversation-runtime",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
readChannelAllowFromStore: (...args: unknown[]) => messageAllowMock(...args),
|
||||
};
|
||||
});
|
||||
vi.mock("openclaw/plugin-sdk/conversation-runtime", () => ({
|
||||
readChannelAllowFromStore: (...args: unknown[]) => messageAllowMock(...args),
|
||||
}));
|
||||
|
||||
let registerSlackMessageEvents: typeof import("./messages.js").registerSlackMessageEvents;
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@ let registerSlackPinEvents: typeof import("./pins.js").registerSlackPinEvents;
|
||||
let buildPinHarness: typeof import("./system-event-test-harness.js").createSlackSystemEventTestHarness;
|
||||
type PinOverrides = import("./system-event-test-harness.js").SlackSystemEventTestOverrides;
|
||||
|
||||
async function createChannelRuntimeMock() {
|
||||
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/infra-runtime")>(
|
||||
"openclaw/plugin-sdk/infra-runtime",
|
||||
);
|
||||
return { ...actual, enqueueSystemEvent: pinEnqueueMock };
|
||||
}
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => pinEnqueueMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => pinEnqueueMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/security-runtime", () => ({
|
||||
readStoreAllowFromForDmPolicy: async () => [],
|
||||
}));
|
||||
|
||||
type PinHandler = (args: { event: Record<string, unknown>; body: unknown }) => Promise<void>;
|
||||
|
||||
|
||||
@@ -6,18 +6,15 @@ let createSlackSystemEventTestHarness: typeof import("./system-event-test-harnes
|
||||
type SlackSystemEventTestOverrides =
|
||||
import("./system-event-test-harness.js").SlackSystemEventTestOverrides;
|
||||
|
||||
async function createChannelRuntimeMock() {
|
||||
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/infra-runtime")>(
|
||||
"openclaw/plugin-sdk/infra-runtime",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
enqueueSystemEvent: (...args: unknown[]) => reactionQueueMock(...args),
|
||||
};
|
||||
}
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", createChannelRuntimeMock);
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => reactionQueueMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime.js", () => ({
|
||||
enqueueSystemEvent: (...args: unknown[]) => reactionQueueMock(...args),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/security-runtime", () => ({
|
||||
readStoreAllowFromForDmPolicy: async () => [],
|
||||
}));
|
||||
|
||||
type ReactionHandler = (args: { event: Record<string, unknown>; body: unknown }) => Promise<void>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user