Files
ihaleist/tests/analysis-parts.test.mjs
T

26 lines
1.8 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 {splitAnalysisText,analyzeInParts} from '../server/analysis-parts.mjs';
test('long Turkish source is covered once without loss, including final paragraph',()=>{
const text=('İğdır laboratuvar 🧪\n').repeat(7000)+'SON MADDE';
const parts=splitAnalysisText(text);assert.ok(parts.length>1);
assert.equal(parts.map(p=>p.text).join(''),text);assert.ok(parts.every(p=>p.text.length<=24000));
assert.equal(parts.at(-1).end,text.length);
});
test('all source parts contribute requirements, failures remain explicit partial analysis',async()=>{
const text='a'.repeat(60000);
const complete=await analyzeInParts({text,fileName:'test'},async p=>({result:{documentChecklist:[{document:`Belge ${p.index}`}],sourceReview:{issues:[]}},attempts:[]}));
assert.equal(complete.result.documentChecklist.length,3);assert.equal(complete.result.sourceReview.analyzedCharacters,60000);
assert.equal(complete.result.sourceReview.status,'review_required');assert.equal(complete.result.bidAnalysis,null);
const partial=await analyzeInParts({text},async p=>{if(p.index===1)throw new Error('test failure');return {result:{itemsAndSpecs:[{name:'Kit',quantity:p.index?'3 adet':'2 adet'}]}};});
assert.equal(partial.result.sourceReview.status,'partial');assert.equal(partial.result.sourceReview.analyzedCharacters,36000);
assert.equal(partial.result.sourceReview.parts[1].status,'failed');
assert.ok(partial.result.sourceReview.issues.some(i=>i.includes('farklı miktar')));
});
test('identical-looking rows in different source parts are retained with origin',async()=>{
const out=await analyzeInParts({text:'a'.repeat(30000)},async()=>({result:{itemsAndSpecs:[{name:'Kit',quantity:'2 adet'}]}}));
assert.equal(out.result.itemsAndSpecs.length,2);
assert.deepEqual(out.result.itemsAndSpecs.map(r=>r.sourcePart),[1,2]);
});