24 lines
761 B
TypeScript
24 lines
761 B
TypeScript
|
|
import assert from 'node:assert/strict'
|
||
|
|
import test from 'node:test'
|
||
|
|
|
||
|
|
import {retryPayload} from '../src/retryMessage.ts'
|
||
|
|
|
||
|
|
test('retry preserves the original message and attachment identifiers', () => {
|
||
|
|
const payload=retryPayload({
|
||
|
|
id:'message-1',
|
||
|
|
role:'user',
|
||
|
|
content:'Analyse cette capture',
|
||
|
|
metadata:{attachments:[
|
||
|
|
{id:'attachment-1',original_name:'capture.png',content_type:'image/png',size:42,url:'/attachment-1'},
|
||
|
|
]},
|
||
|
|
})
|
||
|
|
assert.deepEqual(payload,{content:'Analyse cette capture',attachment_ids:['attachment-1']})
|
||
|
|
})
|
||
|
|
|
||
|
|
test('retry keeps a text-only message valid', () => {
|
||
|
|
assert.deepEqual(retryPayload({id:'message-2',role:'user',content:'Réessaie',metadata:{}}),{
|
||
|
|
content:'Réessaie',
|
||
|
|
attachment_ids:[],
|
||
|
|
})
|
||
|
|
})
|