From 851a38885358515107174209da198e2d162d0d85 Mon Sep 17 00:00:00 2001 From: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Date: Fri, 11 Aug 2023 14:45:53 -0400 Subject: [PATCH] fix: e2e test for rescheduling overlapping time (#10721) Co-authored-by: CarinaWolli --- apps/web/playwright/reschedule.e2e.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/web/playwright/reschedule.e2e.ts b/apps/web/playwright/reschedule.e2e.ts index b33b3d57b6..3c31cb5678 100644 --- a/apps/web/playwright/reschedule.e2e.ts +++ b/apps/web/playwright/reschedule.e2e.ts @@ -248,17 +248,23 @@ test.describe("Reschedule Tests", async () => { }) => { const user = await users.create(); const eventType = user.eventTypes[0]; - const startTime = dayjs().add(1, "day").set("hour", 10).set("minute", 0).toDate(); - const endTime = dayjs().add(1, "day").set("hour", 10).set("minute", 30).toDate(); + + let firstOfNextMonth = dayjs().add(1, "month").startOf("month"); + + // find first available slot of next month (available monday-friday) + while (firstOfNextMonth.day() < 1 || firstOfNextMonth.day() > 5) { + firstOfNextMonth = firstOfNextMonth.add(1, "day"); + } + + // set startTime to first available slot + const startTime = firstOfNextMonth.set("hour", 9).set("minute", 0).toDate(); + const endTime = firstOfNextMonth.set("hour", 9).set("minute", 30).toDate(); const booking = await bookings.create(user.id, user.username, eventType.id, {}, startTime, endTime); await page.goto(`/reschedule/${booking.uid}`); - //book same slot again - page.getByRole("button", { name: dayjs(startTime).format("D"), exact: true }).click(); - - page.getByRole("button", { name: dayjs(startTime).format("h:mmA") }).click(); + await selectFirstAvailableTimeSlotNextMonth(page); await page.locator('[data-testid="confirm-reschedule-button"]').click(); await expect(page).toHaveURL(/.*booking/);