diff --git a/src/infra/outbound/message-action-normalization.test.ts b/src/infra/outbound/message-action-normalization.test.ts index ef2f8c3ca76..6ea00a526c2 100644 --- a/src/infra/outbound/message-action-normalization.test.ts +++ b/src/infra/outbound/message-action-normalization.test.ts @@ -1,21 +1,10 @@ import { describe, expect, it, vi } from "vitest"; import { normalizeMessageActionInput } from "./message-action-normalization.js"; -vi.mock("../../channels/plugins/bootstrap-registry.js", () => ({ - getBootstrapChannelPlugin: (channel: string) => - channel === "feishu" - ? { - actions: { - messageActionTargetAliases: { - read: { aliases: ["messageId"] }, - pin: { aliases: ["messageId"] }, - unpin: { aliases: ["messageId"] }, - "list-pins": { aliases: ["chatId"] }, - "channel-info": { aliases: ["chatId"] }, - }, - }, - } - : undefined, +vi.mock("../../channels/plugins/bootstrap-registry.js", async () => ({ + getBootstrapChannelPlugin: ( + await import("./message-action-test-fixtures.js") + ).createFeishuMessageActionBootstrapRegistryMock(), })); describe("normalizeMessageActionInput", () => { diff --git a/src/infra/outbound/message-action-spec.test.ts b/src/infra/outbound/message-action-spec.test.ts index d9115fcc8b1..a2b9cf1f7c3 100644 --- a/src/infra/outbound/message-action-spec.test.ts +++ b/src/infra/outbound/message-action-spec.test.ts @@ -1,21 +1,10 @@ import { describe, expect, it, vi } from "vitest"; import { actionHasTarget, actionRequiresTarget } from "./message-action-spec.js"; -vi.mock("../../channels/plugins/bootstrap-registry.js", () => ({ - getBootstrapChannelPlugin: (channel: string) => - channel === "feishu" - ? { - actions: { - messageActionTargetAliases: { - read: { aliases: ["messageId"] }, - pin: { aliases: ["messageId"] }, - unpin: { aliases: ["messageId"] }, - "list-pins": { aliases: ["chatId"] }, - "channel-info": { aliases: ["chatId"] }, - }, - }, - } - : undefined, +vi.mock("../../channels/plugins/bootstrap-registry.js", async () => ({ + getBootstrapChannelPlugin: ( + await import("./message-action-test-fixtures.js") + ).createFeishuMessageActionBootstrapRegistryMock(), })); describe("actionRequiresTarget", () => { diff --git a/src/infra/outbound/message-action-test-fixtures.ts b/src/infra/outbound/message-action-test-fixtures.ts new file mode 100644 index 00000000000..184e902ee80 --- /dev/null +++ b/src/infra/outbound/message-action-test-fixtures.ts @@ -0,0 +1,16 @@ +export function createFeishuMessageActionBootstrapRegistryMock() { + return (channel: string) => + channel === "feishu" + ? { + actions: { + messageActionTargetAliases: { + read: { aliases: ["messageId"] }, + pin: { aliases: ["messageId"] }, + unpin: { aliases: ["messageId"] }, + "list-pins": { aliases: ["chatId"] }, + "channel-info": { aliases: ["chatId"] }, + }, + }, + } + : undefined; +}