feat: validate preparation against owned document files

This commit is contained in:
2026-09-06 08:53:41 +03:00
parent 0d332afdb1
commit 953d3b5c1e
7 changed files with 91 additions and 11 deletions
+13 -1
View File
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {preparationBlockers,documentKey,HEALTH_CHECKS} from '../src/services/preparationChecks.js';
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'}]))}}});
@@ -17,3 +17,15 @@ 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'));
});