chore: team booking test (#10440)
* feat: add team name in the createTeam fixture * chore: remove unnecessary variables * test: e2e booking for Round Robin EventType * feat: teammates in user fixtures * chore: DRY * fix: remove redundant todo * fix: add teamEvent title and slug in scenario * test: booking title, RR hostname
This commit is contained in:
parent
e8339030c2
commit
344b9e9b2b
|
@ -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>
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 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();
|
||||
}
|
||||
|
@ -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");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user