Scheduling infrastructure for absolutely everyone.
fix: add waitFor calls to prevent flaky time slot selection tests (#26592)
Keith Williams53833f15ea5d
diff --git a/apps/web/playwright/lib/testUtils.ts b/apps/web/playwright/lib/testUtils.tsindex ab55213034c..9fff23a2552 100644--- a/apps/web/playwright/lib/testUtils.ts+++ b/apps/web/playwright/lib/testUtils.ts@@ -106,22 +106,35 @@ export function createHttpServer(opts: { requestHandler?: RequestHandler } = {})}export async function selectFirstAvailableTimeSlotNextMonth(page: Page | Frame) {- // Let current month dates fully render.- await page.getByTestId("incrementMonth").click();-- // Waiting for full month increment- await page.locator('[data-testid="day"][data-disabled="false"]').nth(0).click();-- await page.locator('[data-testid="time"]').nth(0).click();+ // Wait for the booker to be ready before interacting+ const incrementMonth = page.getByTestId("incrementMonth");+ await incrementMonth.waitFor();+ await incrementMonth.click();++ // Wait for available day to appear after month increment+ const firstAvailableDay = page.locator('[data-testid="day"][data-disabled="false"]').nth(0);+ await firstAvailableDay.waitFor();+ await firstAvailableDay.click();++ const firstTimeSlot = page.locator('[data-testid="time"]').nth(0);+ await firstTimeSlot.waitFor();+ await firstTimeSlot.click();}export async function selectSecondAvailableTimeSlotNextMonth(page: Page) {- // Let current month dates fully render.- await page.getByTestId("incrementMonth").click();-- await page.locator('[data-testid="day"][data-disabled="false"]').nth(1).click();-- await page.locator('[data-testid="time"]').nth(0).click();+ // Wait for the booker to be ready before interacting+ const incrementMonth = page.getByTestId("incrementMonth");+ await incrementMonth.waitFor();+ await incrementMonth.click();++ // Wait for available day to appear after month increment+ const secondAvailableDay = page.locator('[data-testid="day"][data-disabled="false"]').nth(1);+ await secondAvailableDay.waitFor();+ await secondAvailableDay.click();++ const firstTimeSlot = page.locator('[data-testid="time"]').nth(0);+ await firstTimeSlot.waitFor();+ await firstTimeSlot.click();}export async function bookEventOnThisPage(page: Page) {