fix: skip email verification for reschedules and added test case (#24867)

* fix: skip email verification for reschedules and added test case

* used getNewBookingHandler helper instead of direct import in test

---------

Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com>
This commit is contained in:
Kartik
2025-11-11 04:05:55 +00:00
committed by GitHub
co-authored by Dhairyashil Shinde
parent 0c53717d0f
commit 228fbaf72e
2 changed files with 77 additions and 1 deletions
@@ -341,5 +341,81 @@ describe("handleNewBooking - Email Verification", () => {
},
timeout
);
test(
"should allow rescheduling without email verification even when requiresBookerEmailVerification is true",
async () => {
const handleNewBooking = getNewBookingHandler();
const { verifyCodeUnAuthenticated } = await import("@calcom/trpc/server/routers/viewer/auth/util");
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
});
const organizer = getOrganizer({
name: "Organizer",
email: "organizer@example.com",
id: 101,
schedules: [TestData.schedules.IstWorkHours],
});
const scenarioData = getScenarioData({
eventTypes: [
{
id: 1,
slotInterval: 15,
length: 30,
users: [
{
id: 101,
},
],
requiresBookerEmailVerification: true,
},
],
organizer,
bookings: [
{
uid: "existing-booking-uid",
eventTypeId: 1,
userId: 101,
status: "ACCEPTED",
startTime: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(), // tomorrow
endTime: new Date(Date.now() + 24 * 60 * 60 * 1000 + 30 * 60 * 1000).toISOString(), // tomorrow + 30 min
attendees: [
{
email: booker.email,
name: booker.name,
timeZone: "Asia/Kolkata",
},
],
},
],
});
await createBookingScenario(scenarioData);
const mockBookingData = getMockRequestDataForBooking({
data: {
eventTypeId: 1,
rescheduleUid: "existing-booking-uid",
responses: {
email: booker.email,
name: booker.name,
location: { optionValue: "", value: "integrations:daily" },
},
},
});
const result = await handleNewBooking({ bookingData: mockBookingData });
expect(result).toBeDefined();
expect(result.uid).toBeDefined();
expect(verifyCodeUnAuthenticated).not.toHaveBeenCalled();
},
timeout
);
});
});
@@ -559,7 +559,7 @@ async function handler(
});
}
if (eventType.requiresBookerEmailVerification) {
if (eventType.requiresBookerEmailVerification && !rawBookingData.rescheduleUid) {
const verificationCode = reqBody.verificationCode;
if (!verificationCode) {
throw new HttpError({