Prepare worker and Discord snapshots through bounded catch-up

This commit is contained in:
syntaxbullet
2026-09-08 16:21:37 +02:00
parent c3b52e8fe1
commit 149ec36c77
8 changed files with 99 additions and 54 deletions

View File

@@ -231,3 +231,17 @@ test('delivered slots skip habit evaluation while later slots and retries remain
await tick('10:00'); expect(sync).toHaveBeenCalled(); expect(sent).toHaveLength(2);
} finally { sync?.mockRestore(); f.close(); }
});
test('reminder catch-up yields and rechecks opt-out before claiming or sending', async () => {
const f = fixture(); let requests = 0;
try {
await f.json('/habits', 'POST', { name: 'Backlog', method: 'tasks', tasks: Array.from({ length: 50 }, (_, i) => ({ name: `Task ${i}` })) }, 201);
f.db.insert(reminderSettings).values({ userId: 'alice', ...defaultReminder, enabled: true, updatedAt: 0 }).run();
const work = sendDueReminders(f.db, config, async () => { requests++; throw new Error('No sends expected'); }, () => Date.parse('2027-09-04T18:00:00Z'));
await new Promise(resolve => setTimeout(resolve, 0));
f.db.update(reminderSettings).set({ enabled: false }).run();
await work;
expect(requests).toBe(0);
expect(f.db.select().from(reminderDeliveries).all()).toHaveLength(0);
} finally { f.close(); }
});