fix: resolve flaky API v2 slots E2E tests
- Add await to unawaited bookingSeatsRepositoryFixture.create calls - Clean up leftover selected slots before seated and variable length tests - Add deleteAllByUserId method to SelectedSlotRepositoryFixture The flakiness was caused by reserved slots from earlier tests leaking into subsequent test groups. The availability calculation fetches all unexpired reserved slots by userId (not eventTypeId), so non-seat reserved slots from regular event type tests appeared as busy times when computing slots for seated and variable length event types. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
This commit is contained in:
committed by
Alex van Andel
parent
5943a8ad64
commit
b96559b4e8
+11
-2
@@ -830,6 +830,8 @@ describe("Slots 2024-09-04 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-${seatedEventType.id}-${randomString()}`,
|
||||
@@ -865,7 +867,7 @@ describe("Slots 2024-09-04 Endpoints", () => {
|
||||
},
|
||||
});
|
||||
|
||||
bookingSeatsRepositoryFixture.create({
|
||||
await bookingSeatsRepositoryFixture.create({
|
||||
referenceUid: `seat-${randomString()}`,
|
||||
data: {},
|
||||
booking: {
|
||||
@@ -959,6 +961,8 @@ describe("Slots 2024-09-04 Endpoints", () => {
|
||||
});
|
||||
|
||||
it("should do a booking for seated event and slot should show attendees count and bookingUid and return 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-range-${seatedEventType.id}-${randomString()}`,
|
||||
@@ -994,7 +998,7 @@ describe("Slots 2024-09-04 Endpoints", () => {
|
||||
},
|
||||
});
|
||||
|
||||
bookingSeatsRepositoryFixture.create({
|
||||
await bookingSeatsRepositoryFixture.create({
|
||||
referenceUid: `seat-${randomString()}`,
|
||||
data: {},
|
||||
booking: {
|
||||
@@ -1324,6 +1328,11 @@ describe("Slots 2024-09-04 Endpoints", () => {
|
||||
|
||||
describe("variable length", () => {
|
||||
let responseReservedVariableSlot: ReserveSlotOutputData_2024_09_04;
|
||||
|
||||
beforeAll(async () => {
|
||||
await selectedSlotRepositoryFixture.deleteAllByUserId(user.id);
|
||||
});
|
||||
|
||||
it("should not be able to reserve a slot for variable length event type with invalid duration", async () => {
|
||||
const slotStartTime = "2050-09-05T10:00:00.000Z";
|
||||
const reserveResponse = await request(app.getHttpServer())
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { SelectedSlots } from "@calcom/prisma/client";
|
||||
import { TestingModule } from "@nestjs/testing";
|
||||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { TestingModule } from "@nestjs/testing";
|
||||
|
||||
import type { SelectedSlots } from "@calcom/prisma/client";
|
||||
|
||||
export class SelectedSlotRepositoryFixture {
|
||||
private prismaReadClient: PrismaReadService["prisma"];
|
||||
@@ -20,4 +19,8 @@ export class SelectedSlotRepositoryFixture {
|
||||
async deleteByUId(uid: SelectedSlots["uid"]) {
|
||||
return this.prismaWriteClient.selectedSlots.deleteMany({ where: { uid } });
|
||||
}
|
||||
|
||||
async deleteAllByUserId(userId: number) {
|
||||
return this.prismaWriteClient.selectedSlots.deleteMany({ where: { userId } });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user