import test from 'node:test'; import assert from 'node:assert/strict'; import {draftReviewEntries,incompleteRecipientReview,reviewComplete} from '../src/core/draft-review.ts'; import {workspaceTasks,shortcutOrder} from '../src/core/workspace-tasks.ts'; import {modules} from '../src/core/modules.ts'; test('long mobile drafts retain every nested change and require every review page',()=>{ const prices=Array.from({length:54},(_,id)=>({id}));const draft={rows:[{_referencePricePreview:prices,_quotePreview:[{name:'末尾报价'}]},{_historyPreview:{name:'末尾历史'}}]}; const entries=draftReviewEntries(draft);assert.equal(entries.filter(e=>e.kind==='reference').length,54);assert.equal(entries.at(-1).value.name,'末尾历史'); const pages=Math.ceil(entries.length/20);assert.equal(reviewComplete(pages,[0,2]),false);assert.equal(reviewComplete(pages,[0,1,2]),true);assert.equal(reviewComplete(0,[]),false); }); test('large broadcasts cannot execute against a partial recipient preview',()=>{ const row={_notificationPreview:{recipientCount:50,recipients:Array.from({length:20},(_,id)=>({id}))}}; assert.equal(incompleteRecipientReview({action:'notification.send',rows:[row]}),true); row._notificationPreview.recipients=Array.from({length:50},(_,id)=>({id}));assert.equal(incompleteRecipientReview({action:'notification.send',rows:[row]}),false); assert.equal(draftReviewEntries({rows:[row]}).filter(e=>e.kind==='recipient').length,50); }); test('workspace tasks count only allowed modules using list-compatible server filters',()=>{ assert.deepEqual(workspaceTasks(modules.filter(m=>m.key==='stock')),[]); const tasks=workspaceTasks(modules);assert.equal(tasks.length,3);assert.equal(tasks.find(t=>t.id==='accept'),undefined); assert.deepEqual(tasks.find(t=>t.id==='check').openQuery,{checkStatus:0});assert.equal(tasks.find(t=>t.id==='pending').query.inStatus,0); }); test('personal shortcuts cannot restore forbidden entries and preserve user order',()=>{ const permitted=modules.filter(m=>['stock','use'].includes(m.key));assert.deepEqual(shortcutOrder(['use','arrival','stock','use',null],permitted),['use','stock']);assert.deepEqual(shortcutOrder([],permitted),[]); });