




























@@ -1,10 +1,5 @@
11import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
223-// Resolve a real photo to a stored path for "p1.jpg" while making "p2.jpg"
4-// (and "p3.jpg") fail with a *real* MediaFetchError so that
5-// isRecoverableMediaGroupError() (which checks `instanceof MediaFetchError`
6-// against openclaw/plugin-sdk/media-runtime) treats the failure as a
7-// recoverable per-photo skip rather than dropping the whole album.
83const saveRemoteMedia = vi.fn();
94const saveMediaBuffer = vi.fn();
105const readRemoteMediaBuffer = vi.fn();
@@ -171,15 +166,11 @@ describe("createTelegramBot media-group skip warning (#55216)", () => {
171166 ...opts,
172167telegramDeps: telegramBotDepsForTest,
173168});
174-setTelegramBotRuntimeForTest(
175-telegramBotRuntimeForTest as unknown as Parameters<typeof setTelegramBotRuntimeForTest>[0],
176-);
169+setTelegramBotRuntimeForTest(telegramBotRuntimeForTest);
177170});
178171179172beforeEach(() => {
180-setTelegramBotRuntimeForTest(
181-telegramBotRuntimeForTest as unknown as Parameters<typeof setTelegramBotRuntimeForTest>[0],
182-);
173+setTelegramBotRuntimeForTest(telegramBotRuntimeForTest);
183174saveRemoteMedia.mockReset();
184175saveMediaBuffer.mockReset();
185176readRemoteMediaBuffer.mockReset();
@@ -227,7 +218,7 @@ describe("createTelegramBot media-group skip warning (#55216)", () => {
227218}
228219});
229220230-it("does not send a media-drop warning when every photo fails", async () => {
221+it("warns the user when every album image fails", async () => {
231222setOpenChannelPostConfig();
232223saveRemoteMedia.mockImplementation(async (...args: unknown[]) => {
233224throw new MediaFetchError("fetch_failed", `Failed to fetch media from ${urlOf(args)}`);
@@ -243,7 +234,10 @@ describe("createTelegramBot media-group skip warning (#55216)", () => {
243234});
244235await flushChannelPostMediaGroup(setTimeoutSpy);
245236246-expect(sendMessageSpy).not.toHaveBeenCalled();
237+expect(sendMessageSpy).toHaveBeenCalledTimes(1);
238+const warningText = String(sendMessageSpy.mock.calls[0]?.[1]);
239+expect(warningText).toContain("0 of 2 images");
240+expect(warningText).toContain("2 could not be fetched and were skipped");
247241} finally {
248242setTimeoutSpy.mockRestore();
249243}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。