32 lines
2.4 KiB
JavaScript
32 lines
2.4 KiB
JavaScript
import test from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import {preparationBlockers,documentKey,HEALTH_CHECKS,documentRevision,documentLinkProblem} from '../src/services/preparationChecks.js';
|
||
const rows=[{priceKey:'kit1',name:'Kit'}];
|
||
const docs=[{document:'Yetki belgesi',mandatory:true,note:'Şartname 7.1'}];
|
||
const complete=()=>({documents:{[documentKey(docs[0])]:{status:'verified',evidence:'Yetki v2, süre kontrol edildi, 7.1'}},products:{kit1:{product:'QA model',source:'Teknik 3.2, katalog s4',status:'suitable',...Object.fromEntries(HEALTH_CHECKS.map(([key])=>[key,{status:'notApplicable',evidence:'Doküman ilgili maddesi kapsamında uygulanmıyor'}]))}}});
|
||
test('priced rows without document and health review remain incomplete',()=>{
|
||
assert.ok(preparationBlockers(rows,[],{}).length>=6);
|
||
assert.equal(preparationBlockers(rows,docs,complete()).length,0);
|
||
});
|
||
test('unsuitable product, missing evidence and mandatory document exemption block readiness',()=>{
|
||
const c=complete();c.products.kit1.status='unsuitable';assert.ok(preparationBlockers(rows,docs,c).some(x=>x.includes('uygun değil')));
|
||
c.products.kit1.status='suitable';c.products.kit1.uts.evidence=' ';assert.ok(preparationBlockers(rows,docs,c).some(x=>x.includes('ÜTS')));
|
||
c.documents[documentKey(docs[0])].status='notApplicable';assert.ok(preparationBlockers(rows,docs,c).some(x=>x.includes('Yetki')));
|
||
});
|
||
test('changed requirement and changed product row require new checks',()=>{
|
||
assert.ok(preparationBlockers(rows,[{...docs[0],note:'Zeyilname 2'}],complete()).length>0);
|
||
assert.ok(preparationBlockers([{...rows[0],priceKey:'kit2'}],docs,complete()).length>0);
|
||
});
|
||
|
||
test('linked file must exist, match reviewed metadata and remain valid at tender deadline',()=>{
|
||
const file={id:'f1',olusturma:'2026-09-01',boyut:100,son_kullanma:'2026-09-10',erisilebilir:true};
|
||
const c={documentId:file.id,documentRevision:documentRevision(file)};
|
||
assert.equal(documentLinkProblem(c,[file],'2026-09-10'),null);
|
||
assert.ok(documentLinkProblem(c,[],'2026-09-10'));
|
||
assert.ok(documentLinkProblem(c,[{...file,erisilebilir:false}],'2026-09-10'));
|
||
assert.ok(documentLinkProblem(c,[{...file,boyut:101}],'2026-09-10'));
|
||
assert.ok(documentLinkProblem(c,[file],'2026-09-11'));
|
||
const invalid={...file,son_kullanma:'2026-02-31'};
|
||
assert.ok(documentLinkProblem({...c,documentRevision:documentRevision(invalid)},[invalid],'2026-01-01'));
|
||
});
|