fix: separate pending and sent mail batches
This commit is contained in:
1 parent
fd2dd557c7
commit
5fe461c77d
7 files changed
+50
-8
No files matched your search
@@ -60,6 +60,16 @@ test('batch pagination covers more than three pages and scope all retains comple
|
||||
const c=fixture();for(let i=0;i<85;i++)c.orderRules.all('batches').push({id:'b'+i,orderIds:['o0'],status:i===0?'sent':'prepared',subject:'Batch '+i});
|
||||
const active=queryBatches(c,{page:999,pageSize:25},user);assert.equal(active.page,4);assert.equal(active.total,85);assert.equal(active.items.length,10);assert.equal(queryBatches(c,{scope:'all'},user).total,86);
|
||||
});
|
||||
|
||||
test('sent batches have a dedicated history scope and status-only links never hide sent records',()=>{
|
||||
const c=fixture(),batches=c.orderRules.all('batches');
|
||||
batches.push({id:'delivered',orderIds:['o0'],status:'sent',subject:'Sent notice',sentAt:'2026-10-26T03:00:00Z'},{id:'cancelled',orderIds:['o0'],status:'cancelled'},{id:'private-sent',orderIds:['foreign'],status:'sent'});
|
||||
const history=queryBatches(c,{scope:'sent'},user);assert.deepEqual(history.items.map(b=>b.id),['delivered']);assert.equal(history.items[0].sentAt,'2026-10-26T03:00:00Z');
|
||||
assert.deepEqual(queryBatches(c,{status:'sent'},user).items.map(b=>b.id),['delivered']);
|
||||
assert.deepEqual(queryBatches(c,{},user).items.map(b=>b.id),['old']);
|
||||
assert.equal(queryBatches(c,{scope:'all'},user).total,3);
|
||||
assert.equal(queryBatches(c,{scope:'sent',status:'unknown'},user).total,0);
|
||||
});
|
||||
test('HTTP query routing rejects missing services, invalid parameters and malformed encoding',async()=>{
|
||||
const {orderRuleQueryApi}=require('../../src/modules/order-rules/query-api.cjs');const c=fixture(),invoke=(route,extra={})=>orderRuleQueryApi({...c,user,route,method:'GET',url:new URL(route,'http://localhost'),reply(){},...extra});
|
||||
await assert.rejects(()=>invoke('/api/order-rules/orders?unused=1',{route:'/api/order-rules/orders'}),e=>e.status===400||e.statusCode===400);
|
||||
|
||||
Reference in new issue
Block a user