Files
ihaleist/tests/offer-response.test.mjs
T
hikmettan c783269041
Quality gates / test-build (push) Canceled after 0s
Quality gates / container (push) Canceled after 0s
eksik teklif taslagini acikca etiketle
2026-09-06 21:28:43 +03:00

23 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {test} from 'node:test';
import assert from 'node:assert/strict';
import {draftReviewLabel,validateOfferResponse} from '../src/services/offerResponse.js';
import {qualifyOfferDraft} from '../server/offer-draft.mjs';
import {qualifyOfferAudit} from '../server/offer-audit.mjs';
import {qualifyQuestionAnswer} from '../server/document-question.mjs';
test('all three server output contracts can be rendered by the client',()=>{
const draft={success:true,...qualifyOfferDraft({bolumler:[{baslik:'Kapak',icerik:'Taslak metni'}]},['Kapak','Ekler'])};
const audit={success:true,...qualifyOfferAudit({maddeler:[{gereklilik:'Numune',durum:'eksik'}]},['Numune'],'Taslak')};
const answer={success:true,...qualifyQuestionAnswer({cevap:'Numune zorunlu [1].'},[{n:1,icerik:'Numune zorunlu.'}])};
for(const [url,data] of [['teklif-taslak',draft],['teklif-denetim',audit],['belge-sor',answer]]) assert.equal(validateOfferResponse('/api/ai/'+url,data),data);
});
test('nested fields that would crash the view are rejected at the boundary',()=>{
for(const [url,data] of [
['belge-sor',{cevap:'Yanıt',kaynaklar:{}}],
['teklif-denetim',{maddeler:[{gereklilik:'Numune',durum:'unexpected'}],eksikler:[],uyum_yuzde:100,belirsizSayisi:0}],
['teklif-taslak',{bolumler:[{baslik:'Kapak',icerik:{text:'invalid'}}]}]]) assert.throws(()=>validateOfferResponse('/api/ai/'+url,{success:true,...data}),/beklenen biçimde/);
});
test('partial draft output carries an explicit non-official offer warning',()=>{
assert.equal(draftReviewLabel({status:'partial'}),'EKSİK TASLAK — TEKLİF OLARAK KULLANILAMAZ');
assert.equal(draftReviewLabel({status:'draft'}),'Taslak — kullanıcı kontrolü gerekli');
});