Validate assistant response contracts and bound AI request waiting
This commit is contained in:
@@ -34,3 +34,12 @@ test('late answer is rejected after account or active tender changes',async()=>{
|
||||
fetcher:async()=>{if(change==='account')token='second';else mounted=false;return Response.json({cevap:'Private answer'});}}),/Oturum veya ihale değişti/);
|
||||
}
|
||||
});
|
||||
test('HTML, null and incomplete success responses cannot replace a valid existing result',async()=>{
|
||||
for(const response of [new Response('<html>Gateway</html>'),Response.json(null),Response.json({}),Response.json({success:true,maddeler:[{durum:'unknown'}]})]) {
|
||||
await assert.rejects(requestOfferAssistant({url:'/api/ai/teklif-denetim',body,readToken:()=>'first',fetcher:async()=>response}));
|
||||
}
|
||||
});
|
||||
test('a stalled AI request times out instead of locking the assistant indefinitely',async()=>{
|
||||
await assert.rejects(requestOfferAssistant({url:'/api/ai/belge-sor',body,readToken:()=>'first',timeoutMs:5,
|
||||
fetcher:async(url,{signal})=>new Promise((resolve,reject)=>signal.addEventListener('abort',()=>reject(new DOMException('Aborted','AbortError')),{once:true}))}),/zaman aşımı/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user