Compare commits

...

8 Commits

10 changed files with 265 additions and 63 deletions

View File

@ -0,0 +1,98 @@
/* eslint-disable playwright/no-conditional-in-test */
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Collective Booking With All Questions", () => {
test.beforeEach(async ({ page, users, bookingPage }) => {
await loginUser(users);
await page.goto("/event-types");
await bookingPage.createTeam("Test Team");
await bookingPage.createTeamEventType("Test Collective Event Type", { isCollectiveType: true });
await bookingPage.goToTab("event_advanced_tab_title");
});
const bookingOptions = { isAllRequired: true };
const allQuestions = [
"phone",
"address",
"checkbox",
"boolean",
"textarea",
"multiemail",
"multiselect",
"number",
"radio",
"select",
"text",
];
test("Selecting and filling all questions as required (Collective Event)", async ({ bookingPage }) => {
for (const question of allQuestions) {
if (
question !== "number" &&
question !== "select" &&
question !== "checkbox" &&
question !== "boolean" &&
question !== "multiselect" &&
question !== "radio"
) {
await bookingPage.addQuestion(
question,
`${question}-test`,
`${question} test`,
true,
`${question} test`
);
} else {
await bookingPage.addQuestion(question, `${question}-test`, `${question} test`, true);
}
await bookingPage.checkField(question);
}
await bookingPage.updateEventType();
const eventTypePage = await bookingPage.previewEventType();
await bookingPage.selectTimeSlot(eventTypePage);
await bookingPage.fillAllQuestions(eventTypePage, allQuestions, bookingOptions);
await bookingPage.rescheduleBooking(eventTypePage);
await bookingPage.assertBookingRescheduled(eventTypePage);
await bookingPage.cancelBooking(eventTypePage);
await bookingPage.assertBookingCanceled(eventTypePage);
});
test("Selecting and filling all questions as optional (Collective Event)", async ({ bookingPage }) => {
for (const question of allQuestions) {
if (
question !== "number" &&
question !== "select" &&
question !== "checkbox" &&
question !== "boolean" &&
question !== "multiselect" &&
question !== "radio"
) {
await bookingPage.addQuestion(
question,
`${question}-test`,
`${question} test`,
false,
`${question} test`
);
} else {
await bookingPage.addQuestion(question, `${question}-test`, `${question} test`, false);
}
await bookingPage.checkField(question, { isOptional: true });
}
await bookingPage.updateEventType();
const eventTypePage = await bookingPage.previewEventType();
await bookingPage.selectTimeSlot(eventTypePage);
await bookingPage.fillAllQuestions(eventTypePage, allQuestions, {
...bookingOptions,
isAllRequired: false,
});
await bookingPage.rescheduleBooking(eventTypePage);
await bookingPage.assertBookingRescheduled(eventTypePage);
await bookingPage.cancelBooking(eventTypePage);
await bookingPage.assertBookingCanceled(eventTypePage);
});
});

View File

@ -1,5 +1,5 @@
import { loginUser } from "../../fixtures/regularBookings";
import { test } from "../../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With Address Question and Each Other Question", () => {
const bookingOptions = { hasPlaceholder: true, isRequired: true };

View File

@ -1,6 +1,6 @@
/* eslint-disable playwright/no-conditional-in-test */
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With All Questions", () => {
test.beforeEach(async ({ page, users, bookingPage }) => {
@ -12,20 +12,21 @@ test.describe("Booking With All Questions", () => {
const bookingOptions = { isAllRequired: true };
const allQuestions = [
"phone",
"address",
"checkbox",
"boolean",
"textarea",
"multiemail",
"multiselect",
"number",
"radio",
"select",
"text",
];
test("Selecting and filling all questions as required", async ({ bookingPage }) => {
const allQuestions = [
"phone",
"address",
"checkbox",
"boolean",
"textarea",
"multiemail",
"multiselect",
"number",
"radio",
"select",
"text",
];
for (const question of allQuestions) {
if (
question !== "number" &&
@ -59,19 +60,6 @@ test.describe("Booking With All Questions", () => {
});
test("Selecting and filling all questions as optional", async ({ bookingPage }) => {
const allQuestions = [
"phone",
"address",
"checkbox",
"boolean",
"textarea",
"multiemail",
"multiselect",
"number",
"radio",
"select",
"text",
];
for (const question of allQuestions) {
if (
question !== "number" &&
@ -91,7 +79,7 @@ test.describe("Booking With All Questions", () => {
} else {
await bookingPage.addQuestion(question, `${question}-test`, `${question} test`, false);
}
await bookingPage.checkField(question);
await bookingPage.checkField(question, { isOptional: true });
}
await bookingPage.updateEventType();

View File

@ -1,5 +1,5 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With Checkbox Group Question and Each Other Question", () => {
const bookingOptions = { hasPlaceholder: true, isRequired: true };

View File

@ -1,5 +1,5 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With Long Text Question and Each Other Question", () => {
const bookingOptions = { hasPlaceholder: true, isRequired: true };

View File

@ -1,5 +1,5 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With Multiple Email Question and Each Other Question", () => {
const bookingOptions = { hasPlaceholder: true, isRequired: true };

View File

@ -1,5 +1,5 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With Phone Question and Each Other Question", () => {
const bookingOptions = { hasPlaceholder: true, isRequired: true };

View File

@ -1,5 +1,5 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With Radio Question and Each Other Question", () => {
const bookingOptions = { hasPlaceholder: true, isRequired: true };

View File

@ -1,5 +1,5 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
import { loginUser } from "../../../fixtures/regularBookings";
import { test } from "../../../lib/fixtures";
test.describe("Booking With Phone Question and Each Other Question", () => {
const bookingOptions = { hasPlaceholder: true, isRequired: true };

View File

@ -1,6 +1,7 @@
import { expect, type Page } from "@playwright/test";
import dayjs from "@calcom/dayjs";
import { randomString } from "@calcom/lib/random";
import { localize } from "../lib/testUtils";
import type { createUsersFixture } from "./users";
@ -20,6 +21,8 @@ type BookingOptions = {
isMultiSelect?: boolean;
};
type teamBookingtypes = { isManagedType?: boolean; isRoundRobinType?: boolean; isCollectiveType?: boolean };
interface QuestionActions {
[key: string]: () => Promise<void>;
}
@ -192,8 +195,21 @@ const goToNextMonthIfNoAvailabilities = async (eventTypePage: Page) => {
export function createBookingPageFixture(page: Page) {
return {
goToEventType: async (eventType: string) => {
await page.getByRole("link", { name: eventType }).click();
goToEventType: async (
eventType: string,
options?: {
clickOnFirst?: boolean;
clickOnLast?: boolean;
}
) => {
if (options?.clickOnFirst) {
await page.getByRole("link", { name: eventType }).first().click();
}
if (options?.clickOnLast) {
await page.getByRole("link", { name: eventType }).last().click();
} else {
await page.getByRole("link", { name: eventType }).click();
}
},
goToTab: async (tabName: string) => {
await page.getByTestId(`vertical-tab-${tabName}`).click();
@ -238,8 +254,12 @@ export function createBookingPageFixture(page: Page) {
.getByRole("spinbutton")
.fill(maxEvents);
},
updateEventType: async () => {
updateEventType: async (options?: { shouldCheck: boolean; name: string }) => {
await page.getByTestId("update-eventtype").click();
options?.shouldCheck &&
(await expect(
page.getByRole("button", { name: `${options?.name} event type updated successfully` })
).toBeVisible());
},
previewEventType: async () => {
const eventtypePromise = page.waitForEvent("popup");
@ -291,14 +311,6 @@ export function createBookingPageFixture(page: Page) {
await eventTypePage.getByPlaceholder(reschedulePlaceholderText).click();
await eventTypePage.getByPlaceholder(reschedulePlaceholderText).fill("Test reschedule");
await eventTypePage.getByTestId("confirm-reschedule-button").click();
await eventTypePage.waitForTimeout(400);
if (
await eventTypePage.getByRole("heading", { name: "Could not reschedule the meeting." }).isVisible()
) {
await eventTypePage.getByTestId("back").click();
await eventTypePage.getByTestId("time").last().click();
await eventTypePage.getByTestId("confirm-reschedule-button").click();
}
},
assertBookingRescheduled: async (page: Page) => {
@ -357,19 +369,17 @@ export function createBookingPageFixture(page: Page) {
options.isRequired && (await fillQuestion(eventTypePage, secondQuestion, customLocators));
await eventTypePage.getByTestId(confirmButton).click();
await eventTypePage.waitForTimeout(400);
if (await eventTypePage.getByRole("heading", { name: "Could not book the meeting." }).isVisible()) {
await eventTypePage.getByTestId("back").click();
await eventTypePage.getByTestId("time").last().click();
await fillQuestion(eventTypePage, question, customLocators);
options.isRequired && (await fillQuestion(eventTypePage, secondQuestion, customLocators));
await eventTypePage.getByTestId(confirmButton).click();
}
const scheduleSuccessfullyPage = eventTypePage.getByText(scheduleSuccessfullyText);
await scheduleSuccessfullyPage.waitFor({ state: "visible" });
await expect(scheduleSuccessfullyPage).toBeVisible();
},
checkField: async (question: string) => {
checkField: async (question: string, options?: { isOptional: boolean }) => {
if (options?.isOptional) {
await expect(page.getByTestId(`field-${question}-test`).getByText("Optional")).toBeVisible();
} else {
await expect(page.getByTestId(`field-${question}-test`).getByText("Required")).toBeVisible();
}
await expect(page.getByTestId(`field-${question}-test`)).toBeVisible();
},
fillAllQuestions: async (eventTypePage: Page, questions: string[], options: BookingOptions) => {
@ -387,5 +397,111 @@ export function createBookingPageFixture(page: Page) {
await scheduleSuccessfullyPage.waitFor({ state: "visible" });
await expect(scheduleSuccessfullyPage).toBeVisible();
},
createTeam: async (name: string) => {
const teamsText = (await localize("en"))("teams");
const continueText = (await localize("en"))("continue");
const publishTeamText = (await localize("en"))("team_publish");
await page.getByRole("link", { name: teamsText }).click();
await page.getByTestId("new-team-btn").click();
await page.getByPlaceholder("Acme Inc.").click();
await page.getByPlaceholder("Acme Inc.").fill(`${name}-${randomString(3)}`);
await page.getByRole("button", { name: continueText }).click();
await page.getByRole("button", { name: publishTeamText }).click();
await page.getByTestId("vertical-tab-Back").click();
},
createTeamEventType: async (name: string, options: teamBookingtypes) => {
await page.getByTestId("new-event-type").click();
await page.getByTestId("option-0").click();
// We first simulate to create a default event type to check if managed option is not available
const managedEventDescription = (await localize("en"))("managed_event_description");
const roundRobinEventDescription = (await localize("en"))("round_robin_description");
const collectiveEventDescription = (await localize("en"))("collective_description");
const quickChatText = (await localize("en"))("quick_chat");
await expect(page.locator("div").filter({ hasText: managedEventDescription })).toBeHidden();
await page.getByTestId("dialog-rejection").click();
await page.getByTestId("new-event-type").click();
await page.getByTestId("option-team-1").click();
await page.getByPlaceholder(quickChatText).fill(name);
if (options.isCollectiveType) {
await page
.locator("div")
.filter({ hasText: `Collective${collectiveEventDescription}` })
.getByRole("radio")
.first()
.click();
}
if (options.isRoundRobinType) {
await page
.locator("div")
.filter({ hasText: `Round Robin${roundRobinEventDescription}` })
.getByRole("radio")
.nth(1)
.click();
}
if (options.isManagedType) {
await page
.locator("div")
.filter({ hasText: `Managed Event${managedEventDescription}` })
.getByRole("radio")
.last()
.click();
const managedEventClarification = (await localize("en"))("managed_event_url_clarification");
await expect(page.getByText(managedEventClarification)).toBeVisible();
}
const continueText = (await localize("en"))("continue");
await page.getByRole("button", { name: continueText }).click();
await expect(page.getByRole("button", { name: "event type created successfully" })).toBeVisible();
await page.getByTestId("update-eventtype").click();
},
removeManagedEventType: async () => {
await page
.locator("header")
.filter({ hasText: "Test Managed Event TypeSave" })
.getByRole("button")
.first()
.click();
// Check if the correct messages is showed in the dialog
const deleteManagedEventTypeDescription = (await localize("en"))(
"delete_managed_event_type_description"
);
const confirmDeleteEventTypeText = (await localize("en"))("confirm_delete_event_type");
await expect(page.getByText(deleteManagedEventTypeDescription)).toBeVisible();
await page.getByRole("button", { name: confirmDeleteEventTypeText }).click();
// Check if the correct image is showed when there is no event type
await expect(page.getByTestId("empty-screen")).toBeVisible();
},
assertManagedEventTypeDeleted: async () => {
const eventTypeDeletedText = (await localize("en"))("event_type_deleted_successfully");
await expect(page.getByRole("button", { name: eventTypeDeletedText })).toBeVisible();
},
deleteTeam: async () => {
const teamsText = (await localize("en"))("teams");
const teamLogoText = (await localize("en"))("team_logo");
const disbandTeamText = (await localize("en"))("disband_team");
const confirmDisbandTeamText = (await localize("en"))("confirm_disband_team");
await page.getByRole("link", { name: teamsText }).click();
await page.getByRole("link", { name: `${teamLogoText} Test Team` }).click();
await page.getByRole("button", { name: disbandTeamText }).click();
await page.getByRole("button", { name: confirmDisbandTeamText }).click();
// Check if the correct image is showed when there is no team
await expect(page.getByRole("img", { name: "Cal.com is better with teams" })).toBeVisible();
},
assertTeamDeleted: async () => {
const teamDisbandedText = (await localize("en"))("your_team_disbanded_successfully");
await expect(page.getByRole("button", { name: teamDisbandedText })).toBeVisible();
},
};
}