Api: dzien z aktywna sesja nie wygasa o polnocy (trening nie jest przerywany; twardym limitem pozostaje 24h)

This commit is contained in:
Tilumca
2026-10-14 21:14:23 +02:00
parent 9937074577
commit c3f937f621
3 changed files with 26 additions and 9 deletions

View File

@@ -36,10 +36,16 @@ afterEach(() => {
});
describe('scheduler', () => {
it('auto-expires planned days before today', async () => {
it('auto-expires planned days before today, but not days with an in-progress session', async () => {
await tickOnce();
expect(planDayUpdateMany).toHaveBeenCalledWith({
where: { status: 'PLANNED', date: { lt: new Date(2026, 7, 22) } },
where: {
status: 'PLANNED',
date: { lt: new Date(2026, 7, 22) },
// północ nie może przerwać trwającego treningu — dzień z sesją IN_PROGRESS
// nie wygasa; domknie go ukończenie sesji albo reguła 24h
sessions: { none: { status: 'IN_PROGRESS' } },
},
data: { status: 'SKIPPED', skippedAt: expect.any(Date) },
});
expect(planDayUpdateMany.mock.calls[0][0].data.skippedAt).toEqual(NOW);