Files
openclaw/extensions/slack/src/resolve-channels.test.ts
kevinlin-openai 245b91b83d feat(slack): support Enterprise Grid org installs (#102372)
* feat(slack): support Enterprise Grid org installs

* docs: refresh generated docs map

* fix(slack): satisfy enterprise routing CI

* fix(slack): accept org auth without app id

* docs(plugin-sdk): document channel policy hooks

* fix(slack): reuse canonical sender for enterprise replies

* test(slack): fix enterprise sender lint

---------

Co-authored-by: Kevin Lin <kevin@dendron.so>
2026-07-08 23:53:19 -07:00

56 lines
1.6 KiB
TypeScript

// Slack tests cover resolve channels plugin behavior.
import { describe, expect, it, vi } from "vitest";
import { resolveSlackChannelAllowlist } from "./resolve-channels.js";
describe("resolveSlackChannelAllowlist", () => {
it("returns stable channel ids without listing a workspace", async () => {
const list = vi.fn();
const res = await resolveSlackChannelAllowlist({
token: "xoxb-test",
entries: ["C123", "channel:G456", "<#C789|general>"],
client: { conversations: { list } } as never,
});
expect(res.map((entry) => entry.id)).toEqual(["C123", "G456", "C789"]);
expect(list).not.toHaveBeenCalled();
});
it("resolves by name and prefers active channels", async () => {
const client = {
conversations: {
list: vi.fn().mockResolvedValue({
channels: [
{ id: "C1", name: "general", is_archived: true },
{ id: "C2", name: "general", is_archived: false },
],
}),
},
};
const res = await resolveSlackChannelAllowlist({
token: "xoxb-test",
entries: ["#general"],
client: client as never,
});
expect(res[0]?.resolved).toBe(true);
expect(res[0]?.id).toBe("C2");
});
it("keeps unresolved entries", async () => {
const client = {
conversations: {
list: vi.fn().mockResolvedValue({ channels: [] }),
},
};
const res = await resolveSlackChannelAllowlist({
token: "xoxb-test",
entries: ["#does-not-exist"],
client: client as never,
});
expect(res[0]?.resolved).toBe(false);
});
});