fix: order calendar deadlines and surface undated tenders

This commit is contained in:
2026-09-06 14:05:24 +03:00
parent 2f34b42dc4
commit 6c33012ab8
4 changed files with 75 additions and 28 deletions
+19
View File
@@ -60,3 +60,22 @@ test('deadline ICS is a transparent instant, preserves UID across date changes a
assert.equal(hostile.split('\r\n').filter(line=>line==='BEGIN:VEVENT').length,1);
assert.equal(hostile.split('\r\n').filter(line=>line==='END:VEVENT').length,1);
});
test('calendar agenda sorts known times before unknown and preserves undated records',async()=>{
const {calendarAgenda}=await import('../src/services/tenderCalendar.js');
const now=new Date('2026-09-06T08:00:00Z');
const records=[
{id:'late',tarih:'10.09.2026',saat:'16:00'},
{id:'unknown',tarih:'10.09.2026'},
{id:'early',tarih:'10.09.2026',saat:'09:00'},
{id:'bad',tarih:'31.02.2026'},
{id:'missing'},
{id:'old',tarih:'01.09.2026',saat:'09:00',durum:'İptal'},
];
const agenda=calendarAgenda(records,now);
assert.deepEqual(agenda.days.get('2026-09-10').map(e=>e.tender.id),['early','late','unknown']);
assert.deepEqual(agenda.undated.map(e=>e.tender.id),['bad','missing']);
assert.equal(agenda.days.get('2026-09-01')[0].info.expired,true);
assert.equal([...agenda.days.values()].flat().length+agenda.undated.length,records.length);
assert.equal(records[0].id,'late');
});