


























@@ -1139,6 +1139,72 @@ describe("handleDiscordMessagingAction", () => {
11391139);
11401140});
114111411142+it("resolves guildId from channel info when guildId is omitted in searchMessages", async () => {
1143+fetchChannelInfoDiscord.mockResolvedValueOnce({
1144+id: "C1",
1145+type: 0,
1146+guild_id: "resolved-guild",
1147+});
1148+searchMessagesDiscord.mockResolvedValueOnce({ total_results: 0, messages: [] });
1149+1150+await handleMessagingAction(
1151+"searchMessages",
1152+{ channelId: "C1", content: "hello" },
1153+enableAllActions,
1154+);
1155+1156+expect(fetchChannelInfoDiscord).toHaveBeenCalledWith("C1", expect.anything());
1157+expect(searchMessagesDiscord).toHaveBeenCalledWith(
1158+expect.objectContaining({ guildId: "resolved-guild", content: "hello" }),
1159+expect.anything(),
1160+);
1161+});
1162+1163+it("normalizes channel: prefixed channelId before resolving guildId in searchMessages", async () => {
1164+fetchChannelInfoDiscord.mockResolvedValueOnce({
1165+id: "C1",
1166+type: 0,
1167+guild_id: "resolved-guild",
1168+});
1169+searchMessagesDiscord.mockResolvedValueOnce({ total_results: 0, messages: [] });
1170+1171+await handleMessagingAction(
1172+"searchMessages",
1173+{ channelId: "channel:C1", content: "hello" },
1174+enableAllActions,
1175+);
1176+1177+expect(fetchChannelInfoDiscord).toHaveBeenCalledWith("C1", expect.anything());
1178+expect(searchMessagesDiscord).toHaveBeenCalledWith(
1179+expect.objectContaining({ guildId: "resolved-guild", content: "hello", channelIds: ["C1"] }),
1180+expect.anything(),
1181+);
1182+});
1183+1184+it("accepts query as alias for content in searchMessages", async () => {
1185+searchMessagesDiscord.mockResolvedValueOnce({ total_results: 0, messages: [] });
1186+1187+await handleMessagingAction(
1188+"searchMessages",
1189+{ guildId: "G1", query: "find this" },
1190+enableAllActions,
1191+);
1192+1193+expect(searchMessagesDiscord).toHaveBeenCalledWith(
1194+expect.objectContaining({ guildId: "G1", content: "find this" }),
1195+expect.anything(),
1196+);
1197+});
1198+1199+it("throws descriptive error when guildId cannot be resolved in searchMessages", async () => {
1200+await expect(
1201+handleMessagingAction("searchMessages", { content: "hello" }, enableAllActions),
1202+).rejects.toThrow(
1203+"Discord search requires guildId. Provide guildId explicitly, or provide channelId so the guild can be resolved from the channel.",
1204+);
1205+expect(searchMessagesDiscord).not.toHaveBeenCalled();
1206+});
1207+11421208it("sends voice messages from a local file path", async () => {
11431209sendVoiceMessageDiscord.mockClear();
11441210sendMessageDiscord.mockClear();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。