mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
test(discord): fix updated test harness mocks
This commit is contained in:
@@ -69,7 +69,6 @@ describe("handleDiscordMessageAction", () => {
|
||||
|
||||
it("forwards legacy embeds for send", async () => {
|
||||
sendMessageDiscord.mockClear();
|
||||
const handleDiscordMessageAction = await loadHandleDiscordMessageAction();
|
||||
|
||||
const embeds = [{ title: "Legacy", description: "Use components v2." }];
|
||||
|
||||
|
||||
@@ -29,16 +29,20 @@ const mockRestPost = vi.hoisted(() => vi.fn());
|
||||
const mockRestPatch = vi.hoisted(() => vi.fn());
|
||||
const mockRestDelete = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../send.shared.js", () => ({
|
||||
createDiscordClient: () => ({
|
||||
rest: {
|
||||
post: mockRestPost,
|
||||
patch: mockRestPatch,
|
||||
delete: mockRestDelete,
|
||||
},
|
||||
request: (_fn: () => Promise<unknown>, _label: string) => _fn(),
|
||||
}),
|
||||
}));
|
||||
vi.mock("../send.shared.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../send.shared.js")>();
|
||||
return {
|
||||
...actual,
|
||||
createDiscordClient: () => ({
|
||||
rest: {
|
||||
post: mockRestPost,
|
||||
patch: mockRestPatch,
|
||||
delete: mockRestDelete,
|
||||
},
|
||||
request: (_fn: () => Promise<unknown>, _label: string) => _fn(),
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../../gateway/client.js", () => ({
|
||||
GatewayClient: class {
|
||||
|
||||
@@ -28,7 +28,14 @@ vi.mock("../../agents/identity.js", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
export function getSlackSlashMocks() {
|
||||
type SlashHarnessMocks = {
|
||||
dispatchMock: ReturnType<typeof vi.fn>;
|
||||
readAllowFromStoreMock: ReturnType<typeof vi.fn>;
|
||||
upsertPairingRequestMock: ReturnType<typeof vi.fn>;
|
||||
resolveAgentRouteMock: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
|
||||
export function getSlackSlashMocks(): SlashHarnessMocks {
|
||||
return mocks;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user