mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:20:44 +00:00
test(channels): cover query+limit filtering in directory config
This commit is contained in:
@@ -378,4 +378,71 @@ describe("directory (config-backed)", () => {
|
|||||||
});
|
});
|
||||||
expect(groups?.map((e) => e.id)).toEqual(["999@g.us"]);
|
expect(groups?.map((e) => e.id)).toEqual(["999@g.us"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("applies query and limit filtering for config-backed directories", async () => {
|
||||||
|
const cfg = {
|
||||||
|
channels: {
|
||||||
|
slack: {
|
||||||
|
botToken: "xoxb-test",
|
||||||
|
appToken: "xapp-test",
|
||||||
|
dm: { allowFrom: ["U100", "U200"] },
|
||||||
|
dms: { U300: {} },
|
||||||
|
channels: { C111: {}, C222: {}, C333: {} },
|
||||||
|
},
|
||||||
|
discord: {
|
||||||
|
token: "discord-test",
|
||||||
|
guilds: {
|
||||||
|
"123": {
|
||||||
|
channels: {
|
||||||
|
"555": {},
|
||||||
|
"666": {},
|
||||||
|
"777": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
telegram: {
|
||||||
|
botToken: "telegram-test",
|
||||||
|
groups: { "-1001": {}, "-1002": {}, "-2001": {} },
|
||||||
|
},
|
||||||
|
whatsapp: {
|
||||||
|
groups: { "111@g.us": {}, "222@g.us": {}, "333@s.whatsapp.net": {} },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// oxlint-disable-next-line typescript/no-explicit-any
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const slackPeers = await listSlackDirectoryPeersFromConfig({
|
||||||
|
cfg,
|
||||||
|
accountId: "default",
|
||||||
|
query: "user:u",
|
||||||
|
limit: 2,
|
||||||
|
});
|
||||||
|
expect(slackPeers).toHaveLength(2);
|
||||||
|
expect(slackPeers.every((entry) => entry.id.startsWith("user:u"))).toBe(true);
|
||||||
|
|
||||||
|
const discordGroups = await listDiscordDirectoryGroupsFromConfig({
|
||||||
|
cfg,
|
||||||
|
accountId: "default",
|
||||||
|
query: "666",
|
||||||
|
limit: 5,
|
||||||
|
});
|
||||||
|
expect(discordGroups.map((entry) => entry.id)).toEqual(["channel:666"]);
|
||||||
|
|
||||||
|
const telegramGroups = await listTelegramDirectoryGroupsFromConfig({
|
||||||
|
cfg,
|
||||||
|
accountId: "default",
|
||||||
|
query: "-100",
|
||||||
|
limit: 1,
|
||||||
|
});
|
||||||
|
expect(telegramGroups.map((entry) => entry.id)).toEqual(["-1001"]);
|
||||||
|
|
||||||
|
const whatsAppGroups = await listWhatsAppDirectoryGroupsFromConfig({
|
||||||
|
cfg,
|
||||||
|
accountId: "default",
|
||||||
|
query: "@g.us",
|
||||||
|
limit: 1,
|
||||||
|
});
|
||||||
|
expect(whatsAppGroups.map((entry) => entry.id)).toEqual(["111@g.us"]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user