diff --git a/api/src/__tests__/slots.test.ts b/api/src/__tests__/slots.test.ts index d7b7851..0730a31 100644 --- a/api/src/__tests__/slots.test.ts +++ b/api/src/__tests__/slots.test.ts @@ -203,6 +203,45 @@ describe("generateTimeSlots", () => { expect(slots).to.have.length(0); }); + it("should handle exception with date with minutes and seconds", () => { + const dayExceptionWithTime: Exception = { + date: "2024-01-16T10:30:45.123Z", // Date with time components + type: "day", + }; + + const slots = generateTimeSlots( + testDate, // currentTime + testDate, // date + basicAvailability, + basicEventTypeConfig, + [dayExceptionWithTime], + existingEvents + ); + + expect(slots).to.have.length(0); + }); + + it("should handle hours exception with date containing time components", () => { + const hoursExceptionWithTime: Exception = { + date: "2024-01-16T10:30:45.123Z", // Date with time components + type: "hours", + hours: [{ start: "10:00", end: "12:00" }], + }; + + const slots = generateTimeSlots( + testDate, // currentTime + testDate, // date + basicAvailability, + basicEventTypeConfig, + [hoursExceptionWithTime], + existingEvents + ); + + expect(slots).to.have.length(4); // 2 hours * 2 slots per hour + expect(slots[0].time).to.equal("10:00"); + expect(slots[3].time).to.equal("11:30"); + }); + it("should use exception hours instead of regular availability", () => { const hoursException: Exception = { date: "2024-01-16", diff --git a/api/src/slots.ts b/api/src/slots.ts index 92e061a..e769789 100644 --- a/api/src/slots.ts +++ b/api/src/slots.ts @@ -193,7 +193,12 @@ export function generateTimeSlots( const slots: TimeSlot[] = []; // Check if this date has an exception - const exception = exceptions.find((e) => e.date === dateStr); + const exception = exceptions.find((e) => { + const exceptionDate = new Date(e.date); + const exceptionDateCET = convertToCET(exceptionDate); + const exceptionDateStr = getDateString(exceptionDateCET); + return exceptionDateStr === dateStr; + }); // If there's a "day" exception, no slots available if (exception?.type === "day") {