forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update to fix seated event reschedule * updated handleseats tests * updated handleSeats timeslot * updated test to expect error * update to remove uid in where clause (isFirstSeat)
- Loading branch information
1 parent
d73b841
commit 591d42f
Showing
2 changed files
with
147 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2413,6 +2413,151 @@ describe("handleSeats", () => { | |
// const rescheduledBooking = await handleNewBooking(req); | ||
await expect(() => handleNewBooking(req)).rejects.toThrowError(ErrorCode.NotEnoughAvailableSeats); | ||
}); | ||
|
||
test("When trying to reschedule in a non-available slot, throw an error", async () => { | ||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; | ||
|
||
const booker = getBooker({ | ||
email: "[email protected]", | ||
name: "Booker", | ||
}); | ||
|
||
const organizer = getOrganizer({ | ||
name: "Organizer", | ||
email: "[email protected]", | ||
id: 101, | ||
schedules: [TestData.schedules.IstWorkHours], | ||
}); | ||
|
||
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 }); | ||
// Non-available time slot choosen (7:30PM - 8:00PM IST) while rescheduling | ||
const secondBookingStartTime = `${plus2DateString}T14:00:00Z`; | ||
const secondBookingEndTime = `${plus2DateString}T14:30:00Z`; | ||
|
||
await createBookingScenario( | ||
getScenarioData({ | ||
eventTypes: [ | ||
{ | ||
id: 1, | ||
slug: "seated-event", | ||
slotInterval: 30, | ||
length: 30, | ||
users: [ | ||
{ | ||
id: 101, | ||
}, | ||
], | ||
seatsPerTimeSlot: 3, | ||
seatsShowAttendees: false, | ||
}, | ||
], | ||
bookings: [ | ||
{ | ||
id: firstBookingId, | ||
uid: firstBookingUid, | ||
eventTypeId: 1, | ||
userId: organizer.id, | ||
status: BookingStatus.ACCEPTED, | ||
startTime: firstBookingStartTime, | ||
endTime: firstBookingEndTime, | ||
metadata: { | ||
videoCallUrl: "https://existing-daily-video-call-url.example.com", | ||
}, | ||
references: [ | ||
{ | ||
type: appStoreMetadata.dailyvideo.type, | ||
uid: "MOCK_ID", | ||
meetingId: "MOCK_ID", | ||
meetingPassword: "MOCK_PASS", | ||
meetingUrl: "http://mock-dailyvideo.example.com", | ||
credentialId: null, | ||
}, | ||
], | ||
attendees: [ | ||
getMockBookingAttendee({ | ||
id: 1, | ||
name: "Seat 1", | ||
email: "[email protected]", | ||
locale: "en", | ||
timeZone: "America/Toronto", | ||
bookingSeat: { | ||
referenceUid: "booking-seat-1", | ||
data: {}, | ||
}, | ||
noShow: false, | ||
}), | ||
getMockBookingAttendee({ | ||
id: 2, | ||
name: "Seat 2", | ||
email: "[email protected]", | ||
locale: "en", | ||
timeZone: "America/Toronto", | ||
bookingSeat: { | ||
referenceUid: "booking-seat-2", | ||
data: {}, | ||
}, | ||
noShow: false, | ||
}), | ||
getMockBookingAttendee({ | ||
id: 3, | ||
name: "Seat 3", | ||
email: "[email protected]", | ||
locale: "en", | ||
timeZone: "America/Toronto", | ||
bookingSeat: { | ||
referenceUid: "booking-seat-3", | ||
data: {}, | ||
}, | ||
noShow: false, | ||
}), | ||
], | ||
}, | ||
], | ||
organizer, | ||
}) | ||
); | ||
|
||
mockSuccessfulVideoMeetingCreation({ | ||
metadataLookupKey: "dailyvideo", | ||
videoMeetingData: { | ||
id: "MOCK_ID", | ||
password: "MOCK_PASS", | ||
url: `http://mock-dailyvideo.example.com/meeting-1`, | ||
}, | ||
}); | ||
|
||
const reqBookingUser = "seatedAttendee"; | ||
|
||
const mockBookingData = getMockRequestDataForBooking({ | ||
data: { | ||
eventTypeId: 1, | ||
responses: { | ||
email: booker.email, | ||
name: booker.name, | ||
location: { optionValue: "", value: BookingLocations.CalVideo }, | ||
}, | ||
rescheduleUid: firstBookingUid, | ||
start: secondBookingStartTime, | ||
end: secondBookingEndTime, | ||
user: reqBookingUser, | ||
}, | ||
}); | ||
|
||
const { req } = createMockNextJsRequest({ | ||
method: "POST", | ||
body: mockBookingData, | ||
}); | ||
|
||
req.userId = organizer.id; | ||
|
||
await expect(() => handleNewBooking(req)).rejects.toThrowError(ErrorCode.NoAvailableUsersFound); | ||
}); | ||
}); | ||
|
||
describe("Cancelling a booking", () => { | ||
|