diff --git a/apps/web/playwright/booking-seats.e2e.ts b/apps/web/playwright/booking-seats.e2e.ts index 4ca991e501..17d83f2809 100644 --- a/apps/web/playwright/booking-seats.e2e.ts +++ b/apps/web/playwright/booking-seats.e2e.ts @@ -205,7 +205,7 @@ test.describe("Booking with Seats", () => { }, }); - expect(oldBooking?.attendees).toBeFalsy(); + expect(oldBooking?.status).toBe(BookingStatus.CANCELLED); }); test("Should cancel with seats and have no attendees and cancelled", async ({ diff --git a/apps/web/playwright/reschedule.e2e.ts b/apps/web/playwright/reschedule.e2e.ts index aa9056c2b1..70a648345f 100644 --- a/apps/web/playwright/reschedule.e2e.ts +++ b/apps/web/playwright/reschedule.e2e.ts @@ -97,13 +97,19 @@ test.describe("Reschedule Tests", async () => { await expect(page.locator("[data-testid=success-page]")).toBeVisible(); - const newBooking = await prisma.booking.findFirst({ where: { fromReschedule: booking.uid } }); - const rescheduledBooking = await prisma.booking.findFirst({ where: { uid: booking.uid } }); + const newBooking = await prisma.booking.findFirstOrThrow({ where: { fromReschedule: booking.uid } }); + const rescheduledBooking = await prisma.booking.findFirstOrThrow({ where: { uid: booking.uid } }); expect(newBooking).not.toBeNull(); - expect(rescheduledBooking).toBeNull(); + expect(rescheduledBooking.status).toBe(BookingStatus.CANCELLED); - await prisma.booking.delete({ where: { id: newBooking?.id } }); + await prisma.booking.deleteMany({ + where: { + id: { + in: [newBooking.id, rescheduledBooking.id], + }, + }, + }); }); test("Unpaid rescheduling should go to payment page", async ({ page, users, bookings, payments }) => { diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index 0459622fe4..550504298e 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -895,10 +895,13 @@ async function handler( } await Promise.all(integrationsToDelete).then(async () => { - await prisma.booking.delete({ + await prisma.booking.update({ where: { id: originalRescheduledBooking.id, }, + data: { + status: BookingStatus.CANCELLED, + }, }); }); deletedReferences = true; @@ -1189,11 +1192,14 @@ async function handler( cancellationReason: "$RCH$" + rescheduleReason ? rescheduleReason : "", // Removable code prefix to differentiate cancellation from rescheduling for email }); - // Delete the old booking - await prisma.booking.delete({ + // Update the old booking with the cancelled status + await prisma.booking.update({ where: { id: booking.id, }, + data: { + status: BookingStatus.CANCELLED, + }, }); const resultBooking = await resultBookingQuery(newTimeSlotBooking.id); @@ -1680,12 +1686,15 @@ async function handler( addVideoCallDataToEvt(originalRescheduledBooking.references); const updateManager = await eventManager.reschedule(evt, originalRescheduledBooking.uid); - //delete original rescheduled booking (no seats event) + //update original rescheduled booking (no seats event) if (!eventType.seatsPerTimeSlot) { - await prisma.booking.delete({ + await prisma.booking.update({ where: { id: originalRescheduledBooking.id, }, + data: { + status: BookingStatus.CANCELLED, + }, }); }