mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-23 08:48:11 +00:00
refactor: unify extension allowlist resolver and directory scaffolding
This commit is contained in:
40
extensions/feishu/src/directory.test.ts
Normal file
40
extensions/feishu/src/directory.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("./accounts.js", () => ({
|
||||
resolveFeishuAccount: vi.fn(() => ({
|
||||
configured: false,
|
||||
config: {
|
||||
allowFrom: ["user:alice", "user:bob"],
|
||||
dms: {
|
||||
"user:carla": {},
|
||||
},
|
||||
groups: {
|
||||
"chat-1": {},
|
||||
},
|
||||
groupAllowFrom: ["chat-2"],
|
||||
},
|
||||
})),
|
||||
}));
|
||||
|
||||
import { listFeishuDirectoryGroups, listFeishuDirectoryPeers } from "./directory.js";
|
||||
|
||||
describe("feishu directory (config-backed)", () => {
|
||||
const cfg = {} as ClawdbotConfig;
|
||||
|
||||
it("merges allowFrom + dms into peer entries", async () => {
|
||||
const peers = await listFeishuDirectoryPeers({ cfg, query: "a" });
|
||||
expect(peers).toEqual([
|
||||
{ kind: "user", id: "alice" },
|
||||
{ kind: "user", id: "carla" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("merges groups map + groupAllowFrom into group entries", async () => {
|
||||
const groups = await listFeishuDirectoryGroups({ cfg });
|
||||
expect(groups).toEqual([
|
||||
{ kind: "group", id: "chat-1" },
|
||||
{ kind: "group", id: "chat-2" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user