From 95d62354d997cea3a8f38e7be13bbb96d3dd6f3f Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Tue, 20 May 2025 16:57:43 +0200 Subject: [PATCH] test: update flaky tests (#21419) * test: update flaky integration tests * change limit --- .../booking-denormalized.integration-test.ts | 5 +++-- ...g-form-response-denormalized.integration-test.ts | 13 +++++++------ packages/lib/slots.test.ts | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/features/insights/__tests__/booking-denormalized.integration-test.ts b/packages/features/insights/__tests__/booking-denormalized.integration-test.ts index 290b988254..7b7422e343 100644 --- a/packages/features/insights/__tests__/booking-denormalized.integration-test.ts +++ b/packages/features/insights/__tests__/booking-denormalized.integration-test.ts @@ -9,6 +9,7 @@ describe("BookingDenormalized", () => { let bookingId: number; const randomId = Math.floor(Math.random() * 1000000); const email = `booking-denorm-${randomId}@example.com`; + const updatedEmail = `updated-${email}`; beforeEach(async () => { // Create test user @@ -101,7 +102,7 @@ describe("BookingDenormalized", () => { where: { id: userId }, data: { name: "Updated User", - email: "updated@example.com", + email: updatedEmail, }, }); @@ -110,7 +111,7 @@ describe("BookingDenormalized", () => { }); expect(userUpdatedDenormalizedBooking.userName).toBe("Updated User"); - expect(userUpdatedDenormalizedBooking.userEmail).toBe("updated@example.com"); + expect(userUpdatedDenormalizedBooking.userEmail).toBe(updatedEmail); }); it("should update denormalized entry when event type is updated", async () => { diff --git a/packages/features/insights/__tests__/routing-form-response-denormalized.integration-test.ts b/packages/features/insights/__tests__/routing-form-response-denormalized.integration-test.ts index 10113deb7a..ea9c4abeb7 100644 --- a/packages/features/insights/__tests__/routing-form-response-denormalized.integration-test.ts +++ b/packages/features/insights/__tests__/routing-form-response-denormalized.integration-test.ts @@ -12,14 +12,15 @@ describe("RoutingFormResponseDenormalized", () => { let bookingId: number; let responseId: number; const randomId = Math.floor(Math.random() * 1000000); - const email = `booking-denorm-${randomId}@example.com`; + const email = `routing-form-response-denorm-${randomId}@example.com`; + const updatedEmail = `updated-${email}`; beforeEach(async () => { // Create test user const user = await prisma.user.create({ data: { email, - username: `booking-denorm-testuser-${randomId}`, + username: `routing-form-response-denorm-testuser-${randomId}`, name: "Test User", }, }); @@ -96,7 +97,7 @@ describe("RoutingFormResponseDenormalized", () => { // Create test booking const booking = await prisma.booking.create({ data: { - uid: `booking-denorm-${randomId}`, + uid: `routing-form-response-denorm-${randomId}`, title: "Test Booking", startTime: new Date(), endTime: new Date(Date.now() + 60 * 60 * 1000), @@ -254,7 +255,7 @@ describe("RoutingFormResponseDenormalized", () => { where: { id: userId }, data: { name: "Updated User", - email: "updated@example.com", + email: updatedEmail, }, }); @@ -263,7 +264,7 @@ describe("RoutingFormResponseDenormalized", () => { }); expect(denormalizedResponse.bookingUserName).toBe("Updated User"); - expect(denormalizedResponse.bookingUserEmail).toBe("updated@example.com"); + expect(denormalizedResponse.bookingUserEmail).toBe(updatedEmail); }); it("should update denormalized entry when booking is updated", async () => { @@ -636,7 +637,7 @@ describe("RoutingFormResponseDenormalized", () => { // Create a booking with attendees const booking = await prisma.booking.create({ data: { - uid: `booking-denorm-${Math.floor(Math.random() * 1000000)}`, + uid: `routing-form-response-denorm-${Math.floor(Math.random() * 1000000)}`, title: "Test Booking", startTime: new Date(), endTime: new Date(Date.now() + 60 * 60 * 1000), diff --git a/packages/lib/slots.test.ts b/packages/lib/slots.test.ts index 04e3482fea..885fdc4eee 100644 --- a/packages/lib/slots.test.ts +++ b/packages/lib/slots.test.ts @@ -392,7 +392,7 @@ describe("Tests the slots function performance", () => { const endTime = process.hrtime(startTime); const executionTimeInMs = endTime[0] * 1000 + endTime[1] / 1000000; - expect(executionTimeInMs).toBeLessThan(2000); // less than 2 seconds for 2000 date ranges + expect(executionTimeInMs).toBeLessThan(3000); // less than 3 seconds for 2000 date ranges console.log( `Performance test completed in ${executionTimeInMs}ms with ${result.length} slots generated from ${dateRanges.length} date ranges`