@@ -2,11 +2,21 @@
|
2 | 2 | import { describe, expect, it, vi } from "vitest"; |
3 | 3 | import { normalizeAllowFrom } from "./bot-access.js"; |
4 | 4 | |
5 | | -const { transcribeFirstAudioMock, triggerInternalHookMock } = vi.hoisted(() => ({ |
| 5 | +const { |
| 6 | + resolveStickerVisionSupportRuntimeMock, |
| 7 | + transcribeFirstAudioMock, |
| 8 | + triggerInternalHookMock, |
| 9 | +} = vi.hoisted(() => ({ |
| 10 | +resolveStickerVisionSupportRuntimeMock: vi.fn(async (_params: unknown) => false), |
6 | 11 | transcribeFirstAudioMock: vi.fn(), |
7 | 12 | triggerInternalHookMock: vi.fn<(event: unknown) => Promise<void>>(async () => undefined), |
8 | 13 | })); |
9 | 14 | |
| 15 | +vi.mock("./sticker-vision.runtime.js", () => ({ |
| 16 | +resolveStickerVisionSupportRuntime: (params: unknown) => |
| 17 | +resolveStickerVisionSupportRuntimeMock(params), |
| 18 | +})); |
| 19 | + |
10 | 20 | vi.mock("./media-understanding.runtime.js", () => ({ |
11 | 21 | transcribeFirstAudio: (...args: unknown[]) => transcribeFirstAudioMock(...args), |
12 | 22 | })); |
@@ -277,6 +287,38 @@ describe("resolveTelegramInboundBody", () => {
|
277 | 287 | expect(result?.stickerCacheHit).toBe(true); |
278 | 288 | }); |
279 | 289 | |
| 290 | +it("keeps cached sticker media available when the active model supports vision", async () => { |
| 291 | +resolveStickerVisionSupportRuntimeMock.mockResolvedValueOnce(true); |
| 292 | + |
| 293 | +const result = await resolveTelegramBody({ |
| 294 | +msg: { |
| 295 | +message_id: 8, |
| 296 | +date: 1_700_000_008, |
| 297 | +chat: { id: 42, type: "private", first_name: "Pat" }, |
| 298 | +from: { id: 42, first_name: "Pat" }, |
| 299 | +sticker: { |
| 300 | +file_id: "sticker-3", |
| 301 | +file_unique_id: "sticker-u3", |
| 302 | +type: "regular", |
| 303 | +width: 256, |
| 304 | +height: 256, |
| 305 | +is_animated: false, |
| 306 | +is_video: false, |
| 307 | +}, |
| 308 | +} as never, |
| 309 | +allMedia: [ |
| 310 | +{ |
| 311 | +path: "/tmp/sticker.webp", |
| 312 | +contentType: "image/webp", |
| 313 | +stickerMetadata: { cachedDescription: "Cached description" }, |
| 314 | +}, |
| 315 | +], |
| 316 | +}); |
| 317 | + |
| 318 | +expect(result?.bodyText).toBe("<media:image>"); |
| 319 | +expect(result?.stickerCacheHit).toBe(false); |
| 320 | +}); |
| 321 | + |
280 | 322 | it("lets catch-all mention patterns activate captionless group photos", async () => { |
281 | 323 | const logger = { info: vi.fn() }; |
282 | 324 | |
|