diff --git a/defaultmodules/calendar/calendar.js b/defaultmodules/calendar/calendar.js index a183884db5..61ea7e3d81 100644 --- a/defaultmodules/calendar/calendar.js +++ b/defaultmodules/calendar/calendar.js @@ -595,9 +595,9 @@ Module.register("calendar", { if (eventsByDate[dateStr] && eventsByDate[dateStr].length > 0) { // If there are any events today then get all those events and select the currently active events and the events that are starting later in the day. newEvents.push(...eventsByDate[dateStr].filter((ev) => this.timestampToMoment(ev.endDate).isAfter(moment()))); - // Since we found a day with events, increase the daysCollected by 1 - daysCollected++; } + // Increment the daysCollected by one to ensure the while loop does not get stuck. + daysCollected++; // Search for the next day currentDate.add(1, "day"); } diff --git a/tests/configs/modules/calendar/empty-day.js b/tests/configs/modules/calendar/empty-day.js new file mode 100644 index 0000000000..ea2fcfe34f --- /dev/null +++ b/tests/configs/modules/calendar/empty-day.js @@ -0,0 +1,25 @@ +const config = { + address: "0.0.0.0", + ipWhitelist: [], + timeFormat: 12, + + modules: [ + { + module: "calendar", + position: "bottom_bar", + config: { + limitDays: 3, + calendars: [ + { + url: "http://localhost:8080/tests/mocks/calendar_test_empty_day.ics" + } + ] + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/electron/modules/calendar_spec.js b/tests/electron/modules/calendar_spec.js index 3fb1392748..ea9d898db8 100644 --- a/tests/electron/modules/calendar_spec.js +++ b/tests/electron/modules/calendar_spec.js @@ -96,6 +96,14 @@ describe("Calendar module", () => { }); }); + describe("Empty calendar days", () => { + it("shows events scheduled after an empty calendar day (issue #4243)", async () => { + // event is on day 3 of the limitDays:3 window, days 1-2 are intentionally empty + await helpers.startApplication("tests/configs/modules/calendar/empty-day.js", "01 Jan 2030 12:30:00 GMT"); + await expect(doTestCount()).resolves.toBe(1); + }); + }); + /* * RRULE TESTS: * Add any tests that check rrule functionality here. diff --git a/tests/mocks/calendar_test_empty_day.ics b/tests/mocks/calendar_test_empty_day.ics new file mode 100644 index 0000000000..0833d4dadc --- /dev/null +++ b/tests/mocks/calendar_test_empty_day.ics @@ -0,0 +1,11 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//MagicMirror//Calendar Test//EN +BEGIN:VEVENT +UID:empty-day-test@magicmirror +DTSTAMP:20300101T000000Z +DTSTART;VALUE=DATE:20300103 +DTEND;VALUE=DATE:20300104 +SUMMARY:Event after empty day +END:VEVENT +END:VCALENDAR