From fb3ab660e16dbaea321fb7d76067a618a8155154 Mon Sep 17 00:00:00 2001 From: Romit <85230081+romitg2@users.noreply.github.com> Date: Wed, 25 Mar 2026 14:34:42 +0530 Subject: [PATCH] fix: stabilize flaky Team filter E2E tests in bookings-list (#28576) * fix: stabilize flaky Team filter E2E tests in bookings-list Backport fix from calcom/cal: replace fragile expect.poll().toBe(1) with explicit toBeHidden() wait for filtered-out booking item followed by toHaveCount(1). This prevents race conditions where the DOM hasn't updated yet after the team filter API response returns. Fixes all three Team filter tests: - Team filter shows bookings for direct team event types - Team filter shows bookings for managed event types (child events) - Team filter excludes bookings from other teams Co-Authored-By: romitgabani1 * fix: adjust direct team event types test assertion In cal.com, the team filter includes personal bookings of team members, so instead of asserting the personal booking is hidden, verify that the team booking is visible and present. The managed event types and cross-team tests correctly use toBeHidden since those filters do exclude the expected items. Co-Authored-By: romitgabani1 * fix: strengthen direct team event types assertion with filter-active check Add assertion that the teamId filter popover trigger is visible in the UI, proving the filter was applied before checking the team booking is present. This addresses the concern that toBeVisible alone would pass even without the filter being active. Co-Authored-By: romitgabani1 * chore: remove comments per review feedback Co-Authored-By: romitgabani1 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- apps/web/playwright/bookings-list.e2e.ts | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/web/playwright/bookings-list.e2e.ts b/apps/web/playwright/bookings-list.e2e.ts index a3b37cb7c5..41a3c1f203 100644 --- a/apps/web/playwright/bookings-list.e2e.ts +++ b/apps/web/playwright/bookings-list.e2e.ts @@ -617,14 +617,15 @@ test.describe("Bookings", () => { await page.locator(`[data-testid="select-filter-options-teamId"] [role="option"]`).first().click(); await bookingsGetResponse2; + await expect(page.getByTestId("filter-popover-trigger-teamId")).toBeVisible({ timeout: 10000 }); + const upcomingBookingsTable = page.locator('[data-testid="upcoming-bookings"]'); const bookingListItems = upcomingBookingsTable.locator('[data-testid="booking-item"]'); - await expect - .poll(async () => { - return await bookingListItems.count(); - }) - .toBe(1); + await expect( + upcomingBookingsTable.locator('[data-testid="booking-item"]', { hasText: teamBooking!.title }) + ).toBeVisible({ timeout: 10000 }); + await expect(bookingListItems.first().getByTestId("title-and-attendees")).toContainText( teamBooking!.title ); @@ -677,12 +678,11 @@ test.describe("Bookings", () => { const upcomingBookingsTable = page.locator('[data-testid="upcoming-bookings"]'); const bookingListItems = upcomingBookingsTable.locator('[data-testid="booking-item"]'); - await expect - .poll(async () => { - return await bookingListItems.count(); - }) - .toBe(1); + await expect( + upcomingBookingsTable.locator('[data-testid="booking-item"]', { hasText: "Personal Event Booking" }) + ).toBeHidden({ timeout: 10000 }); + await expect(bookingListItems).toHaveCount(1); await expect(bookingListItems.first().getByTestId("title-and-attendees")).toContainText( managedEventBooking!.title ); @@ -756,11 +756,11 @@ test.describe("Bookings", () => { const upcomingBookingsTable = page.locator('[data-testid="upcoming-bookings"]'); const bookingListItems = upcomingBookingsTable.locator('[data-testid="booking-item"]'); - await expect - .poll(async () => { - return await bookingListItems.count(); - }) - .toBe(1); + await expect( + upcomingBookingsTable.locator('[data-testid="booking-item"]', { hasText: "Team 2 Booking" }) + ).toBeHidden({ timeout: 10000 }); + + await expect(bookingListItems).toHaveCount(1); }); });