Validate assistant response contracts and bound AI request waiting

This commit is contained in:
2026-09-06 10:12:53 +03:00
parent 996cc15245
commit a1d70b9dcf
5 changed files with 75 additions and 5 deletions
+9
View File
@@ -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ı/);
});