test: cover Buzz mention boundaries

This commit is contained in:
Shakker
2026-08-02 05:50:43 +01:00
parent 09bdcf3eb1
commit 12b924c4d0
2 changed files with 34 additions and 0 deletions
@@ -343,6 +343,22 @@ describe("Buzz bus lifecycle", () => {
expect(relayMocks.close).toHaveBeenCalledOnce();
});
it("closes a standalone relay when mention preflight rejects the message", async () => {
relayMocks.auth.mockResolvedValue("ok");
await expect(
sendBuzzTextOneShot({
relayUrl: "wss://buzz.example.com",
privateKey: PRIVATE_KEY,
channelId: CHANNEL_ID,
text: "Hello @Missing",
}),
).rejects.toThrow('Buzz mention "@missing" does not match a current room member');
expect(relayMocks.publish).not.toHaveBeenCalled();
expect(relayMocks.close).toHaveBeenCalledOnce();
});
it("resolves active-bus mentions for proactive sends and agent replies", async () => {
relayMocks.auth.mockResolvedValue("ok");
relayMocks.profileEvents = [
+18
View File
@@ -89,4 +89,22 @@ describe("Buzz outbound mentions", () => {
).toEqual([]);
expect(hasBuzzMentionSyntax("mail user@example.com")).toBe(false);
});
it("rejects messages above the native mention limit", () => {
const mentionedMembers = Array.from({ length: 51 }, (_, index) => {
const publicKey = (index + 1).toString(16).padStart(64, "0");
return {
publicKey,
displayName: `Member${index + 1}`,
};
});
expect(() =>
resolveBuzzMessageMentions({
text: mentionedMembers.map((member) => `@${member.displayName}`).join(" "),
members: members(...mentionedMembers),
senderPublicKey: BOT_PUBLIC_KEY,
}),
).toThrow("Buzz messages support at most 50 mentions");
});
});