|
1 | 1 | import { escapeRegExp, formatEnvelopeTimestamp } from "openclaw/plugin-sdk/channel-test-helpers"; |
2 | 2 | import type { GetReplyOptions, MsgContext } from "openclaw/plugin-sdk/reply-runtime"; |
3 | 3 | import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
| 4 | +import { stripAnsi } from "../../../src/terminal/ansi.js"; |
4 | 5 | import type { TelegramBotOptions } from "./bot.types.js"; |
5 | 6 | const harness = await import("./bot.create-telegram-bot.test-harness.js"); |
6 | 7 | const conversationRuntime = await import("openclaw/plugin-sdk/conversation-runtime"); |
@@ -245,7 +246,8 @@ describe("createTelegramBot", () => {
|
245 | 246 | |
246 | 247 | expect(errorHandler).toBeTypeOf("function"); |
247 | 248 | errorHandler?.(new Error("handler boom")); |
248 | | -expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("telegram bot error:")); |
| 249 | +const errorMessage = stripAnsi(String(runtime.error.mock.calls[0]?.[0])); |
| 250 | +expect(errorMessage.startsWith("telegram bot error: Error: handler boom")).toBe(true); |
249 | 251 | }); |
250 | 252 | |
251 | 253 | it("uses wrapped fetch when global fetch is available", () => { |
@@ -713,10 +715,9 @@ describe("createTelegramBot", () => {
|
713 | 715 | |
714 | 716 | expect(startedBodies[0]).toContain("first"); |
715 | 717 | expect(startedBodies[1]).toContain("second"); |
716 | | -expect(sendMessageSpy.mock.calls.map((call) => call[1])).toEqual([ |
717 | | -expect.stringContaining("first"), |
718 | | -expect.stringContaining("second"), |
719 | | -]); |
| 718 | +const sentBodies = sendMessageSpy.mock.calls.map((call) => String(call[1])); |
| 719 | +expect(sentBodies[0]).toContain("first"); |
| 720 | +expect(sentBodies[1]).toContain("second"); |
720 | 721 | } finally { |
721 | 722 | setTimeoutSpy.mockRestore(); |
722 | 723 | } |
|