diff --git a/extensions/mattermost/src/mattermost/slash-http.test.ts b/extensions/mattermost/src/mattermost/slash-http.test.ts index bc558a6a7c4..e98752d92f0 100644 --- a/extensions/mattermost/src/mattermost/slash-http.test.ts +++ b/extensions/mattermost/src/mattermost/slash-http.test.ts @@ -142,6 +142,11 @@ async function runSlashRequest(params: { return response; } +function firstLogMessage(log: ReturnType): string { + const message = log.mock.calls[0]?.[0]; + return typeof message === "string" ? message : ""; +} + describe("slash-http", () => { beforeEach(() => { resetMattermostSlashCommandValidationCacheForTests(); @@ -628,7 +633,7 @@ describe("slash-http", () => { ).resolves.toBe(false); expect(log).toHaveBeenCalledTimes(1); - const message = log.mock.calls.at(0)?.[0] ?? ""; + const message = firstLogMessage(log); expect(message).not.toMatch(/[\r\n\t]/u); expect(message).toContain("deleted command cmd-1 spoofed"); expect(message).toContain("using team list fallback"); @@ -753,7 +758,7 @@ describe("slash-http", () => { ).resolves.toBe(true); expect(log).toHaveBeenCalledTimes(1); - const message = log.mock.calls.at(0)?.[0] ?? ""; + const message = firstLogMessage(log); expect(message).not.toMatch(/[\r\n\t]/u); expect(message).toContain("/oc_status spoofed"); expect(message).toContain("primary token=[redacted]"); @@ -792,7 +797,7 @@ describe("slash-http", () => { ).resolves.toBe(false); expect(log).toHaveBeenCalledTimes(1); - const message = log.mock.calls.at(0)?.[0] ?? ""; + const message = firstLogMessage(log); expect(message).not.toMatch(/[\r\n\t]/u); expect(message).toContain("fallback second-line"); expect(message).toContain("botToken: [redacted]");