mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 05:24:32 +00:00
fix: stabilize telegram draft boundary previews (#33842) (thanks @ngutman)
This commit is contained in:
@@ -43,7 +43,11 @@ function createHarness(params?: {
|
||||
const log = vi.fn();
|
||||
const markDelivered = vi.fn();
|
||||
const finalizedPreviewByLane: Record<LaneName, boolean> = { answer: false, reasoning: false };
|
||||
const archivedAnswerPreviews: Array<{ messageId: number; textSnapshot: string }> = [];
|
||||
const archivedAnswerPreviews: Array<{
|
||||
messageId: number;
|
||||
textSnapshot: string;
|
||||
deleteIfUnused?: boolean;
|
||||
}> = [];
|
||||
|
||||
const deliverLaneText = createLaneTextDeliverer({
|
||||
lanes,
|
||||
@@ -71,8 +75,10 @@ function createHarness(params?: {
|
||||
flushDraftLane,
|
||||
stopDraftLane,
|
||||
editPreview,
|
||||
deletePreviewMessage,
|
||||
log,
|
||||
markDelivered,
|
||||
archivedAnswerPreviews,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -306,4 +312,26 @@ describe("createLaneTextDeliverer", () => {
|
||||
);
|
||||
expect(harness.markDelivered).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("deletes consumed boundary previews after fallback final send", async () => {
|
||||
const harness = createHarness();
|
||||
harness.archivedAnswerPreviews.push({
|
||||
messageId: 4444,
|
||||
textSnapshot: "Boundary preview",
|
||||
deleteIfUnused: false,
|
||||
});
|
||||
|
||||
const result = await harness.deliverLaneText({
|
||||
laneName: "answer",
|
||||
text: "Final with media",
|
||||
payload: { text: "Final with media", mediaUrl: "file:///tmp/example.png" },
|
||||
infoKind: "final",
|
||||
});
|
||||
|
||||
expect(result).toBe("sent");
|
||||
expect(harness.sendPayload).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ text: "Final with media", mediaUrl: "file:///tmp/example.png" }),
|
||||
);
|
||||
expect(harness.deletePreviewMessage).toHaveBeenCalledWith(4444);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user