fix: event api accepts invalid start & end values (#13203)

* fix: event api accepts invalid start & end values

* fix: unit tests

* test: added 'event length check during booking'

* test: fix unit test

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
This commit is contained in:
Mehul
2024-01-20 17:31:11 +00:00
committed by GitHub
co-authored by Keith Williams
parent da026d909d
commit 95e037c664
6 changed files with 288 additions and 207 deletions
@@ -1099,6 +1099,15 @@ async function handler(
throw new HttpError({ statusCode: 400, message: error.message });
}
const reqEventLength = dayjs(reqBody.end).diff(dayjs(reqBody.start), "minutes");
const validEventLengths = eventType.metadata?.multipleDuration?.length
? eventType.metadata.multipleDuration
: [eventType.length];
if (!validEventLengths.includes(reqEventLength)) {
loggerWithEventDetails.warn({ message: "NewBooking: Invalid event length" });
throw new HttpError({ statusCode: 400, message: "Invalid event length" });
}
// loadUsers allows type inferring
let users: (Awaited<ReturnType<typeof loadUsers>>[number] & {
isFixed?: boolean;
@@ -120,8 +120,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -285,8 +285,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -448,8 +448,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -603,8 +603,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -724,8 +724,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -889,8 +889,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1023,8 +1023,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1111,8 +1111,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1167,6 +1167,66 @@ describe("handleNewBooking", () => {
);
});
describe("Event length check during booking", () => {
test(
`should fail if the time difference between a booking's start and end times is not equal to the event length.`,
async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
});
const organizer = getOrganizer({
name: "Organizer",
email: "organizer@example.com",
id: 101,
schedules: [TestData.schedules.IstWorkHours],
});
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: 1,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
},
],
},
],
organizer,
})
);
const mockBookingData = getMockRequestDataForBooking({
data: {
start: `${getDate({ dateIncrement: 1 }).dateString}T05:00:00.000Z`,
end: `${getDate({ dateIncrement: 1 }).dateString}T05:15:00.000Z`,
eventTypeId: 1,
responses: {
email: booker.email,
name: booker.name,
location: { optionValue: "", value: "New York" },
},
},
});
const { req } = createMockNextJsRequest({
method: "POST",
body: mockBookingData,
});
await expect(async () => await handleNewBooking(req)).rejects.toThrowError("Invalid event length");
},
timeout
);
});
describe(
"Availability Check during booking",
() => {
@@ -1196,8 +1256,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1212,7 +1272,7 @@ describe("handleNewBooking", () => {
userId: 101,
status: BookingStatus.ACCEPTED,
startTime: `${plus1DateString}T05:00:00.000Z`,
endTime: `${plus1DateString}T05:15:00.000Z`,
endTime: `${plus1DateString}T05:30:00.000Z`,
},
],
organizer,
@@ -1221,7 +1281,7 @@ describe("handleNewBooking", () => {
const mockBookingData = getMockRequestDataForBooking({
data: {
start: `${getDate({ dateIncrement: 1 }).dateString}T04:00:00.000Z`,
start: `${getDate({ dateIncrement: 1 }).dateString}T05:00:00.000Z`,
end: `${getDate({ dateIncrement: 1 }).dateString}T05:30:00.000Z`,
eventTypeId: 1,
responses: {
@@ -1279,8 +1339,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1308,7 +1368,7 @@ describe("handleNewBooking", () => {
const mockBookingData = getMockRequestDataForBooking({
data: {
start: `${getDate({ dateIncrement: 1 }).dateString}T04:00:00.000Z`,
start: `${getDate({ dateIncrement: 1 }).dateString}T05:00:00.000Z`,
end: `${getDate({ dateIncrement: 1 }).dateString}T05:30:00.000Z`,
eventTypeId: 1,
responses: {
@@ -1380,9 +1440,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
requiresConfirmation: true,
length: 45,
length: 30,
users: [
{
id: 101,
@@ -1506,9 +1566,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
requiresConfirmation: true,
length: 45,
length: 30,
users: [
{
id: 101,
@@ -1630,7 +1690,7 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
requiresConfirmation: true,
metadata: {
requiresConfirmationThreshold: {
@@ -1638,7 +1698,7 @@ describe("handleNewBooking", () => {
unit: "minutes",
},
},
length: 45,
length: 30,
users: [
{
id: 101,
@@ -1762,7 +1822,7 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
requiresConfirmation: true,
metadata: {
requiresConfirmationThreshold: {
@@ -1770,7 +1830,7 @@ describe("handleNewBooking", () => {
unit: "hours",
},
},
length: 45,
length: 30,
users: [
{
id: 101,
@@ -1856,8 +1916,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1968,8 +2028,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -2076,7 +2136,7 @@ describe("handleNewBooking", () => {
id: 1,
title: "Paid Event",
description: "It's a test Paid Event",
slotInterval: 45,
slotInterval: 30,
requiresConfirmation: false,
metadata: {
apps: {
@@ -2088,7 +2148,7 @@ describe("handleNewBooking", () => {
},
},
},
length: 45,
length: 30,
users: [
{
id: 101,
@@ -2233,7 +2293,7 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
requiresConfirmation: true,
metadata: {
apps: {
@@ -2244,7 +2304,7 @@ describe("handleNewBooking", () => {
},
},
},
length: 45,
length: 30,
users: [
{
id: 101,
@@ -88,8 +88,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
recurringEvent: recurrence,
users: [
{
@@ -294,8 +294,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
recurringEvent: recurrence,
users: [
{
@@ -426,8 +426,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
recurringEvent: recurrence,
users: [
{
@@ -641,8 +641,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
recurringEvent: recurrence,
users: [
{
@@ -100,8 +100,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 15,
length: 15,
users: [
{
id: 101,
@@ -337,8 +337,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 15,
length: 15,
users: [
{
id: 101,
@@ -549,8 +549,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -564,7 +564,7 @@ describe("handleNewBooking", () => {
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: `${plus1DateString}T05:00:00.000Z`,
endTime: `${plus1DateString}T05:15:00.000Z`,
endTime: `${plus1DateString}T05:30:00.000Z`,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -732,9 +732,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 15,
requiresConfirmation: true,
length: 45,
length: 15,
users: [
{
id: 101,
@@ -940,8 +940,8 @@ describe("handleNewBooking", () => {
{
id: 1,
requiresConfirmation: true,
slotInterval: 45,
length: 45,
slotInterval: 15,
length: 15,
users: [
{
id: 101,
@@ -1190,9 +1190,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 15,
requiresConfirmation: true,
length: 45,
length: 15,
users: [
{
id: 101,
@@ -1403,8 +1403,8 @@ describe("handleNewBooking", () => {
{
id: 1,
requiresConfirmation: true,
slotInterval: 45,
length: 45,
slotInterval: 15,
length: 15,
users: [
{
id: 101,
@@ -1650,8 +1650,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 15,
length: 15,
users: [
{
id: 101,
@@ -1803,8 +1803,8 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 15,
length: 15,
users: [
{
id: 101,
@@ -110,9 +110,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 15,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 15,
users: [
{
id: 101,
@@ -296,9 +296,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 15,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 15,
users: [
{
id: 101,
@@ -423,9 +423,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 15,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 15,
users: [
{
id: 101,
@@ -609,9 +609,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 15,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 15,
schedule: TestData.schedules.IstMorningShift,
users: [
{
@@ -731,9 +731,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 30,
users: [
{
id: 101,
@@ -941,9 +941,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 30,
users: [
{
id: 101,
@@ -1159,9 +1159,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 30,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 30,
users: [
{
id: 101,
@@ -1376,9 +1376,9 @@ describe("handleNewBooking", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
slotInterval: 15,
schedulingType: SchedulingType.COLLECTIVE,
length: 45,
length: 15,
users: [
{
id: 101,
@@ -31,6 +31,7 @@ describe("handleSeats", () => {
test("On new booking handleSeats is not called", async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const spy = vi.spyOn(handleSeatsModule, "default");
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
@@ -48,8 +49,8 @@ describe("handleSeats", () => {
eventTypes: [
{
id: 1,
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -108,18 +109,19 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const bookingId = 1;
const bookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
const bookingUid = "abc123";
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
const bookingScenario = await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -131,11 +133,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: bookingId,
uid: bookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: bookingStartTime,
endTime: `${plus1DateString}T05:15:00.000Z`,
endTime: bookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -248,18 +251,19 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const bookingId = 1;
const bookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
const bookingUid = "abc123";
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
const bookingScenario = await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -271,11 +275,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: bookingId,
uid: bookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: bookingStartTime,
endTime: `${plus1DateString}T05:15:00.000Z`,
endTime: bookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -392,19 +397,19 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00.000Z`;
const bookingUid = "abc123";
const bookingId = 1;
const bookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: bookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -416,12 +421,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: bookingId,
uid: bookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: bookingStartTime,
endTime: `${plus1DateString}T05:15:00.000Z`,
endTime: bookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -501,7 +506,7 @@ describe("handleSeats", () => {
expect.objectContaining({
referenceUid: expect.any(String),
data: expect.any(Object),
bookingId: 1,
bookingId: bookingId,
})
);
});
@@ -521,19 +526,19 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00.000Z`;
const bookingUid = "abc123";
const bookingId = 1;
const bookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: bookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -545,12 +550,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: bookingId,
uid: bookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: bookingStartTime,
endTime: `${plus1DateString}T05:15:00.000Z`,
endTime: bookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -631,19 +636,20 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00.000Z`;
const bookingUid = "abc123";
const bookingId = 1;
const bookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: bookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -655,12 +661,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: bookingId,
uid: bookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: bookingStartTime,
endTime: `${plus1DateString}T05:15:00.000Z`,
endTime: bookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -768,25 +774,26 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00.000Z`;
const firstBookingUid = "abc123";
const firstBookingId = 1;
const firstBookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00Z`;
const firstBookingEndTime = `${plus1DateString}T04:30:00Z`;
const secondBookingUid = "def456";
const secondBookingId = 2;
const secondBookingUid = "def456";
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const secondBookingStartTime = `${plus2DateString}T04:00:00Z`;
const secondBookingEndTime = `${plus2DateString}T05:15:00Z`;
const secondBookingEndTime = `${plus2DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: firstBookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -798,12 +805,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: firstBookingId,
uid: firstBookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: firstBookingStartTime,
endTime: secondBookingEndTime,
endTime: firstBookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -839,7 +846,7 @@ describe("handleSeats", () => {
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: secondBookingStartTime,
endTime: `${plus2DateString}T05:15:00.000Z`,
endTime: secondBookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -973,23 +980,24 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00.000Z`;
const firstBookingUid = "abc123";
const firstBookingId = 1;
const firstBookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00Z`;
const firstBookingEndTime = `${plus1DateString}T04:30:00Z`;
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const secondBookingStartTime = `${plus2DateString}T04:00:00Z`;
const secondBookingEndTime = `${plus2DateString}T05:15:00Z`;
const secondBookingEndTime = `${plus2DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: firstBookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1001,12 +1009,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: firstBookingId,
uid: firstBookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: firstBookingStartTime,
endTime: secondBookingEndTime,
endTime: firstBookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -1130,23 +1138,24 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00.000Z`;
const firstBookingUid = "abc123";
const firstBookingId = 1;
const firstBookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00Z`;
const firstBookingEndTime = `${plus1DateString}T04:30:00Z`;
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const secondBookingStartTime = `${plus2DateString}T04:00:00Z`;
const secondBookingEndTime = `${plus2DateString}T05:15:00Z`;
const secondBookingEndTime = `${plus2DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: firstBookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1158,12 +1167,12 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: firstBookingId,
uid: firstBookingUid,
eventTypeId: 1,
status: BookingStatus.ACCEPTED,
startTime: firstBookingStartTime,
endTime: secondBookingEndTime,
endTime: firstBookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -1255,11 +1264,11 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00.00Z`;
const bookingEndTime = `${plus1DateString}T15:00:00.00Z`;
const bookingUid = "abc123";
const bookingId = 1;
const bookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
const attendeeIdToBeCancelled = 2;
const bookingSeatToBeCancelledUid = "booking-seat-2";
@@ -1268,10 +1277,10 @@ describe("handleSeats", () => {
getScenarioData({
eventTypes: [
{
id: bookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1284,7 +1293,7 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: bookingId,
uid: bookingUid,
eventTypeId: 1,
userId: organizer.id,
@@ -1317,13 +1326,13 @@ describe("handleSeats", () => {
},
}),
getMockBookingAttendee({
id: 2,
id: attendeeIdToBeCancelled,
name: "Seat 2",
email: "seat2@test.com",
locale: "en",
timeZone: "America/Toronto",
bookingSeat: {
referenceUid: "booking-seat-2",
referenceUid: bookingSeatToBeCancelledUid,
data: {},
},
}),
@@ -1406,11 +1415,11 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00.00Z`;
const bookingEndTime = `${plus1DateString}T15:00:00.00Z`;
const bookingUid = "abc123";
const bookingId = 1;
const bookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
const attendeeIdToBeCancelled = 1;
const bookingSeatToBeCancelledUid = "booking-seat-1";
@@ -1419,10 +1428,10 @@ describe("handleSeats", () => {
getScenarioData({
eventTypes: [
{
id: bookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1435,7 +1444,7 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: bookingId,
uid: bookingUid,
eventTypeId: 1,
userId: organizer.id,
@@ -1457,13 +1466,13 @@ describe("handleSeats", () => {
],
attendees: [
getMockBookingAttendee({
id: 1,
id: attendeeIdToBeCancelled,
name: "Seat 1",
email: "seat1@test.com",
locale: "en",
timeZone: "America/Toronto",
bookingSeat: {
referenceUid: "booking-seat-1",
referenceUid: bookingSeatToBeCancelledUid,
data: {},
},
}),
@@ -1554,23 +1563,24 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00.000Z`;
const firstBookingUid = "abc123";
const firstBookingId = 1;
const firstBookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00Z`;
const firstBookingEndTime = `${plus1DateString}T04:30:00Z`;
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const secondBookingStartTime = `${plus2DateString}T04:00:00Z`;
const secondBookingEndTime = `${plus2DateString}T05:15:00Z`;
const secondBookingEndTime = `${plus2DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: firstBookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1582,13 +1592,13 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: firstBookingId,
uid: firstBookingUid,
eventTypeId: 1,
userId: organizer.id,
status: BookingStatus.ACCEPTED,
startTime: firstBookingStartTime,
endTime: secondBookingEndTime,
endTime: firstBookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -1716,25 +1726,26 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00.00Z`;
const firstBookingUid = "abc123";
const firstBookingId = 1;
const firstBookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00Z`;
const firstBookingEndTime = `${plus1DateString}T04:30:00Z`;
const secondBookingUid = "def456";
const secondBookingId = 2;
const secondBookingUid = "def456";
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const secondBookingStartTime = `${plus2DateString}T04:00:00Z`;
const secondBookingEndTime = `${plus2DateString}T05:15:00Z`;
const secondBookingEndTime = `${plus2DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: firstBookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1746,13 +1757,13 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: firstBookingId,
uid: firstBookingUid,
eventTypeId: 1,
userId: organizer.id,
status: BookingStatus.ACCEPTED,
startTime: firstBookingStartTime,
endTime: secondBookingEndTime,
endTime: firstBookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -1926,25 +1937,26 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00.00Z`;
const firstBookingUid = "abc123";
const firstBookingId = 1;
const firstBookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00Z`;
const firstBookingEndTime = `${plus1DateString}T04:30:00Z`;
const secondBookingUid = "def456";
const secondBookingId = 2;
const secondBookingUid = "def456";
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
const secondBookingStartTime = `${plus2DateString}T04:00:00Z`;
const secondBookingEndTime = `${plus2DateString}T05:15:00Z`;
const secondBookingEndTime = `${plus2DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: firstBookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -1956,13 +1968,13 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: firstBookingId,
uid: firstBookingUid,
eventTypeId: 1,
userId: organizer.id,
status: BookingStatus.ACCEPTED,
startTime: firstBookingStartTime,
endTime: secondBookingEndTime,
endTime: firstBookingEndTime,
metadata: {
videoCallUrl: "https://existing-daily-video-call-url.example.com",
},
@@ -2107,20 +2119,20 @@ describe("handleSeats", () => {
schedules: [TestData.schedules.IstWorkHours],
});
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00.00Z`;
const firstBookingEndTime = `${plus1DateString}T15:00:00.00Z`;
const firstBookingUid = "abc123";
const firstBookingId = 1;
const firstBookingUid = "abc123";
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const firstBookingStartTime = `${plus1DateString}T04:00:00Z`;
const firstBookingEndTime = `${plus1DateString}T04:30:00Z`;
await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: firstBookingId,
id: 1,
slug: "seated-event",
slotInterval: 45,
length: 45,
slotInterval: 30,
length: 30,
users: [
{
id: 101,
@@ -2133,7 +2145,7 @@ describe("handleSeats", () => {
],
bookings: [
{
id: 1,
id: firstBookingId,
uid: firstBookingUid,
eventTypeId: 1,
userId: organizer.id,