feat(webchat): support image attachments
This commit is contained in:
@@ -323,7 +323,28 @@ describe('agent handlers', () => {
|
||||
expect(sent).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('agent.send requires message', async () => {
|
||||
it('agent.send accepts attachment-only requests', async () => {
|
||||
const req: GatewayRequest = {
|
||||
id: 12,
|
||||
method: 'agent.send',
|
||||
params: {
|
||||
connectionId: 'conn-1',
|
||||
attachments: [{ mimeType: 'image/png', data: 'iVBOR...' }],
|
||||
},
|
||||
};
|
||||
const sent: OutboundMessage[] = [];
|
||||
const send = vi.fn((msg: OutboundMessage) => sent.push(msg));
|
||||
|
||||
await handlers['agent.send'](req, send);
|
||||
|
||||
expect(mockAgent.process).toHaveBeenCalledWith('', [
|
||||
{ mimeType: 'image/png', data: 'iVBOR...', url: undefined, filename: undefined },
|
||||
]);
|
||||
expect(sent).toHaveLength(1);
|
||||
expect((sent[0] as GatewayEvent).event).toBe('done');
|
||||
});
|
||||
|
||||
it('agent.send requires message or attachments', async () => {
|
||||
const req: GatewayRequest = { id: 2, method: 'agent.send', params: { connectionId: 'conn-1' } };
|
||||
const send = vi.fn();
|
||||
const result = await handlers['agent.send'](req, send) as GatewayError;
|
||||
|
||||
Reference in New Issue
Block a user