Scheduling infrastructure for absolutely everyone.
chore: team booking test (#10440)
Shivam Kalra344b9e9b2bd2
diff --git a/apps/web/pages/booking/[uid].tsx b/apps/web/pages/booking/[uid].tsxindex dc0d14977b9..8983f9a8e44 100644--- a/apps/web/pages/booking/[uid].tsx+++ b/apps/web/pages/booking/[uid].tsx@@ -446,7 +446,7 @@ export default function Success(props: SuccessProps) {{bookingInfo?.user && (<div className="mb-3"><div>- <span data-testid={`host-name-${bookingInfo.user.name}`} className="mr-2">+ <span data-testid="booking-host-name" className="mr-2">{bookingInfo.user.name}</span><Badge variant="blue">{t("Host")}</Badge>diff --git a/apps/web/playwright/fixtures/users.ts b/apps/web/playwright/fixtures/users.tsindex 2af6ac85a10..69797755b70 100644--- a/apps/web/playwright/fixtures/users.ts+++ b/apps/web/playwright/fixtures/users.ts@@ -328,6 +328,13 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => {include: { team: true },});},+ getFirstTeamEvent: async (teamId: number) => {+ return prisma.eventType.findFirstOrThrow({+ where: {+ teamId,+ },+ });+ },getPaymentCredential: async () => getPaymentCredential(store.page),setupEventWithPrice: async (eventType: Pick<Prisma.EventType, "id">) =>setupEventWithPrice(eventType, store.page),diff --git a/apps/web/playwright/teams.e2e.ts b/apps/web/playwright/teams.e2e.tsindex 8b6e72e254a..d0edf32b442 100644--- a/apps/web/playwright/teams.e2e.ts+++ b/apps/web/playwright/teams.e2e.ts@@ -4,14 +4,7 @@ import { prisma } from "@calcom/prisma";import { SchedulingType } from "@calcom/prisma/enums";import { test } from "./lib/fixtures";-import {- bookTimeSlot,- selectFirstAvailableTimeSlotNextMonth,- teamEventSlug,- teamEventTitle,- testName,- todo,-} from "./lib/testUtils";+import { bookTimeSlot, selectFirstAvailableTimeSlotNextMonth, testName, todo } from "./lib/testUtils";test.describe.configure({ mode: "parallel" });@@ -74,10 +67,10 @@ test.describe("Teams", () => {test("Can create a booking for Collective EventType", async ({ page, users }) => {const ownerObj = { username: "pro-user", name: "pro-user" };const teamMatesObj = [- { username: "teammate-1", name: "teammate-1" },- { username: "teammate-2", name: "teammate-2" },- { username: "teammate-3", name: "teammate-3" },- { username: "teammate-4", name: "teammate-4" },+ { name: "teammate-1" },+ { name: "teammate-2" },+ { name: "teammate-3" },+ { name: "teammate-4" },];const owner = await users.create(ownerObj, {@@ -86,13 +79,20 @@ test.describe("Teams", () => {schedulingType: SchedulingType.COLLECTIVE,});const { team } = await owner.getTeam();+ const { title: teamEventTitle, slug: teamEventSlug } = await owner.getFirstTeamEvent(team.id);await page.goto(`/team/${team.slug}/${teamEventSlug}`);await selectFirstAvailableTimeSlotNextMonth(page);await bookTimeSlot(page);await expect(page.locator("[data-testid=success-page]")).toBeVisible();++ // The title of the booking+ const BookingTitle = `${teamEventTitle} between ${team.name} and ${testName}`;+ await expect(page.locator("[data-testid=booking-title]")).toHaveText(BookingTitle);+ // The booker should be in the attendee listawait expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName);+ // All the teammates should be in the bookingfor (const teammate of teamMatesObj) {await expect(page.getByText(teammate.name, { exact: true })).toBeVisible();}@@ -102,10 +102,10 @@ test.describe("Teams", () => {test("Can create a booking for Round Robin EventType", async ({ page, users }) => {const ownerObj = { username: "pro-user", name: "pro-user" };const teamMatesObj = [- { username: "teammate-1", name: "teammate-1" },- { username: "teammate-2", name: "teammate-2" },- { username: "teammate-3", name: "teammate-3" },- { username: "teammate-4", name: "teammate-4" },+ { name: "teammate-1" },+ { name: "teammate-2" },+ { name: "teammate-3" },+ { name: "teammate-4" },];const owner = await users.create(ownerObj, {hasTeam: true,@@ -114,6 +114,7 @@ test.describe("Teams", () => {});const { team } = await owner.getTeam();+ const { title: teamEventTitle, slug: teamEventSlug } = await owner.getFirstTeamEvent(team.id);await page.goto(`/team/${team.slug}/${teamEventSlug}`);await selectFirstAvailableTimeSlotNextMonth(page);@@ -127,9 +128,14 @@ test.describe("Teams", () => {const BookingTitle = `${teamEventTitle} between ${team.name} and ${testName}`;await expect(page.locator("[data-testid=booking-title]")).toHaveText(BookingTitle);- // TODO: Assert one of the teamates from the list to be the host+ // Since all the users have the same leastRecentlyBooked value+ // Anyone of the teammates could be the Host of the booking.+ const chosenUser = await page.getByTestId("booking-host-name").textContent();+ expect(chosenUser).not.toBeNull();+ expect(teamMatesObj.some(({ name }) => name === chosenUser)).toBe(true);// TODO: Assert whether the user received an email});+ todo("Create a Round Robin with different leastRecentlyBooked hosts");todo("Reschedule a Collective EventType booking");todo("Reschedule a Round Robin EventType booking");});