Skip to content

Commit 41f1076

Browse files
committed
dev: retain 30 critical regression tests
1 parent f4b44dc commit 41f1076

16 files changed

Lines changed: 0 additions & 347 deletions

‎server/annotation-display.test.mjs‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎server/bitmap-cache.test.mjs‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎server/document-cache.test.mjs‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎server/document-session.test.mjs‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,3 @@ test('session persists multiple documents and positions; closing all restores on
1616
assert.equal(JSON.parse(await readFile(path)).documents.length,0);
1717
}finally{await rm(dir,{recursive:true,force:true});}
1818
});
19-
20-
test('sidebar tabs persist separately for each document and reject unknown modes',async()=>{
21-
const {createRecents}=await import('../electron/recents.mjs');
22-
const dir=await mkdtemp(join(tmpdir(),'reader-sidebar-'));
23-
try{
24-
const path=join(dir,'recents.json'),recents=await createRecents(path);
25-
const [a]=await recents.remember('/tmp/a.pdf');
26-
const [b]=await recents.remember('/tmp/b.pdf');
27-
await recents.setView(a.id,{...view,sidebarMode:'annotations'});
28-
await recents.setView(b.id,{...view,sidebarMode:'outline'});
29-
const restored=(await createRecents(path)).list();
30-
assert.equal(restored.find(item=>item.id===a.id).view.sidebarMode,'annotations');
31-
assert.equal(restored.find(item=>item.id===b.id).view.sidebarMode,'outline');
32-
await assert.rejects(recents.setView(a.id,{...view,sidebarMode:'invalid'}));
33-
}finally{await rm(dir,{recursive:true,force:true});}
34-
});

‎server/engines.test.mjs‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ import {tmpdir} from 'node:os';
66
import {createLimiter,createEngines,prepareKernelAssets,pythonResourcePath,definitions,kernelPythonPath,findUv} from './engines.mjs';
77
import {startServer} from './index.mjs';
88

9-
test('fresh kernel assets have valid targets and reuse existing shared models',async()=>{
10-
const root=await mkdtemp(join(tmpdir(),'kernel-assets-'));
11-
try{
12-
const shared=join(root,'shared');await mkdir(join(shared,'models'),{recursive:true});
13-
const owned=join(root,'owned'),home=join(root,'job');await prepareKernelAssets(owned,home,shared);
14-
for(const kind of ['fonts','models','tiktoken','cmap'])assert.ok((await stat(join(home,'.cache','babeldoc',kind))).isDirectory());
15-
assert.equal(await realpath(join(home,'.cache','babeldoc','models')),await realpath(join(shared,'models')));
16-
// BabelDOC performs this during import; dangling symlinks used to throw.
17-
await mkdir(join(home,'.cache','babeldoc','tiktoken'),{recursive:true});
18-
}finally{await rm(root,{recursive:true,force:true});}
19-
});
209
test('global translation budget holds across simultaneous page workers and releases after failures',async()=>{
2110
const limiter=createLimiter(2);let active=0,peak=0;const completed=[];
2211
await Promise.allSettled(Array.from({length:12},(_,n)=>limiter.run(async()=>{active++;peak=Math.max(peak,active);try{await new Promise(r=>setTimeout(r,2+(n%3)*3));if(n===3)throw Error('fixture failure');completed.push(n);}finally{active--;}})));

‎server/formula-placeholders.test.mjs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import test from 'node:test';
22
import assert from 'node:assert/strict';
33
import {restoreFormulaPlaceholders as restore} from '../src/formula-placeholders.mjs';
4-
test('restores upstream numbered tokens and an unambiguous wildcard from cached layout',()=>{
5-
const base={text:'Original x',sourceInput:'Original {{v2}}',formulaTexts:['a','b','x']};
6-
for(const token of ['{v2}','{{v2}}','{V 2}','{v*}'])assert.equal(restore({...base,translation:`译文${token}。`}).translation,'译文x。');
7-
});
84
test('ambiguous and invalid placeholders preserve original content',()=>{
95
const base={text:'Original x y',sourceInput:'{{v0}} {{v1}}',formulaTexts:['x','y']};
106
assert.equal(restore({...base,translation:'译文{v*}'}).translation,base.text);

‎server/layout-extraction.test.mjs‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,9 @@ import {createLayoutExtraction} from './layout-extraction.mjs';
66

77
const pause=ms=>new Promise(resolve=>setTimeout(resolve,ms));
88

9-
test('coalesces same-entry requests, sorts and deduplicates pages, and splits by one-indexed page',async()=>{
10-
const calls=[];const service=createLayoutExtraction({extractor:async(bytes,pages,options)=>{calls.push({bytes,pages:[...pages],options});return pages.flatMap(page=>[{page,text:`page-${page}`}]);}});
11-
const entry={id:'fixture',bytes:Buffer.from('%PDF')};
12-
const values=await Promise.all([service.extractPage(entry,3),service.extractPage(entry,1),service.extractPage(entry,3),service.extractPage(entry,2),service.extractPage(entry,2)]);
13-
assert.deepEqual(calls,[{bytes:entry.bytes,pages:[1,2,3],options:{frame:'display'}}]);assert.deepEqual(values.map(items=>items[0].page),[3,1,3,2,2]);assert.deepEqual(service.stats(entry),{pages:3,bytes:jsonSize([{page:1,text:'page-1'}])+jsonSize([{page:2,text:'page-2'}])+jsonSize([{page:3,text:'page-3'}]),pendingPages:0});
14-
const before=calls.length;assert.deepEqual(await service.extractPage(entry,1),[{page:1,text:'page-1'}]);assert.equal(calls.length,before);
15-
});
16-
179
test('cleanup cancels pending and in-flight waiters and ignores late native results',async()=>{
1810
let release;let calls=0;const service=createLayoutExtraction({extractor:async(_bytes,pages)=>{calls++;return new Promise(resolve=>{release=()=>resolve(pages.map(page=>({page})));});}});const entry={id:'cleanup-inflight',bytes:Buffer.from('%PDF')};
1911
const pendingEntry={id:'cleanup-pending',bytes:Buffer.from('%PDF')};const pending=service.extractPage(pendingEntry,1);assert.equal(service.cleanup(pendingEntry),true);await assert.rejects(pending,/cleaned up/);
2012
const waiting=service.extractPage(entry,1);await pause(8);const oldRelease=release;assert.equal(typeof oldRelease,'function');assert.equal(service.cleanup(entry),true);await assert.rejects(waiting,/cleaned up/);oldRelease();await pause(2);assert.deepEqual(service.stats(entry),{pages:0,bytes:0,pendingPages:0});
2113
const next=service.extractPage(entry,1);await pause(8);assert.equal(calls,2);const newRelease=release;assert.equal(typeof newRelease,'function');newRelease();assert.deepEqual(await next,[{page:1}]);
2214
});
23-
24-
test('limits cache by exact JSON bytes and page count with LRU eviction',async()=>{
25-
const service=createLayoutExtraction({maxPages:2,maxBytes:100,extractor:async(_bytes,pages)=>pages.map(page=>({page,text:'x'.repeat(page*20)}))});
26-
const entry={id:'cache',bytes:Buffer.from('%PDF')};await service.extractPage(entry,1);await service.extractPage(entry,2);assert.deepEqual(service.stats(entry),{pages:1,bytes:jsonSize([{page:2,text:'x'.repeat(40)}]),pendingPages:0});
27-
await service.extractPage(entry,3);const current=service.stats(entry);assert.ok(current.pages<=2);assert.ok(current.bytes<=100);assert.deepEqual(await service.extractPage(entry,1),[{page:1,text:'x'.repeat(20)}]);
28-
});
29-
30-
function jsonSize(value){return Buffer.byteLength(JSON.stringify(value),'utf8');}

‎server/layout.test.mjs‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎server/pdf-navigation.test.mjs‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,3 @@ test('named and explicit PDF destinations resolve page references and reject mis
99
assert.equal(await resolvePDFDestination(pdf,'missing'),null);
1010
assert.equal(await resolvePDFDestination(pdf,[9,{name:'Fit'}]),null);
1111
});
12-
test('destination coordinates use the PDF viewport including nonzero page origins',()=>{
13-
const page={view:[10,20,510,720],getViewport:({scale})=>({width:500*scale,height:700*scale,convertToViewportPoint:(x,y)=>[(x-10)*scale,(720-y)*scale]})};
14-
for(const [dest,point] of [ [[0,{name:'XYZ'},40,600,null],{x:60,y:240}],[[0,{name:'FitH'},600],{x:0,y:240}],[[0,{name:'FitV'},40],{x:60,y:0}],[[0,{name:'FitR'},40,100,300,600],{x:60,y:240}],[[0,{name:'Fit'}],{x:0,y:0}],[[0,{name:'XYZ'},null,null,null],{x:0,y:0}] ])assert.deepEqual(destinationPoint(page,dest,2),point);
15-
});
16-
17-
test('PDF fit and explicit zoom destinations select the destination scale',()=>{
18-
const page={getViewport:()=>({width:500,height:700,convertToViewportPoint:(x,y)=>[x,700-y]})};
19-
assert.equal(destinationScale(page,[0,{name:'XYZ'},0,500,2],1,1000,700),2);
20-
assert.equal(destinationScale(page,[0,{name:'Fit'}],2,1000,700),1);
21-
assert.equal(destinationScale(page,[0,{name:'FitH'},650],1,1000,700),2);
22-
assert.equal(destinationScale(page,[0,{name:'FitR'},0,0,250,350],1,1000,700),2);
23-
});

‎server/reader-layout.test.mjs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import {test} from 'node:test';import assert from 'node:assert/strict';
22
import {buildReaderLayout,visibleReaderWindow,buildThumbnailLayout,visibleThumbnailWindow} from '../src/reader-layout.mjs';
33
const pages=Array.from({length:1000},(_,i)=>({number:i+1,width:i%2?792:612,height:i%2?612:792}));
4-
test('mixed-size row geometry preserves column widths, gaps and four buffered rows',()=>{for(const columns of [1,2,4]){const layout=buildReaderLayout(pages,1,'vertical',columns),row=layout.rows[80],bounds={top:row.offset+100,bottom:row.offset+600,left:0,right:layout.width};const result=visibleReaderWindow(layout,bounds);assert.equal(result.firstRow,76);assert.equal(result.lastRow,84);assert.equal(result.numbers.length,9*columns);assert.equal(layout.frames[columns].y-layout.frames[0].height,24);assert.ok(result.visible.every(v=>v.row===80));assert.equal(layout.height,layout.rows.at(-1).offset+layout.rows.at(-1).extent);}});
5-
64
test('mixed orientations use a fixed horizontal gap and center each packed row',()=>{
75
const input=[{number:1,width:400,height:600},{number:2,width:400,height:600},{number:3,width:600,height:400},{number:4,width:400,height:600}];
86
const layout=buildReaderLayout(input,1,'vertical',2,24,2);

0 commit comments

Comments
 (0)