|
1 | 1 | // Discord tests cover resolve channels plugin behavior. |
| 2 | +import { ChannelType } from "discord-api-types/v10"; |
2 | 3 | import { withFetchPreconnect } from "openclaw/plugin-sdk/test-env"; |
3 | 4 | import { describe, expect, it } from "vitest"; |
4 | 5 | import { resolveDiscordChannelAllowlist } from "./resolve-channels.js"; |
@@ -67,14 +68,19 @@ describe("resolveDiscordChannelAllowlist", () => { |
67 | 68 | expect(res[0]?.guildId).toBe("111"); |
68 | 69 | } |
69 | 70 |
|
70 | | - it("resolves guild/channel by name", async () => { |
| 71 | + it.each([ |
| 72 | + ["announcement", ChannelType.AnnouncementThread], |
| 73 | + ["public", ChannelType.PublicThread], |
| 74 | + ["private", ChannelType.PrivateThread], |
| 75 | + ])("prefers a matching guild channel over a %s thread", async (_kind, threadType) => { |
71 | 76 | const fetcher = withFetchPreconnect(async (input: RequestInfo | URL) => { |
72 | 77 | const url = urlToString(input); |
73 | 78 | if (url.endsWith("/users/@me/guilds")) { |
74 | 79 | return jsonResponse([{ id: "g1", name: "My Guild" }]); |
75 | 80 | } |
76 | 81 | if (url.endsWith("/guilds/g1/channels")) { |
77 | 82 | return jsonResponse([ |
| 83 | + { id: "thread-1", name: "general", guild_id: "g1", type: threadType }, |
78 | 84 | { id: "c1", name: "general", guild_id: "g1", type: 0 }, |
79 | 85 | { id: "c2", name: "random", guild_id: "g1", type: 0 }, |
80 | 86 | ]); |
|
0 commit comments