Fix emoticon slash commands including stale buffers (#32928)

This commit is contained in:
Michael Telatynski 2026-03-25 18:06:35 +01:00 committed by GitHub
parent e78ad200a5
commit ec47986ef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -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: "<message>",
description,
runFn: function (_cli, _roomId, _threadId, args) {
let message = prefix;
if (args) {
message = message + " " + args;
message += " " + args;
}
return successSync(ContentHelpers.makeTextMessage(message));
},

View File

@ -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,
);
});
});