mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-21 06:51:01 +00:00
Move all Slack channel implementation files from src/slack/ to extensions/slack/src/ and replace originals with shim re-exports. This follows the extension migration pattern for channel plugins. - Copy all .ts files to extensions/slack/src/ (preserving directory structure: monitor/, http/, monitor/events/, monitor/message-handler/) - Transform import paths: external src/ imports use relative paths back to src/, internal slack imports stay relative within extension - Replace all src/slack/ files with shim re-exports pointing to the extension copies - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." so the DTS build can follow shim chains into extensions/ - Update write-plugin-sdk-entry-dts.ts re-export path accordingly - Preserve extensions/slack/index.ts, package.json, openclaw.plugin.json, src/channel.ts, src/runtime.ts, src/channel.test.ts (untouched)
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { resolveSlackUserAllowlist } from "./resolve-users.js";
|
|
|
|
describe("resolveSlackUserAllowlist", () => {
|
|
it("resolves by email and prefers active human users", async () => {
|
|
const client = {
|
|
users: {
|
|
list: vi.fn().mockResolvedValue({
|
|
members: [
|
|
{
|
|
id: "U1",
|
|
name: "bot-user",
|
|
is_bot: true,
|
|
deleted: false,
|
|
profile: { email: "person@example.com" },
|
|
},
|
|
{
|
|
id: "U2",
|
|
name: "person",
|
|
is_bot: false,
|
|
deleted: false,
|
|
profile: { email: "person@example.com", display_name: "Person" },
|
|
},
|
|
],
|
|
}),
|
|
},
|
|
};
|
|
|
|
const res = await resolveSlackUserAllowlist({
|
|
token: "xoxb-test",
|
|
entries: ["person@example.com"],
|
|
client: client as never,
|
|
});
|
|
|
|
expect(res[0]).toMatchObject({
|
|
resolved: true,
|
|
id: "U2",
|
|
name: "Person",
|
|
email: "person@example.com",
|
|
isBot: false,
|
|
});
|
|
});
|
|
|
|
it("keeps unresolved users", async () => {
|
|
const client = {
|
|
users: {
|
|
list: vi.fn().mockResolvedValue({ members: [] }),
|
|
},
|
|
};
|
|
|
|
const res = await resolveSlackUserAllowlist({
|
|
token: "xoxb-test",
|
|
entries: ["@missing-user"],
|
|
client: client as never,
|
|
});
|
|
|
|
expect(res[0]).toEqual({ input: "@missing-user", resolved: false });
|
|
});
|
|
});
|