fix: close order intake five minutes before scheduled mail
This commit is contained in:
1 parent
5fe461c77d
commit
4d8f393895
17 files changed
+137
-24
No files matched your search
@@ -2,6 +2,14 @@
|
||||
const {test}=require('node:test');const assert=require('node:assert/strict');
|
||||
const {windowForCutoff,upcomingWindow,inWindow}=require('../../src/modules/order-rules/window.cjs');
|
||||
const schedule={times:['11:00','17:00'],timezone:'Asia/Shanghai',weekends:false};
|
||||
|
||||
test('five minute intake deadline partitions arrivals without a gap across send times and weekends',()=>{
|
||||
const morning=windowForCutoff('2026-10-26T03:00:00Z',schedule),afternoon=windowForCutoff('2026-10-26T09:00:00Z',schedule),next=windowForCutoff('2026-10-27T03:00:00Z',schedule);
|
||||
assert.equal(morning.end,'2026-10-26T03:00:00.000Z');assert.equal(morning.collectionEnd,'2026-10-26T02:55:00.000Z');assert.equal(morning.collectionStart,'2026-10-23T08:55:00.000Z');
|
||||
for(const [at,want]of [['2026-10-26T02:54:59.999Z',true],['2026-10-26T02:55:00Z',false],['2026-10-26T02:59:59Z',false]])assert.equal(inWindow(at,morning),want);
|
||||
assert.equal(inWindow('2026-10-26T02:55:00Z',afternoon),true);assert.equal(inWindow('2026-10-26T02:59:59Z',afternoon),true);assert.equal(inWindow('2026-10-26T08:55:00Z',afternoon),false);assert.equal(inWindow('2026-10-26T08:55:00Z',next),true);
|
||||
const legacy={start:'2026-10-26T03:00:00Z',end:'2026-10-26T09:00:00Z'};assert.equal(inWindow('2026-10-26T08:59:59Z',legacy),true);
|
||||
});
|
||||
test('normal weekday first interval continuously covers prior evening',()=>{
|
||||
const morning=windowForCutoff('2026-10-20T03:00:00Z',schedule),afternoon=windowForCutoff('2026-10-20T09:00:00Z',schedule);
|
||||
assert.equal(morning.start,'2026-10-19T09:00:00.000Z');assert.equal(morning.end,'2026-10-20T03:00:00.000Z');
|
||||
@@ -12,7 +20,7 @@ test('normal weekday first interval continuously covers prior evening',()=>{
|
||||
test('Monday first mail covers last workday final cutoff through Monday morning, never older history',()=>{
|
||||
const window=windowForCutoff('2026-10-19T03:00:00Z',schedule);
|
||||
assert.equal(window.start,'2026-10-16T09:00:00.000Z');assert.equal(window.end,'2026-10-19T03:00:00.000Z');
|
||||
assert.equal(inWindow('2026-10-16T08:59:59Z',window),false);assert.equal(inWindow('2026-10-17T10:00:00Z',window),true);
|
||||
assert.equal(inWindow('2026-10-16T08:54:59Z',window),false);assert.equal(inWindow('2026-10-17T10:00:00Z',window),true);
|
||||
});
|
||||
test('business calendar determines previous actual working day across a rest period',()=>{
|
||||
const window=windowForCutoff('2026-10-19T03:00:00Z',schedule,[{date:'2026-10-16',kind:'restday',send:false,scan:false}]);
|
||||
|
||||
Reference in new issue
Block a user