fix: Stores the DateRange in UTC instead of user machine that caused the bug (#26900)

* fix init

* remove comment

* fix to v2

* type fix

* edge case

* test fix to suit the date storage method

* fix for atoms

* backward compatibility

* fix test mock

* test fix?

* testing a theory

* address cubic
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2026-01-19 10:41:53 +02:00
1 parent 9f0d035a3b
commit c1d0a6bb1b
7 files changed
+647 -89

No files matched your search

@@ -1,8 +1,8 @@
import {
TestData,
Timezones,
createBookingScenario,
replaceDates,
TestData,
Timezones,
} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import type { ScenarioData } from "@calcom/testing/lib/bookingScenario/bookingScenario";
@@ -1489,13 +1489,12 @@ describe("getSchedule", () => {
{
id: 1,
length: 60,
// Makes today and tomorrow only available
// Makes plus1 and plus2 dates only available (June 1-2 in event timezone)
// Period dates are now stored as UTC midnight for the selected date
...getPeriodTypeData({
type: "RANGE",
// dayPlus1InIst
periodStartDate: new Date(`${todayDateString}T18:30:00.000Z`),
// datePlus2InIst
periodEndDate: new Date(`${plus1DateString}T18:30:00.000Z`),
periodStartDate: new Date(`${plus1DateString}T00:00:00.000Z`), // June 1 UTC midnight
periodEndDate: new Date(`${plus2DateString}T00:00:00.000Z`), // June 2 UTC midnight
periodCountCalendarDays: true,
}),
users: [
@@ -1574,14 +1573,12 @@ describe("getSchedule", () => {
{
id: 1,
length: 60,
// Makes today and tomorrow only available
// Makes 25th and 26th July (in event timezone) available
// Period dates are now stored as UTC midnight for the selected date
...getPeriodTypeData({
type: "RANGE",
// Only 25th and 26th(as per the event timezone(IST)) should be available
periodStartDate: new Date(`2024-07-24T18:30:00.000Z`), // 25th July in IST
periodEndDate: new Date(`2024-07-25T18:30:00.000Z`), // 26th July in IST
periodStartDate: new Date(`2024-07-25T00:00:00.000Z`), // July 25 UTC midnight
periodEndDate: new Date(`2024-07-26T00:00:00.000Z`), // July 26 UTC midnight
periodCountCalendarDays: true,
}),
users: [
@@ -1614,23 +1611,17 @@ describe("getSchedule", () => {
orgSlug: null,
},
});
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-21",
});
/**
* Current day in test is 5th July, so verify that earlier timeslots than 24th July are disabled
*/
{
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-21",
});
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-22",
});
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-22",
});
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-23",
});
}
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-23",
});
expect(scheduleForEventForPagoTz).toHaveTimeSlots(
[
@@ -1670,19 +1661,13 @@ describe("getSchedule", () => {
dateString: "2024-07-26",
doExactMatch: true,
});
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-27",
});
/**
* Verify that timeslots beyond 26th July are disabled
*/
{
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-27",
});
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-28",
});
}
expect(scheduleForEventForPagoTz).toHaveDateDisabled({
dateString: "2024-07-28",
});
});
});
});