mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 17:44:57 +00: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 () => {
|
it("forwards legacy embeds for send", async () => {
|
||||||
sendMessageDiscord.mockClear();
|
sendMessageDiscord.mockClear();
|
||||||
const handleDiscordMessageAction = await loadHandleDiscordMessageAction();
|
|
||||||
|
|
||||||
const embeds = [{ title: "Legacy", description: "Use components v2." }];
|
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 mockRestPatch = vi.hoisted(() => vi.fn());
|
||||||
const mockRestDelete = vi.hoisted(() => vi.fn());
|
const mockRestDelete = vi.hoisted(() => vi.fn());
|
||||||
|
|
||||||
vi.mock("../send.shared.js", () => ({
|
vi.mock("../send.shared.js", async (importOriginal) => {
|
||||||
createDiscordClient: () => ({
|
const actual = await importOriginal<typeof import("../send.shared.js")>();
|
||||||
rest: {
|
return {
|
||||||
post: mockRestPost,
|
...actual,
|
||||||
patch: mockRestPatch,
|
createDiscordClient: () => ({
|
||||||
delete: mockRestDelete,
|
rest: {
|
||||||
},
|
post: mockRestPost,
|
||||||
request: (_fn: () => Promise<unknown>, _label: string) => _fn(),
|
patch: mockRestPatch,
|
||||||
}),
|
delete: mockRestDelete,
|
||||||
}));
|
},
|
||||||
|
request: (_fn: () => Promise<unknown>, _label: string) => _fn(),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
vi.mock("../../gateway/client.js", () => ({
|
vi.mock("../../gateway/client.js", () => ({
|
||||||
GatewayClient: class {
|
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;
|
return mocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user