Fixes that sometimes last shown slot was unavailable (#7804)
* fix unavailable slots + add relevant test * code clean up --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
co-authored by
CarinaWolli
parent
13577a5dbe
commit
6128be8860
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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()] = {
|
||||
|
||||
Reference in New Issue
Block a user