refactor: GetAvailableSlotsService (#22321)

* refactor: GetAvailableSlotsService

* chore: add todo comments where DI is needed

* chore: bump platform libs
This commit is contained in:
Morgan authored and GitHub committed 2025-07-08 16:54:45 -04:00
1 parent 0c182e2813
commit c3dab3e4f8
18 files changed
+1337 -1277

No files matched your search

+95 -90
View File
@@ -17,7 +17,7 @@ import { describe, vi, test } from "vitest";
import dayjs from "@calcom/dayjs";
import { SchedulingType, type BookingStatus } from "@calcom/prisma/enums";
import { getAvailableSlots as getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
import { expect, expectedSlotsForSchedule } from "./getSchedule/expects";
import { setupAndTeardown } from "./getSchedule/setupAndTeardown";
@@ -31,6 +31,7 @@ vi.mock("@calcom/lib/constants", () => ({
}));
describe("getSchedule", () => {
const availableSlotsService = new AvailableSlotsService();
setupAndTeardown();
// TODO: Move these inside describe('Team Event')
@@ -113,7 +114,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithLeadSkip = await getSchedule({
const scheduleWithLeadSkip = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -134,7 +135,7 @@ describe("getSchedule", () => {
}
);
const scheduleWithoutLeadSkip = await getSchedule({
const scheduleWithoutLeadSkip = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -262,7 +263,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleFixedHostLead = await getSchedule({
const scheduleFixedHostLead = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -291,7 +292,7 @@ describe("getSchedule", () => {
}
);
const scheduleRRHostLead = await getSchedule({
const scheduleRRHostLead = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -392,7 +393,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithLeadSkip = await getSchedule({
const scheduleWithLeadSkip = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -526,7 +527,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithLeadSkip = await getSchedule({
const scheduleWithLeadSkip = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -623,7 +624,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithLeadSkip = await getSchedule({
const scheduleWithLeadSkip = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -732,7 +733,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithLeadSkip = await getSchedule({
const scheduleWithLeadSkip = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -829,7 +830,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithLeadSkip = await getSchedule({
const scheduleWithLeadSkip = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -926,7 +927,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWhenContactOwnerIsSkipped = await getSchedule({
const scheduleWhenContactOwnerIsSkipped = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1030,7 +1031,7 @@ describe("getSchedule", () => {
});
// Day Plus 2 is completely free - It only has non accepted bookings
const scheduleOnCompletelyFreeDay = await getSchedule({
const scheduleOnCompletelyFreeDay = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
// EventTypeSlug doesn't matter for non-dynamic events
@@ -1064,7 +1065,7 @@ describe("getSchedule", () => {
);
// Day plus 3
const scheduleForDayWithOneBooking = await getSchedule({
const scheduleForDayWithOneBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1130,7 +1131,7 @@ describe("getSchedule", () => {
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const scheduleForEventWith30Length = await getSchedule({
const scheduleForEventWith30Length = await availableSlotsService.getAvailableSlots({
input: {
orgSlug: null,
eventTypeId: 1,
@@ -1167,17 +1168,18 @@ describe("getSchedule", () => {
}
);
const scheduleForEventWith30minsLengthAndSlotInterval2hrs = await getSchedule({
input: {
orgSlug: null,
eventTypeId: 2,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: false,
},
});
const scheduleForEventWith30minsLengthAndSlotInterval2hrs =
await availableSlotsService.getAvailableSlots({
input: {
orgSlug: null,
eventTypeId: 2,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: false,
},
});
// `slotInterval` takes precedence over `length`
// 4:30 is utc so it is 10:00 in IST
expect(scheduleForEventWith30minsLengthAndSlotInterval2hrs).toHaveTimeSlots(
@@ -1227,7 +1229,7 @@ describe("getSchedule", () => {
// Time Travel to the beginning of today after getting all the dates correctly.
timeTravelToTheBeginningOfToday({ utcOffsetInHours: 5.5 });
const scheduleForEventWithBookingNotice13Hrs = await getSchedule({
const scheduleForEventWithBookingNotice13Hrs = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1251,7 +1253,7 @@ describe("getSchedule", () => {
}
);
const scheduleForEventWithBookingNotice10Hrs = await getSchedule({
const scheduleForEventWithBookingNotice10Hrs = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -1314,7 +1316,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEventOnADayWithNonCalBooking = await getSchedule({
const scheduleForEventOnADayWithNonCalBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1389,7 +1391,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEventOnADayWithCalBooking = await getSchedule({
const scheduleForEventOnADayWithCalBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1448,7 +1450,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1513,7 +1515,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEventOnADayWithDateOverride = await getSchedule({
const scheduleForEventOnADayWithDateOverride = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1592,7 +1594,7 @@ describe("getSchedule", () => {
// Requesting this user's availability for their
// individual Event Type
const thisUserAvailability = await getSchedule({
const thisUserAvailability = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -1705,7 +1707,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const thisUserAvailabilityBookingLimitOne = await getSchedule({
const thisUserAvailabilityBookingLimitOne = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1717,7 +1719,7 @@ describe("getSchedule", () => {
},
});
const thisUserAvailabilityBookingLimitTwo = await getSchedule({
const thisUserAvailabilityBookingLimitTwo = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -1833,7 +1835,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const thisUserAvailabilityDurationLimitReached = await getSchedule({
const thisUserAvailabilityDurationLimitReached = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1845,7 +1847,7 @@ describe("getSchedule", () => {
},
});
const thisUserAvailabilityDurationLimitNotReached = await getSchedule({
const thisUserAvailabilityDurationLimitNotReached = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -1943,7 +1945,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const thisUserAvailabilityDurationLimit = await getSchedule({
const thisUserAvailabilityDurationLimit = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2039,7 +2041,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const weeklyAvailability = await getSchedule({
const weeklyAvailability = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2169,7 +2171,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const availabilityEventTypeOne = await getSchedule({
const availabilityEventTypeOne = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2190,7 +2192,7 @@ describe("getSchedule", () => {
expect(availableSlotsInTz.filter((slot) => slot.format().startsWith(plus2DateString)).length).toBe(0);
const availabilityEventTypeTwo = await getSchedule({
const availabilityEventTypeTwo = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -2211,7 +2213,7 @@ describe("getSchedule", () => {
expect(availableSlotsInTz2.filter((slot) => slot.format().startsWith(plus2DateString)).length).toBe(0);
const availabilityUserEventType = await getSchedule({
const availabilityUserEventType = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 3,
eventTypeSlug: "",
@@ -2327,7 +2329,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const eventType1Availability = await getSchedule({
const eventType1Availability = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2339,7 +2341,7 @@ describe("getSchedule", () => {
},
});
const eventType2Availability = await getSchedule({
const eventType2Availability = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -2387,7 +2389,7 @@ describe("getSchedule", () => {
],
});
const eventType2AvailabilityUpdated = await getSchedule({
const eventType2AvailabilityUpdated = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -2468,7 +2470,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const thisUserAvailabilityBookingLimit = await getSchedule({
const thisUserAvailabilityBookingLimit = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2583,7 +2585,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const availabilityEventTypeOne = await getSchedule({
const availabilityEventTypeOne = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2604,7 +2606,7 @@ describe("getSchedule", () => {
expect(availableSlotsInTz.filter((slot) => slot.format().startsWith(plus2DateString)).length).toBe(0); // 1 booking per day as limit
const availabilityEventTypeTwo = await getSchedule({
const availabilityEventTypeTwo = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -2624,7 +2626,7 @@ describe("getSchedule", () => {
expect(availableSlotsInTz.filter((slot) => slot.format().startsWith(plus2DateString)).length).toBe(0); // 1 booking per day as limit
const availabilityUserEventType = await getSchedule({
const availabilityUserEventType = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 3,
eventTypeSlug: "",
@@ -2708,7 +2710,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const thisUserAvailabilityBookingLimit = await getSchedule({
const thisUserAvailabilityBookingLimit = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2791,7 +2793,7 @@ describe("getSchedule", () => {
// Requesting this user's availability for their
// individual Event Type
const thisUserAvailability = await getSchedule({
const thisUserAvailability = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 2,
eventTypeSlug: "",
@@ -2862,7 +2864,7 @@ describe("getSchedule", () => {
],
});
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2961,7 +2963,7 @@ describe("getSchedule", () => {
],
});
const scheduleForTeamEventOnADayWithNoBooking = await getSchedule({
const scheduleForTeamEventOnADayWithNoBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -2992,17 +2994,18 @@ describe("getSchedule", () => {
}
);
const scheduleForTeamEventOnADayWithOneBookingForEachUser = await getSchedule({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
orgSlug: null,
},
});
const scheduleForTeamEventOnADayWithOneBookingForEachUser =
await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
orgSlug: null,
},
});
// A user with blocked time in another event, still affects Team Event availability
// It's a collective availability, so both user 101 and 102 are considered for timeslots
@@ -3101,17 +3104,18 @@ describe("getSchedule", () => {
},
],
});
const scheduleForTeamEventOnADayWithOneBookingForEachUserButOnDifferentTimeslots = await getSchedule({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
orgSlug: null,
},
});
const scheduleForTeamEventOnADayWithOneBookingForEachUserButOnDifferentTimeslots =
await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
orgSlug: null,
},
});
// A user with blocked time in another event, still affects Team Event availability
expect(scheduleForTeamEventOnADayWithOneBookingForEachUserButOnDifferentTimeslots).toHaveTimeSlots(
[
@@ -3130,17 +3134,18 @@ describe("getSchedule", () => {
{ dateString: plus2DateString }
);
const scheduleForTeamEventOnADayWithOneBookingForEachUserOnSameTimeSlot = await getSchedule({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus2DateString}T18:30:00.000Z`,
endTime: `${plus3DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
orgSlug: null,
},
});
const scheduleForTeamEventOnADayWithOneBookingForEachUserOnSameTimeSlot =
await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus2DateString}T18:30:00.000Z`,
endTime: `${plus3DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
orgSlug: null,
},
});
// A user with blocked time in another event, still affects Team Event availability
expect(scheduleForTeamEventOnADayWithOneBookingForEachUserOnSameTimeSlot).toHaveTimeSlots(
[
@@ -3195,7 +3200,7 @@ describe("getSchedule", () => {
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const getScheduleRes = await getSchedule({
const getScheduleRes = await availableSlotsService.getAvailableSlots({
input: {
eventTypeSlug: scenario.eventTypes[0]?.slug,
startTime: `${plus1DateString}T18:30:00.000Z`,
@@ -3275,7 +3280,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithHostChoosenSch = await getSchedule({
const scheduleWithHostChoosenSch = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -3341,7 +3346,7 @@ describe("getSchedule", () => {
bookings: [],
});
const scheduleWithEventCommonSch = await getSchedule({
const scheduleWithEventCommonSch = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -3422,7 +3427,7 @@ describe("getSchedule", () => {
],
});
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -3503,7 +3508,7 @@ describe("getSchedule", () => {
],
});
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -9,12 +9,13 @@ import {
import { describe, test } from "vitest";
import { getAvailableSlots as getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
import { expect, expectedSlotsForSchedule } from "./expects";
import { setupAndTeardown } from "./setupAndTeardown";
describe("getSchedule", () => {
const availableSlotsService = new AvailableSlotsService();
setupAndTeardown();
describe("Calendar event", () => {
test("correctly identifies unavailable slots from selected calendars at user level", async () => {
@@ -63,7 +64,7 @@ describe("getSchedule", () => {
// An event with one accepted booking
await createBookingScenario(scenarioData);
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
const scheduleForDayWithAGoogleCalendarBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -133,7 +134,7 @@ describe("getSchedule", () => {
// An event with one accepted booking
await createBookingScenario(scenarioData);
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
const scheduleForDayWithAGoogleCalendarBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId,
eventTypeSlug: "",
@@ -202,7 +203,7 @@ describe("getSchedule", () => {
// An event with one accepted booking
await createBookingScenario(scenarioData);
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
const scheduleForDayWithAGoogleCalendarBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId,
eventTypeSlug: "",
@@ -275,7 +276,7 @@ describe("getSchedule", () => {
// An event with one accepted booking
await createBookingScenario(scenarioData);
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
const scheduleForDayWithAGoogleCalendarBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId,
eventTypeSlug: "",
@@ -13,13 +13,14 @@ import { expectNoAttemptToGetAvailability } from "../../utils/bookingScenario/ex
import { describe, test } from "vitest";
import { MembershipRole } from "@calcom/prisma/enums";
import { getAvailableSlots as getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
import { expect, expectedSlotsForSchedule } from "./expects";
import { setupAndTeardown } from "./setupAndTeardown";
describe("getSchedule", () => {
setupAndTeardown();
describe("Delegation Credential", () => {
test("correctly identifies unavailable slots using DelegationCredential credentials", async () => {
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
@@ -89,8 +90,8 @@ describe("getSchedule", () => {
};
await createBookingScenario(scenarioData);
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
const availableSlotsService = new AvailableSlotsService();
const scheduleForDayWithAGoogleCalendarBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -181,8 +182,8 @@ describe("getSchedule", () => {
};
await createBookingScenario(scenarioData);
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
const availableSlotsService = new AvailableSlotsService();
const scheduleForDayWithAGoogleCalendarBooking = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -9,7 +9,7 @@ import type { ScenarioData } from "../../utils/bookingScenario/bookingScenario";
import { describe, expect, vi, test } from "vitest";
import { PeriodType } from "@calcom/prisma/enums";
import { getAvailableSlots as getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
import { expectedSlotsForSchedule } from "./expects";
import { setupAndTeardown } from "./setupAndTeardown";
@@ -70,6 +70,7 @@ vi.mock("@calcom/lib/constants", () => ({
}));
describe("getSchedule", () => {
const availableSlotsService = new AvailableSlotsService();
setupAndTeardown();
describe("Future Limits", () => {
describe("PeriodType=ROLLING", () => {
@@ -112,7 +113,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -200,7 +201,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -284,7 +285,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -379,7 +380,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -483,7 +484,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -573,7 +574,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -657,7 +658,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -780,7 +781,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -878,7 +879,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -979,7 +980,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1087,7 +1088,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1207,7 +1208,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1304,7 +1305,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1413,7 +1414,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1515,7 +1516,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEvent = await getSchedule({
const scheduleForEvent = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -1601,7 +1602,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const scheduleForEventForPagoTz = await getSchedule({
const scheduleForEventForPagoTz = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -11,7 +11,7 @@ import { describe, test, vi } from "vitest";
import type { z } from "zod";
import type { getScheduleSchema } from "@calcom/trpc/server/routers/viewer/slots/types";
import { getAvailableSlots as getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
import { expect } from "./expects";
import { setupAndTeardown } from "./setupAndTeardown";
@@ -89,6 +89,7 @@ async function setupTeamAndFeatures() {
}
describe("getSchedule", () => {
const availableSlotsService = new AvailableSlotsService();
setupAndTeardown();
describe("Restriction Schedule", () => {
@@ -156,7 +157,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const result = await getSchedule({
const result = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -252,7 +253,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const result = await getSchedule({
const result = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -353,7 +354,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const result = await getSchedule({
const result = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -438,7 +439,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const result = await getSchedule({
const result = await availableSlotsService.getAvailableSlots({
input: {
eventTypeId: 1,
eventTypeSlug: "",
@@ -12,7 +12,7 @@ import type { z } from "zod";
import { prisma } from "@calcom/prisma";
import type { getScheduleSchema, GetScheduleOptions } from "@calcom/trpc/server/routers/viewer/slots/types";
import { getAvailableSlots as getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
import { expect } from "./expects";
import { setupAndTeardown } from "./setupAndTeardown";
@@ -62,6 +62,7 @@ const getBaseScenarioData = (): ScheduleScenario => ({
});
describe("getSchedule", () => {
const availableSlotsService = new AvailableSlotsService();
setupAndTeardown();
describe("Reserved Slots", () => {
@@ -93,7 +94,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: getTestScheduleInput({ yesterdayDateString, plus5DateString }),
});
@@ -128,7 +129,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: getTestScheduleInput({ yesterdayDateString, plus5DateString }),
ctx: {
req: {
@@ -183,7 +184,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: getTestScheduleInput({ yesterdayDateString, plus5DateString }),
});
@@ -238,7 +239,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: getTestScheduleInput({ yesterdayDateString, plus5DateString }),
});
@@ -287,7 +288,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
const schedule = await getSchedule({
const schedule = await availableSlotsService.getAvailableSlots({
input: getTestScheduleInput({ yesterdayDateString, plus5DateString }),
});
@@ -366,7 +367,7 @@ describe("getSchedule", () => {
await createBookingScenario(scenarioData);
await getSchedule({
await availableSlotsService.getAvailableSlots({
input: getTestScheduleInput({ yesterdayDateString, plus5DateString }),
ctx: {
req: {