From eecf9e1ab9cff48ebd78e980275711c5590600a7 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Sun, 11 Jan 2026 00:50:11 +0530 Subject: [PATCH] fix: make BookingReferenceRepository integration tests use unique identifiers (#26701) The integration tests were flaky because they used fixed identifiers (email, username, uid) that could conflict across parallel test runs or with leftover data from previous runs. Changes: - Add unique testRunId using timestamp and random suffix - Use testRunId in email, username, and booking uid - Change afterAll cleanup to use deleteMany instead of delete to prevent failures when records are already deleted Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- ...ingReferenceRepository.integration-test.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/features/bookingReference/repositories/BookingReferenceRepository.integration-test.ts b/packages/features/bookingReference/repositories/BookingReferenceRepository.integration-test.ts index fd1144b433..17822d4e13 100644 --- a/packages/features/bookingReference/repositories/BookingReferenceRepository.integration-test.ts +++ b/packages/features/bookingReference/repositories/BookingReferenceRepository.integration-test.ts @@ -5,6 +5,8 @@ import type { Booking, Credential, User } from "@calcom/prisma/client"; import { BookingReferenceRepository } from "./BookingReferenceRepository"; +const testRunId = `${Date.now()}-${Math.random().toString(36).substring(2, 8)}`; + describe("BookingReferenceRepository Integration Tests", () => { let testUser: User; let testCredential: Credential; @@ -14,8 +16,8 @@ describe("BookingReferenceRepository Integration Tests", () => { beforeAll(async () => { testUser = await prisma.user.create({ data: { - email: "bookingreference-test@example.com", - username: "bookingreference-test", + email: `bookingreference-test-${testRunId}@example.com`, + username: `bookingreference-test-${testRunId}`, }, }); @@ -29,7 +31,7 @@ describe("BookingReferenceRepository Integration Tests", () => { testBooking = await prisma.booking.create({ data: { - uid: "test-booking-uid-123", + uid: `test-booking-uid-${testRunId}`, title: "Test Booking", startTime: new Date(), endTime: new Date(), @@ -52,19 +54,25 @@ describe("BookingReferenceRepository Integration Tests", () => { }); afterAll(async () => { - await prisma.booking.delete({ + await prisma.bookingReference.deleteMany({ + where: { + bookingId: testBooking.id, + }, + }); + + await prisma.booking.deleteMany({ where: { id: testBooking.id, }, }); - await prisma.credential.delete({ + await prisma.credential.deleteMany({ where: { id: testCredential.id, }, }); - await prisma.user.delete({ + await prisma.user.deleteMany({ where: { id: testUser.id, },