From d80493f201a72afe0d94a19953a5483052bac137 Mon Sep 17 00:00:00 2001 From: Romit <85230081+romitg2@users.noreply.github.com> Date: Sat, 28 Mar 2026 14:52:01 +0530 Subject: [PATCH] fix: resolve flaky API v2 slots-2024-04-15 E2E tests (#28589) - Add await to unawaited bookingSeatsRepositoryFixture.create calls - Clean up leftover selected slots before seated event tests The flakiness was caused by two issues: 1. Missing await on bookingSeatsRepositoryFixture.create() - the HTTP request to fetch slots could execute before the booking seat record was written to the database, leading to incorrect seat counts. 2. Leftover SelectedSlots records leaking between test groups - the availability calculation fetches all unexpired reserved slots by userId (not eventTypeId), so reserved slots from earlier tests appeared as busy times when computing slots for seated event types. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../controllers/slots.controller.e2e-spec.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/api/v2/src/modules/slots/slots-2024-04-15/controllers/slots.controller.e2e-spec.ts b/apps/api/v2/src/modules/slots/slots-2024-04-15/controllers/slots.controller.e2e-spec.ts index 3a7283f982..236cfc8beb 100644 --- a/apps/api/v2/src/modules/slots/slots-2024-04-15/controllers/slots.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/slots/slots-2024-04-15/controllers/slots.controller.e2e-spec.ts @@ -513,6 +513,8 @@ describe("Slots 2024-04-15 Endpoints", () => { }); it("should do a booking for seated event and slot should show attendees count and bookingUid", async () => { + await selectedSlotRepositoryFixture.deleteAllByUserId(user.id); + const startTime = "2050-09-05T11:00:00.000Z"; const booking = await bookingsRepositoryFixture.create({ uid: `booking-uid-seated-${seatedEventTypeId}-${randomString()}`, @@ -548,7 +550,7 @@ describe("Slots 2024-04-15 Endpoints", () => { }, }); - bookingSeatsRepositoryFixture.create({ + await bookingSeatsRepositoryFixture.create({ referenceUid: `seat-${randomString()}`, data: {}, booking: { @@ -596,6 +598,8 @@ describe("Slots 2024-04-15 Endpoints", () => { }); it("should do a booking for seated event and slot should show attendees count and bookingUid in range format", async () => { + await selectedSlotRepositoryFixture.deleteAllByUserId(user.id); + const startTime = "2050-09-05T11:00:00.000Z"; const booking = await bookingsRepositoryFixture.create({ uid: `booking-uid-seated-${seatedEventTypeId}-${randomString()}`, @@ -631,7 +635,7 @@ describe("Slots 2024-04-15 Endpoints", () => { }, }); - bookingSeatsRepositoryFixture.create({ + await bookingSeatsRepositoryFixture.create({ referenceUid: `seat-${randomString()}`, data: {}, booking: {