diff --git a/apps/server/src/services/__tests__/rollUtils.test.ts b/apps/server/src/services/__tests__/rollUtils.test.ts index b8f3d2af3..daf737ddd 100644 --- a/apps/server/src/services/__tests__/rollUtils.test.ts +++ b/apps/server/src/services/__tests__/rollUtils.test.ts @@ -280,6 +280,42 @@ describe('loadRoll() handle rundowns with several days', () => { expect(state).toMatchObject(expected); }); + it('should find the correct event, when we have events of zero duration', () => { + const now = 20 * MILLIS_PER_HOUR + 37 * MILLIS_PER_MINUTE; + const timedEvents = [ + { + id: '0', + timeStart: 18 * MILLIS_PER_HOUR, + timeEnd: 19 * MILLIS_PER_HOUR, + }, + { + id: '1 no duration', + timeStart: 0, + timeEnd: 0, + }, + { + id: '2', + timeStart: 19 * MILLIS_PER_HOUR, + timeEnd: 20 * MILLIS_PER_HOUR, + }, + { + id: '3 no duration', + timeStart: 0, + timeEnd: 0, + }, + { + id: '4', + timeStart: 20 * MILLIS_PER_HOUR, + timeEnd: 21 * MILLIS_PER_HOUR, + }, + ]; + + const state = loadRoll(prepareTimedEvents(timedEvents), now); + const expected = { + event: timedEvents[4], + index: 4, + }; + expect(state).toMatchObject(expected); }); }); diff --git a/apps/server/src/services/rollUtils.ts b/apps/server/src/services/rollUtils.ts index f8d3650e9..b2f7f9bbe 100644 --- a/apps/server/src/services/rollUtils.ts +++ b/apps/server/src/services/rollUtils.ts @@ -31,6 +31,10 @@ export function loadRoll( continue; } + if (event.duration === 0) { + continue; + } + // we check if event crosses midnight if (event.timeStart > event.timeEnd) { daySpan++;