Scheduling infrastructure for absolutely everyone.
Fixes that sometimes last shown slot was unavailable (#7804)
Carina Wollendorfer6128be886098
diff --git a/apps/web/test/lib/slots.test.ts b/apps/web/test/lib/slots.test.tsindex 0c8407f8599..b2e4349effd 100644--- a/apps/web/test/lib/slots.test.ts+++ b/apps/web/test/lib/slots.test.ts@@ -112,4 +112,25 @@ describe("Tests the slot logic", () => {})).toHaveLength(11);});++ it("shows correct time slots for 20 minutes long events with working hours that do not end at a full hour ", async () => {+ // 72 20-minutes events in a 24h day+ expect(+ getSlots({+ inviteeDate: dayjs.utc().add(1, "day"),+ frequency: 20,+ minimumBookingNotice: 0,+ workingHours: [+ {+ userId: 1,+ days: Array.from(Array(7).keys()),+ startTime: MINUTES_DAY_START,+ endTime: MINUTES_DAY_END - 14, // 23:45+ },+ ],+ eventLength: 20,+ organizerTimeZone: "America/Toronto",+ })+ ).toHaveLength(71);+ });});diff --git a/packages/lib/slots.ts b/packages/lib/slots.tsindex 3ec13df18bc..4d65d228af7 100644--- a/packages/lib/slots.ts+++ b/packages/lib/slots.ts@@ -87,7 +87,7 @@ function buildSlots({for (let slotStart = boundaryStart; slotStart < boundaryEnd; slotStart += frequency) {computedLocalAvailability.forEach((item) => {// TODO: This logic does not allow for past-midnight bookings.- if (slotStart < item.startTime || slotStart > item.endTime + 15 - eventLength) {+ if (slotStart < item.startTime || slotStart > item.endTime + 1 - eventLength) {return;}slotsTimeFrameAvailable[slotStart.toString()] = {