From f1ac0642d1ac8702c345e46d34a531f9efd4a766 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Thu, 18 Sep 2025 14:09:45 -0300 Subject: [PATCH] fix: correct route pattern and assertions in duplicate API calls E2E test (#23287) - Fix route pattern from **/api/trpc/viewer.slots.getSchedule** to **/api/trpc/slots/getSchedule** - Remove permissive assertions that allowed tests to pass with 0 API calls - Tests now properly fail when duplicate getSchedule calls are detected - Addresses issue where E2E tests weren't catching duplicate API calls on main branch Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Hariom Balhara --- .../booking-duplicate-api-calls.e2e.ts | 44 +++++++------------ 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/apps/web/playwright/booking-duplicate-api-calls.e2e.ts b/apps/web/playwright/booking-duplicate-api-calls.e2e.ts index eb297c4720..fb8030f1d7 100644 --- a/apps/web/playwright/booking-duplicate-api-calls.e2e.ts +++ b/apps/web/playwright/booking-duplicate-api-calls.e2e.ts @@ -16,8 +16,8 @@ test.describe("Duplicate API Calls Prevention", () => { const trpcCalls: string[] = []; const apiV2Calls: string[] = []; - // Intercept tRPC getSchedule calls - pattern matches trpc.viewer.slots.getSchedule.useQuery() - await page.route("**/api/trpc/viewer.slots.getSchedule**", async (route) => { + // Intercept tRPC getSchedule calls - pattern matches /api/trpc/slots/getSchedule + await page.route("**/api/trpc/slots/getSchedule**", async (route) => { trpcCalls.push(route.request().url()); await route.continue(); }); @@ -33,14 +33,10 @@ test.describe("Duplicate API Calls Prevention", () => { const totalCalls = trpcCalls.length + apiV2Calls.length; - if (totalCalls === 0) { - console.log("No API calls detected - environment may have issues preventing page load"); - expect(totalCalls).toBeGreaterThanOrEqual(0); - } else { - expect(totalCalls).toBeLessThanOrEqual(1); - expect(trpcCalls.length).toBeLessThanOrEqual(1); - expect(apiV2Calls.length).toBeLessThanOrEqual(1); - } + expect(totalCalls).toBeGreaterThan(0); + expect(totalCalls).toBeLessThanOrEqual(1); + expect(trpcCalls.length).toBeLessThanOrEqual(1); + expect(apiV2Calls.length).toBeLessThanOrEqual(1); }); test("should detect when schedule endpoints are called multiple times for team events", async ({ @@ -65,7 +61,7 @@ test.describe("Duplicate API Calls Prevention", () => { const trpcCalls: string[] = []; const apiV2Calls: string[] = []; - await page.route("**/api/trpc/viewer.slots.getSchedule**", async (route) => { + await page.route("**/api/trpc/slots/getSchedule**", async (route) => { trpcCalls.push(route.request().url()); await route.continue(); }); @@ -81,14 +77,10 @@ test.describe("Duplicate API Calls Prevention", () => { const totalCalls = trpcCalls.length + apiV2Calls.length; - if (totalCalls === 0) { - console.log("No API calls detected - environment may have issues preventing page load"); - expect(totalCalls).toBeGreaterThanOrEqual(0); - } else { - expect(totalCalls).toBeLessThanOrEqual(1); - expect(trpcCalls.length).toBeLessThanOrEqual(1); - expect(apiV2Calls.length).toBeLessThanOrEqual(1); - } + expect(totalCalls).toBeGreaterThan(0); + expect(totalCalls).toBeLessThanOrEqual(1); + expect(trpcCalls.length).toBeLessThanOrEqual(1); + expect(apiV2Calls.length).toBeLessThanOrEqual(1); }); test("should detect when schedule endpoints are called multiple times for organization team events", async ({ @@ -117,7 +109,7 @@ test.describe("Duplicate API Calls Prevention", () => { const trpcCalls: string[] = []; const apiV2Calls: string[] = []; - await page.route("**/api/trpc/viewer.slots.getSchedule**", async (route) => { + await page.route("**/api/trpc/slots/getSchedule**", async (route) => { trpcCalls.push(route.request().url()); await route.continue(); }); @@ -133,13 +125,9 @@ test.describe("Duplicate API Calls Prevention", () => { const totalCalls = trpcCalls.length + apiV2Calls.length; - if (totalCalls === 0) { - console.log("No API calls detected - environment may have issues preventing page load"); - expect(totalCalls).toBeGreaterThanOrEqual(0); - } else { - expect(totalCalls).toBeLessThanOrEqual(1); - expect(trpcCalls.length).toBeLessThanOrEqual(1); - expect(apiV2Calls.length).toBeLessThanOrEqual(1); - } + expect(totalCalls).toBeGreaterThan(0); + expect(totalCalls).toBeLessThanOrEqual(1); + expect(trpcCalls.length).toBeLessThanOrEqual(1); + expect(apiV2Calls.length).toBeLessThanOrEqual(1); }); });