mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-20 12:51:43 +00:00
* 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>
56 lines
1.6 KiB
TypeScript
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);
|
|
});
|
|
});
|