test(discord): fix updated test harness mocks

This commit is contained in:
Sebastian
2026-02-15 11:44:39 -05:00
parent 10feda100e
commit 6277698f86
3 changed files with 22 additions and 12 deletions

View File

@@ -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." }];

View File

@@ -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 {

View File

@@ -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;
}