From f09937605ad95bff37634a032dfa920de0b8d272 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Thu, 12 Oct 2023 14:19:57 +0100 Subject: [PATCH] feat: Refactor teams test suites --- apps/web/playwright/teams/assignment.e2e.ts | 88 +++++++++++++++++++ .../{ => teams}/managed-event-types.e2e.ts | 2 +- .../{teams.e2e.ts => teams/setup.e2e.ts} | 78 +--------------- .../playwright/{ => teams}/unpublished.e2e.ts | 2 +- 4 files changed, 91 insertions(+), 79 deletions(-) create mode 100644 apps/web/playwright/teams/assignment.e2e.ts rename apps/web/playwright/{ => teams}/managed-event-types.e2e.ts (99%) rename apps/web/playwright/{teams.e2e.ts => teams/setup.e2e.ts} (63%) rename apps/web/playwright/{ => teams}/unpublished.e2e.ts (99%) diff --git a/apps/web/playwright/teams/assignment.e2e.ts b/apps/web/playwright/teams/assignment.e2e.ts new file mode 100644 index 0000000000..ec7b639fbe --- /dev/null +++ b/apps/web/playwright/teams/assignment.e2e.ts @@ -0,0 +1,88 @@ +import { expect } from "@playwright/test"; + +import { SchedulingType } from "@calcom/prisma/enums"; + +import { test } from "../lib/fixtures"; +import { bookTimeSlot, selectFirstAvailableTimeSlotNextMonth, testName, todo } from "../lib/testUtils"; + +test.describe.configure({ mode: "parallel" }); + +test.afterEach(({ users }) => users.deleteAll()); + +test.describe("Team Assignment (Round Robin / Collective / ...)", () => { + test("Can create a booking for Collective EventType", async ({ page, users }) => { + const ownerObj = { username: "pro-user", name: "pro-user" }; + const teamMatesObj = [ + { name: "teammate-1" }, + { name: "teammate-2" }, + { name: "teammate-3" }, + { name: "teammate-4" }, + ]; + + const owner = await users.create(ownerObj, { + hasTeam: true, + teammates: teamMatesObj, + 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 list + await expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName); + + // All the teammates should be in the booking + for (const teammate of teamMatesObj) { + await expect(page.getByText(teammate.name, { exact: true })).toBeVisible(); + } + + // TODO: Assert whether the user received an email + }); + test("Can create a booking for Round Robin EventType", async ({ page, users }) => { + const ownerObj = { username: "pro-user", name: "pro-user" }; + const teamMatesObj = [ + { name: "teammate-1" }, + { name: "teammate-2" }, + { name: "teammate-3" }, + { name: "teammate-4" }, + ]; + const owner = await users.create(ownerObj, { + hasTeam: true, + teammates: teamMatesObj, + schedulingType: SchedulingType.ROUND_ROBIN, + }); + + 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 person who booked the meeting should be in the attendee list + await expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName); + + // The title of the booking + const BookingTitle = `${teamEventTitle} between ${team.name} and ${testName}`; + await expect(page.locator("[data-testid=booking-title]")).toHaveText(BookingTitle); + + // 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"); +}); diff --git a/apps/web/playwright/managed-event-types.e2e.ts b/apps/web/playwright/teams/managed-event-types.e2e.ts similarity index 99% rename from apps/web/playwright/managed-event-types.e2e.ts rename to apps/web/playwright/teams/managed-event-types.e2e.ts index 52e6bf86c6..f03419648d 100644 --- a/apps/web/playwright/managed-event-types.e2e.ts +++ b/apps/web/playwright/teams/managed-event-types.e2e.ts @@ -1,6 +1,6 @@ import { expect } from "@playwright/test"; -import { test } from "./lib/fixtures"; +import { test } from "../lib/fixtures"; test.afterEach(({ users }) => users.deleteAll()); diff --git a/apps/web/playwright/teams.e2e.ts b/apps/web/playwright/teams/setup.e2e.ts similarity index 63% rename from apps/web/playwright/teams.e2e.ts rename to apps/web/playwright/teams/setup.e2e.ts index a8f4539e8a..449a9dab07 100644 --- a/apps/web/playwright/teams.e2e.ts +++ b/apps/web/playwright/teams/setup.e2e.ts @@ -3,8 +3,7 @@ import { expect } from "@playwright/test"; import { prisma } from "@calcom/prisma"; import { SchedulingType } from "@calcom/prisma/enums"; -import { test } from "./lib/fixtures"; -import { bookTimeSlot, selectFirstAvailableTimeSlotNextMonth, testName, todo } from "./lib/testUtils"; +import { test } from "../lib/fixtures"; test.describe.configure({ mode: "parallel" }); @@ -64,77 +63,6 @@ test.describe("Teams", () => { // await expect(page.locator('[data-testid="empty-screen"]')).toBeVisible(); }); }); - test("Can create a booking for Collective EventType", async ({ page, users }) => { - const ownerObj = { username: "pro-user", name: "pro-user" }; - const teamMatesObj = [ - { name: "teammate-1" }, - { name: "teammate-2" }, - { name: "teammate-3" }, - { name: "teammate-4" }, - ]; - - const owner = await users.create(ownerObj, { - hasTeam: true, - teammates: teamMatesObj, - 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 list - await expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName); - - // All the teammates should be in the booking - for (const teammate of teamMatesObj) { - await expect(page.getByText(teammate.name, { exact: true })).toBeVisible(); - } - - // TODO: Assert whether the user received an email - }); - test("Can create a booking for Round Robin EventType", async ({ page, users }) => { - const ownerObj = { username: "pro-user", name: "pro-user" }; - const teamMatesObj = [ - { name: "teammate-1" }, - { name: "teammate-2" }, - { name: "teammate-3" }, - { name: "teammate-4" }, - ]; - const owner = await users.create(ownerObj, { - hasTeam: true, - teammates: teamMatesObj, - schedulingType: SchedulingType.ROUND_ROBIN, - }); - - 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 person who booked the meeting should be in the attendee list - await expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName); - - // The title of the booking - const BookingTitle = `${teamEventTitle} between ${team.name} and ${testName}`; - await expect(page.locator("[data-testid=booking-title]")).toHaveText(BookingTitle); - - // 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 - }); test("Can create team with same name as user", async ({ page, users }) => { // Name to be used for both user and team const uniqueName = "test-unique-name"; @@ -208,8 +136,4 @@ test.describe("Teams", () => { await expect(page.locator('[data-testid="you-cannot-see-team-members"]')).toBeVisible(); await expect(page.locator('[data-testid="team-members-container"]')).toBeHidden(); }); - - todo("Create a Round Robin with different leastRecentlyBooked hosts"); - todo("Reschedule a Collective EventType booking"); - todo("Reschedule a Round Robin EventType booking"); }); diff --git a/apps/web/playwright/unpublished.e2e.ts b/apps/web/playwright/teams/unpublished.e2e.ts similarity index 99% rename from apps/web/playwright/unpublished.e2e.ts rename to apps/web/playwright/teams/unpublished.e2e.ts index fc5862ca7e..adc5aa0e77 100644 --- a/apps/web/playwright/unpublished.e2e.ts +++ b/apps/web/playwright/teams/unpublished.e2e.ts @@ -2,7 +2,7 @@ import { expect } from "@playwright/test"; import { SchedulingType } from "@calcom/prisma/enums"; -import { test } from "./lib/fixtures"; +import { test } from "../lib/fixtures"; test.describe.configure({ mode: "parallel" });