Skip to content

Commit 0adc902

Browse files
author
Sorra
committed
SB-0MNJLYHGL006PXC6: Add test for Save briefing edge case (no content)
1 parent 94b0ff0 commit 0adc902

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/save-button.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,33 @@ describe("Save briefing button interaction", () => {
204204

205205
expect(runCliMock).toHaveBeenCalledTimes(2);
206206
});
207+
208+
it("returns a helpful error when no briefing content is available", async () => {
209+
// No attachments and no message content -> handler should return an explanatory error
210+
await vi.doMock("../src/discord/client.js", async () => {
211+
class MockDiscordBot {
212+
constructor(options: any) {
213+
(global as any).__ON_INTERACTION_CAPTURE__ = options.onInteraction;
214+
}
215+
async start(): Promise<void> {
216+
return;
217+
}
218+
}
219+
220+
return { DiscordBot: MockDiscordBot };
221+
});
222+
223+
// Load the bot module (this will set __ON_INTERACTION_CAPTURE__)
224+
await import("../src/index.js");
225+
226+
const { interaction, edits } = makeButtonInteraction({ message: { id: "reply-empty", content: "", attachments: { size: 0 } } });
227+
228+
const captured = (global as any).__ON_INTERACTION_CAPTURE__ as any;
229+
if (!captured) throw new Error("Failed to capture onInteraction handler");
230+
await captured(interaction);
231+
232+
expect(edits.length).toBeGreaterThan(0);
233+
const last = edits[edits.length - 1];
234+
expect(String(last.content)).toContain("Could not extract briefing text");
235+
});
207236
});

0 commit comments

Comments
 (0)