fix: restore telegram draft streaming partials

This commit is contained in:
Ayaan Zaidi
2026-01-31 21:55:59 +05:30
committed by Ayaan Zaidi
parent 35988d77ec
commit 37721ebd7c
12 changed files with 260 additions and 54 deletions

View File

@@ -0,0 +1,35 @@
import { describe, expect, it, vi } from "vitest";
import { createTelegramDraftStream } from "./draft-stream.js";
describe("createTelegramDraftStream", () => {
it("passes message_thread_id when provided", () => {
const api = { sendMessageDraft: vi.fn().mockResolvedValue(true) };
const stream = createTelegramDraftStream({
api: api as any,
chatId: 123,
draftId: 42,
messageThreadId: 99,
});
stream.update("Hello");
expect(api.sendMessageDraft).toHaveBeenCalledWith(123, 42, "Hello", {
message_thread_id: 99,
});
});
it("omits message_thread_id for general topic id", () => {
const api = { sendMessageDraft: vi.fn().mockResolvedValue(true) };
const stream = createTelegramDraftStream({
api: api as any,
chatId: 123,
draftId: 42,
messageThreadId: 1,
});
stream.update("Hello");
expect(api.sendMessageDraft).toHaveBeenCalledWith(123, 42, "Hello", undefined);
});
});