2022-11-10 20:23:56 +00:00
|
|
|
import { expect } from "@playwright/test";
|
|
|
|
|
2023-03-01 20:18:51 +00:00
|
|
|
import { prisma } from "@calcom/prisma";
|
2023-07-27 11:48:08 +00:00
|
|
|
import { SchedulingType } from "@calcom/prisma/enums";
|
2023-03-01 20:18:51 +00:00
|
|
|
|
2022-11-10 20:23:56 +00:00
|
|
|
import { test } from "./lib/fixtures";
|
2023-07-28 12:51:15 +00:00
|
|
|
import { bookTimeSlot, selectFirstAvailableTimeSlotNextMonth, testName, todo } from "./lib/testUtils";
|
2022-11-10 20:23:56 +00:00
|
|
|
|
|
|
|
test.describe.configure({ mode: "parallel" });
|
|
|
|
|
2023-03-01 20:18:51 +00:00
|
|
|
test.afterEach(({ users }) => users.deleteAll());
|
2022-11-10 20:23:56 +00:00
|
|
|
|
2023-03-01 20:18:51 +00:00
|
|
|
test.describe("Teams", () => {
|
2022-11-14 19:34:47 +00:00
|
|
|
test("Can create teams via Wizard", async ({ page, users }) => {
|
2022-11-10 20:23:56 +00:00
|
|
|
const user = await users.create();
|
|
|
|
const inviteeEmail = `${user.username}+invitee@example.com`;
|
2023-06-06 18:02:32 +00:00
|
|
|
await user.apiLogin();
|
2022-11-10 20:23:56 +00:00
|
|
|
await page.goto("/teams");
|
|
|
|
|
|
|
|
await test.step("Can create team", async () => {
|
|
|
|
// Click text=Create Team
|
|
|
|
await page.locator("text=Create Team").click();
|
|
|
|
await page.waitForURL("/settings/teams/new");
|
|
|
|
// Fill input[name="name"]
|
|
|
|
await page.locator('input[name="name"]').fill(`${user.username}'s Team`);
|
|
|
|
// Click text=Continue
|
|
|
|
await page.locator("text=Continue").click();
|
|
|
|
await page.waitForURL(/\/settings\/teams\/(\d+)\/onboard-members$/i);
|
|
|
|
await page.waitForSelector('[data-testid="pending-member-list"]');
|
|
|
|
expect(await page.locator('[data-testid="pending-member-item"]').count()).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
await test.step("Can add members", async () => {
|
|
|
|
// Click [data-testid="new-member-button"]
|
|
|
|
await page.locator('[data-testid="new-member-button"]').click();
|
|
|
|
// Fill [placeholder="email\@example\.com"]
|
|
|
|
await page.locator('[placeholder="email\\@example\\.com"]').fill(inviteeEmail);
|
|
|
|
// Click [data-testid="invite-new-member-button"]
|
|
|
|
await page.locator('[data-testid="invite-new-member-button"]').click();
|
2022-11-30 21:52:56 +00:00
|
|
|
await expect(page.locator(`li:has-text("${inviteeEmail}")`)).toBeVisible();
|
2022-11-10 20:23:56 +00:00
|
|
|
expect(await page.locator('[data-testid="pending-member-item"]').count()).toBe(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
await test.step("Can remove members", async () => {
|
|
|
|
const removeMemberButton = page.locator('[data-testid="remove-member-button"]');
|
|
|
|
await removeMemberButton.click();
|
|
|
|
await removeMemberButton.waitFor({ state: "hidden" });
|
|
|
|
expect(await page.locator('[data-testid="pending-member-item"]').count()).toBe(1);
|
2023-03-01 20:18:51 +00:00
|
|
|
// Cleanup here since this user is created without our fixtures.
|
|
|
|
await prisma.user.delete({ where: { email: inviteeEmail } });
|
2022-11-10 20:23:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
await test.step("Can publish team", async () => {
|
|
|
|
await page.locator("text=Publish team").click();
|
|
|
|
await page.waitForURL(/\/settings\/teams\/(\d+)\/profile$/i);
|
|
|
|
});
|
|
|
|
|
|
|
|
await test.step("Can disband team", async () => {
|
2022-11-22 19:18:47 +00:00
|
|
|
await page.locator("text=Disband Team").click();
|
2022-11-10 20:23:56 +00:00
|
|
|
await page.locator("text=Yes, disband team").click();
|
|
|
|
await page.waitForURL("/teams");
|
2022-11-14 19:34:47 +00:00
|
|
|
await expect(await page.locator(`text=${user.username}'s Team`).count()).toEqual(0);
|
|
|
|
// FLAKY: If other tests are running async this may mean there are >0 teams, empty screen will not be shown.
|
|
|
|
// await expect(page.locator('[data-testid="empty-screen"]')).toBeVisible();
|
2022-11-10 20:23:56 +00:00
|
|
|
});
|
|
|
|
});
|
2023-07-21 11:58:52 +00:00
|
|
|
test("Can create a booking for Collective EventType", async ({ page, users }) => {
|
|
|
|
const ownerObj = { username: "pro-user", name: "pro-user" };
|
2023-07-27 11:48:08 +00:00
|
|
|
const teamMatesObj = [
|
2023-07-28 12:51:15 +00:00
|
|
|
{ name: "teammate-1" },
|
|
|
|
{ name: "teammate-2" },
|
|
|
|
{ name: "teammate-3" },
|
|
|
|
{ name: "teammate-4" },
|
2023-07-27 11:48:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
const owner = await users.create(ownerObj, {
|
|
|
|
hasTeam: true,
|
|
|
|
teammates: teamMatesObj,
|
|
|
|
schedulingType: SchedulingType.COLLECTIVE,
|
2023-07-21 11:58:52 +00:00
|
|
|
});
|
2023-07-27 11:48:08 +00:00
|
|
|
const { team } = await owner.getTeam();
|
2023-07-28 12:51:15 +00:00
|
|
|
const { title: teamEventTitle, slug: teamEventSlug } = await owner.getFirstTeamEvent(team.id);
|
2023-07-21 11:58:52 +00:00
|
|
|
|
2023-07-27 11:48:08 +00:00
|
|
|
await page.goto(`/team/${team.slug}/${teamEventSlug}`);
|
|
|
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
|
|
|
await bookTimeSlot(page);
|
|
|
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
2023-07-28 12:51:15 +00:00
|
|
|
|
|
|
|
// 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
|
2023-07-27 11:48:08 +00:00
|
|
|
await expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName);
|
2023-07-21 11:58:52 +00:00
|
|
|
|
2023-07-28 12:51:15 +00:00
|
|
|
// All the teammates should be in the booking
|
2023-07-27 11:48:08 +00:00
|
|
|
for (const teammate of teamMatesObj) {
|
|
|
|
await expect(page.getByText(teammate.name, { exact: true })).toBeVisible();
|
|
|
|
}
|
2023-07-21 11:58:52 +00:00
|
|
|
|
2023-07-27 11:48:08 +00:00
|
|
|
// 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 = [
|
2023-07-28 12:51:15 +00:00
|
|
|
{ name: "teammate-1" },
|
|
|
|
{ name: "teammate-2" },
|
|
|
|
{ name: "teammate-3" },
|
|
|
|
{ name: "teammate-4" },
|
2023-07-27 11:48:08 +00:00
|
|
|
];
|
|
|
|
const owner = await users.create(ownerObj, {
|
|
|
|
hasTeam: true,
|
|
|
|
teammates: teamMatesObj,
|
|
|
|
schedulingType: SchedulingType.ROUND_ROBIN,
|
2023-07-21 11:58:52 +00:00
|
|
|
});
|
|
|
|
|
2023-07-27 11:48:08 +00:00
|
|
|
const { team } = await owner.getTeam();
|
2023-07-28 12:51:15 +00:00
|
|
|
const { title: teamEventTitle, slug: teamEventSlug } = await owner.getFirstTeamEvent(team.id);
|
2023-07-21 11:58:52 +00:00
|
|
|
|
2023-07-27 11:48:08 +00:00
|
|
|
await page.goto(`/team/${team.slug}/${teamEventSlug}`);
|
2023-07-21 11:58:52 +00:00
|
|
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
|
|
|
await bookTimeSlot(page);
|
|
|
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
2023-07-27 11:48:08 +00:00
|
|
|
|
|
|
|
// The person who booked the meeting should be in the attendee list
|
2023-07-21 11:58:52 +00:00
|
|
|
await expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName);
|
|
|
|
|
2023-07-27 11:48:08 +00:00
|
|
|
// The title of the booking
|
|
|
|
const BookingTitle = `${teamEventTitle} between ${team.name} and ${testName}`;
|
|
|
|
await expect(page.locator("[data-testid=booking-title]")).toHaveText(BookingTitle);
|
2023-07-21 11:58:52 +00:00
|
|
|
|
2023-07-28 12:51:15 +00:00
|
|
|
// 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);
|
2023-07-21 11:58:52 +00:00
|
|
|
// TODO: Assert whether the user received an email
|
|
|
|
});
|
2023-08-22 11:03:00 +00:00
|
|
|
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";
|
|
|
|
const ownerObj = { username: uniqueName, name: uniqueName, useExactUsername: true };
|
|
|
|
|
|
|
|
const user = await users.create(ownerObj);
|
|
|
|
await user.apiLogin();
|
|
|
|
await page.goto("/teams");
|
|
|
|
|
|
|
|
await test.step("Can create team with same name", async () => {
|
|
|
|
// Click text=Create Team
|
|
|
|
await page.locator("text=Create Team").click();
|
|
|
|
await page.waitForURL("/settings/teams/new");
|
|
|
|
// Fill input[name="name"]
|
|
|
|
await page.locator('input[name="name"]').fill(uniqueName);
|
|
|
|
// Click text=Continue
|
|
|
|
await page.locator("text=Continue").click();
|
|
|
|
await page.waitForURL(/\/settings\/teams\/(\d+)\/onboard-members$/i);
|
|
|
|
// Click text=Continue
|
|
|
|
await page.locator("text=Publish team").click();
|
|
|
|
await page.waitForURL(/\/settings\/teams\/(\d+)\/profile$/i);
|
|
|
|
});
|
|
|
|
|
|
|
|
await test.step("Can access user and team with same slug", async () => {
|
|
|
|
// Go to team page and confirm name
|
|
|
|
const teamUrl = `/team/${uniqueName}`;
|
|
|
|
await page.goto(teamUrl);
|
|
|
|
await page.waitForURL(teamUrl);
|
|
|
|
await expect(page.locator("[data-testid=team-name]")).toHaveText(uniqueName);
|
|
|
|
|
|
|
|
// Go to user page and confirm name
|
|
|
|
const userUrl = `/${uniqueName}`;
|
|
|
|
await page.goto(userUrl);
|
|
|
|
await page.waitForURL(userUrl);
|
|
|
|
await expect(page.locator("[data-testid=name-title]")).toHaveText(uniqueName);
|
|
|
|
|
|
|
|
// cleanup team
|
|
|
|
const team = await prisma.team.findFirst({ where: { slug: uniqueName } });
|
|
|
|
await prisma.team.delete({ where: { id: team?.id } });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-07-28 12:51:15 +00:00
|
|
|
todo("Create a Round Robin with different leastRecentlyBooked hosts");
|
2023-07-27 11:48:08 +00:00
|
|
|
todo("Reschedule a Collective EventType booking");
|
|
|
|
todo("Reschedule a Round Robin EventType booking");
|
2022-11-10 20:23:56 +00:00
|
|
|
});
|