Discord: preserve accountId in message actions (refs #1489)
This commit is contained in:
committed by
Peter Steinberger
parent
3de5ea818d
commit
c5546f0d5b
@@ -1,11 +1,41 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { ClawdbotConfig } from "../../../config/config.js";
|
||||
import { discordMessageActions } from "./discord.js";
|
||||
type SendMessageDiscord = typeof import("../../../discord/send.js").sendMessageDiscord;
|
||||
type SendPollDiscord = typeof import("../../../discord/send.js").sendPollDiscord;
|
||||
|
||||
const sendMessageDiscord = vi.fn<Parameters<SendMessageDiscord>, ReturnType<SendMessageDiscord>>(
|
||||
async () => ({ ok: true }) as Awaited<ReturnType<SendMessageDiscord>>,
|
||||
);
|
||||
const sendPollDiscord = vi.fn<Parameters<SendPollDiscord>, ReturnType<SendPollDiscord>>(
|
||||
async () => ({ ok: true }) as Awaited<ReturnType<SendPollDiscord>>,
|
||||
);
|
||||
|
||||
vi.mock("../../../discord/send.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../../../discord/send.js")>(
|
||||
"../../../discord/send.js",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
sendMessageDiscord: (...args: Parameters<SendMessageDiscord>) => sendMessageDiscord(...args),
|
||||
sendPollDiscord: (...args: Parameters<SendPollDiscord>) => sendPollDiscord(...args),
|
||||
};
|
||||
});
|
||||
|
||||
const loadHandleDiscordMessageAction = async () => {
|
||||
const mod = await import("./discord/handle-action.js");
|
||||
return mod.handleDiscordMessageAction;
|
||||
};
|
||||
|
||||
const loadDiscordMessageActions = async () => {
|
||||
const mod = await import("./discord.js");
|
||||
return mod.discordMessageActions;
|
||||
};
|
||||
|
||||
describe("discord message actions", () => {
|
||||
it("lists channel and upload actions by default", () => {
|
||||
it("lists channel and upload actions by default", async () => {
|
||||
const cfg = { channels: { discord: { token: "d0" } } } as ClawdbotConfig;
|
||||
const discordMessageActions = await loadDiscordMessageActions();
|
||||
const actions = discordMessageActions.listActions?.({ cfg }) ?? [];
|
||||
|
||||
expect(actions).toContain("emoji-upload");
|
||||
@@ -13,10 +43,11 @@ describe("discord message actions", () => {
|
||||
expect(actions).toContain("channel-create");
|
||||
});
|
||||
|
||||
it("respects disabled channel actions", () => {
|
||||
it("respects disabled channel actions", async () => {
|
||||
const cfg = {
|
||||
channels: { discord: { token: "d0", actions: { channels: false } } },
|
||||
} as ClawdbotConfig;
|
||||
const discordMessageActions = await loadDiscordMessageActions();
|
||||
const actions = discordMessageActions.listActions?.({ cfg }) ?? [];
|
||||
|
||||
expect(actions).not.toContain("channel-create");
|
||||
|
||||
Reference in New Issue
Block a user