fix: close discovery dispatch and persistent UI state races

This commit is contained in:
abaishu0730 committed 2026-10-19 14:33:09 +08:00
1 parent 0a366f43d6
commit 9d8d6971c1
19 files changed
+237 -77

No files matched your search

+2 -1
View File
@@ -87,11 +87,12 @@ test('pausing a rule prevents a prepared batch from entering SMTP sending',t=>{
store.pause(rule.id,{version:rule.version},'admin');assert.throws(()=>store.beginSending(batch.id),e=>e.status===409);
assert.equal(store.snapshot().batches[0].status,'prepared');
});
test('late discovered pre-cutoff orders cannot create a second email for an already frozen category and slot',t=>{
test('late discovery rebuilds an unsent reservation as one complete batch and never carries it into a later slot',t=>{
const {store}=fixture(t,{capabilities:{liveTodo:true,pdfExport:true,automaticArchive:true}}),sample=configure(store);
const archive=(sample)=>{const order=store.ingest(sample,'system');store.recordArchive(order.id,{files:[{name:order.id+'.pdf',path:'C:\\archive\\'+order.id+'.pdf',sha256:'a'.repeat(64),size:42,kind:'pdf'}],archivedAt:'2026-10-19T01:05:00Z'},'archive-executor');return order;};
archive(sample);assert.equal(store.prepare('2026-10-19T03:00:00Z','admin').length,1);
archive({...sample,instanceId:'late',taskId:'late'});
const replacement=store.prepare('2026-10-19T03:00:00Z','admin');assert.equal(replacement.length,1);assert.equal(replacement[0].orderIds.length,2);assert.equal(store.snapshot().batches.filter(b=>b.status==='prepared').length,1);
assert.equal(store.prepare('2026-10-19T03:00:00Z','admin').length,0);
assert.equal(store.prepare('2026-10-19T09:00:00Z','admin').length,0);
assert.equal(store.snapshot().orders.filter(o=>o.status==='ignored').length,2);