From 4210f35e9cfd226e60fac5913d09afd5da4dcdf4 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Thu, 27 Oct 2022 15:04:34 +0530 Subject: [PATCH] Add a test that could have caught bug #5142 (#5157) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/web/playwright/booking-pages.e2e.ts | 18 ++++++++++++++++++ apps/web/playwright/lib/testUtils.ts | 17 ++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/apps/web/playwright/booking-pages.e2e.ts b/apps/web/playwright/booking-pages.e2e.ts index 270d8807ca..a20318e3e5 100644 --- a/apps/web/playwright/booking-pages.e2e.ts +++ b/apps/web/playwright/booking-pages.e2e.ts @@ -3,6 +3,7 @@ import { expect } from "@playwright/test"; import { test } from "./lib/fixtures"; import { bookFirstEvent, + bookOptinEvent, bookTimeSlot, selectFirstAvailableTimeSlotNextMonth, selectSecondAvailableTimeSlotNextMonth, @@ -119,4 +120,21 @@ test.describe("pro user", () => { await page.goto(`/${pro.username}`); await bookFirstEvent(page); }); + + test("can book an event that requires confirmation and then that booking can be accepted by organizer", async ({ + page, + users, + }) => { + await bookOptinEvent(page); + const [pro] = users.get(); + await pro.login(); + + await page.goto("/bookings/unconfirmed"); + await Promise.all([ + page.click('[data-testid="confirm"]'), + page.waitForResponse((response) => response.url().includes("/api/trpc/viewer.bookings.confirm")), + ]); + // This is the only booking in there that needed confirmation and now it should be empty screen + await expect(page.locator('[data-testid="empty-screen"]')).toBeVisible(); + }); }); diff --git a/apps/web/playwright/lib/testUtils.ts b/apps/web/playwright/lib/testUtils.ts index 687b93cbcc..b55b45c0c0 100644 --- a/apps/web/playwright/lib/testUtils.ts +++ b/apps/web/playwright/lib/testUtils.ts @@ -105,11 +105,7 @@ export async function selectSecondAvailableTimeSlotNextMonth(page: Page) { await page.locator('[data-testid="time"]').nth(1).click(); } -export async function bookFirstEvent(page: Page) { - // Click first event type - - await page.click('[data-testid="event-type-link"]'); - +async function bookEventOnThisPage(page: Page) { await selectFirstAvailableTimeSlotNextMonth(page); await bookTimeSlot(page); @@ -122,6 +118,17 @@ export async function bookFirstEvent(page: Page) { await expect(page.locator("[data-testid=success-page]")).toBeVisible(); } +export async function bookOptinEvent(page: Page) { + await page.locator('[data-testid="event-type-link"]:has-text("Opt in")').click(); + await bookEventOnThisPage(page); +} + +export async function bookFirstEvent(page: Page) { + // Click first event type + await page.click('[data-testid="event-type-link"]'); + await bookEventOnThisPage(page); +} + export const bookTimeSlot = async (page: Page) => { // --- fill form await page.fill('[name="name"]', "Test Testson");