























@@ -159,8 +159,12 @@ describe("createTelegramDraftStream", () => {
159159160160expect(api.sendMessage).toHaveBeenCalledTimes(1);
161161expect(api.sendMessage).toHaveBeenCalledWith(123, "Hello", { message_thread_id: 42 });
162-expect(warn).toHaveBeenCalledWith(expect.stringContaining("message thread not found"));
163-expect(warn).not.toHaveBeenCalledWith(expect.stringContaining("retrying without thread"));
162+expect(warn).toHaveBeenCalledWith(
163+"telegram stream preview failed: 400: Bad Request: message thread not found",
164+);
165+expect(
166+warn.mock.calls.some(([message]) => String(message).includes("retrying without thread")),
167+).toBe(false);
164168});
165169166170it("keeps allow_sending_without_reply on message previews that target a reply", async () => {
@@ -318,12 +322,16 @@ describe("createTelegramDraftStream", () => {
318322resolveFirstSend?.({ message_id: 17 });
319323await stream.flush();
320324321-expect(onSupersededPreview).toHaveBeenCalledWith({
325+expect(onSupersededPreview).toHaveBeenCalledTimes(1);
326+const [supersededPreview] = onSupersededPreview.mock.calls[0] ?? [];
327+expect(supersededPreview).toEqual({
322328messageId: 17,
323329textSnapshot: "Message A partial",
324330parseMode: undefined,
325-visibleSinceMs: expect.any(Number),
331+visibleSinceMs: supersededPreview.visibleSinceMs,
326332});
333+expect(typeof supersededPreview.visibleSinceMs).toBe("number");
334+expect(Number.isFinite(supersededPreview.visibleSinceMs)).toBe(true);
327335expect(api.sendMessage).toHaveBeenCalledTimes(2);
328336expect(api.sendMessage).toHaveBeenNthCalledWith(2, 123, "Message B partial", undefined);
329337expect(api.editMessageText).not.toHaveBeenCalledWith(123, 17, "Message B partial");
@@ -434,13 +442,17 @@ describe("createTelegramDraftStream", () => {
434442stream.update("Hello world foo bar baz qux");
435443await stream.flush();
436444437-expect(onSupersededPreview).toHaveBeenCalledWith({
445+expect(onSupersededPreview).toHaveBeenCalledTimes(1);
446+const [supersededPreview] = onSupersededPreview.mock.calls[0] ?? [];
447+expect(supersededPreview).toEqual({
438448messageId: 17,
439449textSnapshot: "Hello world",
440450parseMode: undefined,
441-visibleSinceMs: expect.any(Number),
451+visibleSinceMs: supersededPreview.visibleSinceMs,
442452retain: true,
443453});
454+expect(typeof supersededPreview.visibleSinceMs).toBe("number");
455+expect(Number.isFinite(supersededPreview.visibleSinceMs)).toBe(true);
444456});
445457446458it("enforces maxChars after renderText expansion", async () => {
@@ -459,9 +471,7 @@ describe("createTelegramDraftStream", () => {
459471460472expect(api.sendMessage).not.toHaveBeenCalled();
461473expect(api.editMessageText).not.toHaveBeenCalled();
462-expect(warn).toHaveBeenCalledWith(
463-expect.stringContaining("telegram stream preview stopped (text length 127 > 100)"),
464-);
474+expect(warn).toHaveBeenCalledWith("telegram stream preview stopped (text length 127 > 100)");
465475});
466476});
467477此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。