From ec47986ef5dafcb5613b303178120889ffd658bf Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 25 Mar 2026 18:06:35 +0100 Subject: [PATCH] Fix emoticon slash commands including stale buffers (#32928) --- apps/web/src/slash-commands/emoticon.ts | 5 +++-- apps/web/test/unit-tests/slash-commands/emoticons-test.ts | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/web/src/slash-commands/emoticon.ts b/apps/web/src/slash-commands/emoticon.ts index c1d232bca9..7c27e8a4b9 100644 --- a/apps/web/src/slash-commands/emoticon.ts +++ b/apps/web/src/slash-commands/emoticon.ts @@ -11,14 +11,15 @@ import { Command } from "./command"; import { successSync } from "./utils"; import { CommandCategories } from "./interface"; -export function emoticon(command: string, description: TranslationKey, message: string): Command { +export function emoticon(command: string, description: TranslationKey, prefix: string): Command { return new Command({ command, args: "", description, runFn: function (_cli, _roomId, _threadId, args) { + let message = prefix; if (args) { - message = message + " " + args; + message += " " + args; } return successSync(ContentHelpers.makeTextMessage(message)); }, diff --git a/apps/web/test/unit-tests/slash-commands/emoticons-test.ts b/apps/web/test/unit-tests/slash-commands/emoticons-test.ts index bd30059127..dbf35d7769 100644 --- a/apps/web/test/unit-tests/slash-commands/emoticons-test.ts +++ b/apps/web/test/unit-tests/slash-commands/emoticons-test.ts @@ -20,6 +20,11 @@ describe.each(["shrug", "tableflip", "unflip", "lenny"])("/%s", (commandName: st it("should match snapshot with args", async () => { const { client, command } = setUpCommandTest(roomId, `/${commandName}`); - await expect(command.run(client, roomId, null, "this is a test message").promise).resolves.toMatchSnapshot(); + const initialResult = await command.run(client, roomId, null, "this is a test message").promise; + expect(initialResult).toMatchSnapshot(); + // We run this twice to ensure it doesn't stack the buffer + await expect(command.run(client, roomId, null, "this is a test message").promise).resolves.toEqual( + initialResult, + ); }); });