(withPhoto = true)
| 3 | import type { Transport, Incoming, MessageRef, Button, AgentRunner, TurnSink, ArtifactCard } from '../src/bot/types.ts'; |
| 4 | |
| 5 | function fakeTransport(withPhoto = true) { |
| 6 | let onMsg: (m: Incoming) => void = () => {}; |
| 7 | const sent: Array<{ text: string; buttons?: Button[][] }> = []; |
| 8 | const photos: Array<{ path: string; caption?: string; buttons?: Button[][] }> = []; |
| 9 | const t: Transport = { |
| 10 | platform: 'telegram', maxLen: 4000, minEditIntervalMs: 0, |
| 11 | start: async (cb) => { onMsg = cb; }, stop: async () => {}, |
| 12 | send: async (_c, text, buttons) => { sent.push({ text, buttons }); return { id: 'm' } as MessageRef; }, |
| 13 | edit: async () => {}, |
| 14 | ackCallback: async () => {}, |
| 15 | ...(withPhoto ? { sendPhoto: async (_c: string, path: string, caption?: string, buttons?: Button[][]) => { photos.push({ path, caption, buttons }); return { id: 'p' } as MessageRef; } } : {}), |
| 16 | }; |
| 17 | const inject = (m: Partial<Incoming>) => onMsg({ platform: 'telegram', chatId: 'c1', userId: 'u1', text: '', ...m } as Incoming); |
| 18 | return { t, sent, photos, inject }; |
| 19 | } |
| 20 | |
| 21 | const allow = { telegram: { allowedUsers: ['u1'] } }; |
| 22 | const flush = async () => { for (let i = 0; i < 4; i++) await new Promise(r => setTimeout(r, 0)); }; |
no test coverage detected