fix: Failing futureLimit handleNewBooking test (#15155)

This commit is contained in:
Hariom Balhara
2024-05-22 14:44:56 +05:30
committed by GitHub
parent aca2b29aa4
commit 4217efc5a8
2 changed files with 7 additions and 4 deletions
@@ -653,6 +653,8 @@ export async function createOrganization(orgData: {
* - `monthIncrement` adds the increment to current month
* - `yearIncrement` adds the increment to current year
* - `fromDate` starts incrementing from this date (default: today)
* @deprecated Stop using this function as it is not timezone aware and can return wrong date depending on the time of the day and timezone. Instead
* use vi.setSystemTime to fix the date and time and then use hardcoded days instead of dynamic date calculation.
*/
export const getDate = (
param: {
@@ -687,11 +687,12 @@ describe("handleNewBooking", () => {
timeout
);
// FIXME: Test is flaky, sometimes it fails on CI. It resolves instead of rejecting.
describe.skipIf(true)("Future Limits", () => {
describe("Future Limits", () => {
test(
`should fail booking if periodType=ROLLING check fails`,
async () => {
// In IST it is 2024-05-22 12:39am
vi.setSystemTime("2024-05-21T19:09:13Z");
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const booker = getBooker({
email: "booker@example.com",
@@ -721,7 +722,7 @@ describe("handleNewBooking", () => {
id: 1,
slotInterval: 30,
periodType: PeriodType.ROLLING,
// Today, plus1 and plus2
// 22st, 23nd and 24th in IST availability(Schedule being used is ISTWorkHours)
periodDays: 2,
periodCountCalendarDays: true,
length: 30,
@@ -738,7 +739,7 @@ describe("handleNewBooking", () => {
})
);
const plus3DateString = getDate({ dateIncrement: 3 }).dateString;
const plus3DateString = `2024-05-25`;
const mockBookingData = getMockRequestDataForBooking({
data: {
user: organizer.username,