Tests: cover Slack interactive reply capability gating

This commit is contained in:
Vincent Koc
2026-03-12 23:42:46 -04:00
parent 6585f6f608
commit 177165559e
3 changed files with 68 additions and 1 deletions

View File

@@ -137,6 +137,46 @@ describe("slackPlugin outbound", () => {
});
});
describe("slackPlugin agentPrompt", () => {
it("tells agents interactive replies are disabled by default", () => {
const hints = slackPlugin.agentPrompt?.messageToolHints?.({
cfg: {
channels: {
slack: {
botToken: "xoxb-test",
appToken: "xapp-test",
},
},
},
});
expect(hints).toEqual([
"- Slack interactive replies are disabled. If needed, ask to set `channels.slack.capabilities.interactiveReplies=true` (or the same under `channels.slack.accounts.<account>.capabilities`).",
]);
});
it("shows Slack interactive reply directives when enabled", () => {
const hints = slackPlugin.agentPrompt?.messageToolHints?.({
cfg: {
channels: {
slack: {
botToken: "xoxb-test",
appToken: "xapp-test",
capabilities: { interactiveReplies: true },
},
},
},
});
expect(hints).toContain(
"- Slack interactive replies: use `[[slack_buttons: Label:value, Other:other]]` to add action buttons that route clicks back as Slack interaction system events.",
);
expect(hints).toContain(
"- Slack selects: use `[[slack_select: Placeholder | Label:value, Other:other]]` to add a static select menu that routes the chosen value back as a Slack interaction system event.",
);
});
});
describe("slackPlugin config", () => {
it("treats HTTP mode accounts with bot token + signing secret as configured", async () => {
const cfg: OpenClawConfig = {

View File

@@ -151,12 +151,22 @@ describe("normalizeReplyPayload", () => {
expect(result!.mediaUrl).toBe("https://example.com/img.png");
});
it("does not compile Slack directives unless interactive replies are enabled", () => {
const result = normalizeReplyPayload({
text: "hello [[slack_buttons: Retry:retry, Ignore:ignore]]",
});
expect(result).not.toBeNull();
expect(result!.text).toBe("hello [[slack_buttons: Retry:retry, Ignore:ignore]]");
expect(result!.channelData).toBeUndefined();
});
it("applies responsePrefix before compiling Slack directives into blocks", () => {
const result = normalizeReplyPayload(
{
text: "hello [[slack_buttons: Retry:retry, Ignore:ignore]]",
},
{ responsePrefix: "[bot]" },
{ responsePrefix: "[bot]", enableSlackInteractiveReplies: true },
);
expect(result).not.toBeNull();

View File

@@ -125,6 +125,23 @@ describe("resolveChannelCapabilities", () => {
}),
).toBeUndefined();
});
it("handles Slack object-format capabilities gracefully", () => {
const cfg = {
channels: {
slack: {
capabilities: { interactiveReplies: true },
},
},
} as unknown as Partial<OpenClawConfig>;
expect(
resolveChannelCapabilities({
cfg,
channel: "slack",
}),
).toBeUndefined();
});
});
const createStubPlugin = (id: string): ChannelPlugin => ({