From a661eec0bf34ab77208809ffae88f5385a347bd7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 18 Feb 2026 16:24:49 +0000 Subject: [PATCH] test(channels): cover query+limit filtering in directory config --- src/channels/plugins/plugins-core.test.ts | 67 +++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/channels/plugins/plugins-core.test.ts b/src/channels/plugins/plugins-core.test.ts index 0db2382433..f31d83f3e7 100644 --- a/src/channels/plugins/plugins-core.test.ts +++ b/src/channels/plugins/plugins-core.test.ts @@ -378,4 +378,71 @@ describe("directory (config-backed)", () => { }); 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"]); + }); });