Create E2E tests for collective bookings for all questions together as custom/required
This commit is contained in:
commit
3b09cc0536
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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 };
|
|
@ -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 }) => {
|
|
@ -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 };
|
|
@ -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 };
|
|
@ -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 };
|
|
@ -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 };
|
|
@ -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 };
|
|
@ -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 };
|
|
@ -1,6 +1,7 @@
|
|||
import { expect, type Page } from "@playwright/test";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { randomString } from "@calcom/lib/random";
|
||||
|
||||
import type { createUsersFixture } from "./users";
|
||||
|
||||
|
@ -19,6 +20,8 @@ type BookingOptions = {
|
|||
isMultiSelect?: boolean;
|
||||
};
|
||||
|
||||
type teamBookingtypes = { isManagedType?: boolean; isRoundRobinType?: boolean; isCollectiveType?: boolean };
|
||||
|
||||
interface QuestionActions {
|
||||
[key: string]: () => Promise<void>;
|
||||
}
|
||||
|
@ -190,8 +193,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();
|
||||
|
@ -219,8 +235,12 @@ export function createBookingPageFixture(page: Page) {
|
|||
}
|
||||
await page.getByTestId("field-add-save").click();
|
||||
},
|
||||
updateEventType: async () => {
|
||||
updateEventType: async (options?: { shouldCheck: boolean }) => {
|
||||
await page.getByTestId("update-eventtype").click();
|
||||
options?.shouldCheck &&
|
||||
(await expect(
|
||||
page.getByRole("button", { name: "Test Managed Event Type event type updated successfully" })
|
||||
).toBeVisible());
|
||||
},
|
||||
previewEventType: async () => {
|
||||
const eventtypePromise = page.waitForEvent("popup");
|
||||
|
@ -338,7 +358,13 @@ export function createBookingPageFixture(page: Page) {
|
|||
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) => {
|
||||
|
@ -356,5 +382,101 @@ export function createBookingPageFixture(page: Page) {
|
|||
await scheduleSuccessfullyPage.waitFor({ state: "visible" });
|
||||
await expect(scheduleSuccessfullyPage).toBeVisible();
|
||||
},
|
||||
createTeam: async (name: string) => {
|
||||
await page.getByRole("link", { name: "Teams" }).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: "Continue" }).click();
|
||||
await page.getByRole("button", { name: "Publish team" }).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
|
||||
await expect(
|
||||
page
|
||||
.locator("div")
|
||||
.filter({ hasText: "Managed EventCreate & distribute event types in bulk to team members" })
|
||||
).toBeHidden();
|
||||
await page.getByTestId("dialog-rejection").click();
|
||||
|
||||
await page.getByTestId("new-event-type").click();
|
||||
await page.getByTestId("option-team-1").click();
|
||||
await page.getByPlaceholder("Quick Chat").fill(name);
|
||||
if (options.isCollectiveType) {
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: "CollectiveSchedule meetings when all selected team members are available." })
|
||||
.getByRole("radio")
|
||||
.first()
|
||||
.click();
|
||||
}
|
||||
|
||||
if (options.isRoundRobinType) {
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: "Round RobinCycle meetings between multiple team members." })
|
||||
.getByRole("radio")
|
||||
.nth(1)
|
||||
.click();
|
||||
}
|
||||
|
||||
if (options.isManagedType) {
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: "Managed EventCreate & distribute event types in bulk to team members" })
|
||||
.getByRole("radio")
|
||||
.last()
|
||||
.click();
|
||||
await expect(
|
||||
page.getByText('"username" will be filled by the username of the members assigned')
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
await page.getByRole("button", { name: "Continue" }).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
|
||||
await expect(
|
||||
page.getByText("Members assigned to this event type will also have their event types deleted.")
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByText("Anyone who they've shared their link with will no longer be able to book using it")
|
||||
).toBeVisible();
|
||||
await page.getByRole("button", { name: "Yes, delete" }).click();
|
||||
|
||||
// Check if the correct image is showed when there is no event type
|
||||
await expect(page.getByTestId("empty-screen")).toBeVisible();
|
||||
},
|
||||
assertManagedEventTypeDeleted: async () => {
|
||||
await expect(page.getByRole("button", { name: "Event type deleted successfully" })).toBeVisible();
|
||||
},
|
||||
deleteTeam: async () => {
|
||||
await page.getByRole("link", { name: "Teams" }).click();
|
||||
await page.getByRole("link", { name: "Team Logo Test Team" }).click();
|
||||
await page.getByRole("button", { name: "Disband Team" }).click();
|
||||
await page.getByRole("button", { name: "Yes, disband team" }).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 () => {
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Your team has been disbanded successfully" })
|
||||
).toBeVisible();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user