Skip to content

Commit d80493f

Browse files
fix: resolve flaky API v2 slots-2024-04-15 E2E tests (calcom#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>
1 parent d685278 commit d80493f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/api/v2/src/modules/slots/slots-2024-04-15/controllers/slots.controller.e2e-spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ describe("Slots 2024-04-15 Endpoints", () => {
513513
});
514514

515515
it("should do a booking for seated event and slot should show attendees count and bookingUid", async () => {
516+
await selectedSlotRepositoryFixture.deleteAllByUserId(user.id);
517+
516518
const startTime = "2050-09-05T11:00:00.000Z";
517519
const booking = await bookingsRepositoryFixture.create({
518520
uid: `booking-uid-seated-${seatedEventTypeId}-${randomString()}`,
@@ -548,7 +550,7 @@ describe("Slots 2024-04-15 Endpoints", () => {
548550
},
549551
});
550552

551-
bookingSeatsRepositoryFixture.create({
553+
await bookingSeatsRepositoryFixture.create({
552554
referenceUid: `seat-${randomString()}`,
553555
data: {},
554556
booking: {
@@ -596,6 +598,8 @@ describe("Slots 2024-04-15 Endpoints", () => {
596598
});
597599

598600
it("should do a booking for seated event and slot should show attendees count and bookingUid in range format", async () => {
601+
await selectedSlotRepositoryFixture.deleteAllByUserId(user.id);
602+
599603
const startTime = "2050-09-05T11:00:00.000Z";
600604
const booking = await bookingsRepositoryFixture.create({
601605
uid: `booking-uid-seated-${seatedEventTypeId}-${randomString()}`,
@@ -631,7 +635,7 @@ describe("Slots 2024-04-15 Endpoints", () => {
631635
},
632636
});
633637

634-
bookingSeatsRepositoryFixture.create({
638+
await bookingSeatsRepositoryFixture.create({
635639
referenceUid: `seat-${randomString()}`,
636640
data: {},
637641
booking: {

0 commit comments

Comments
 (0)