Skip to content

Scheduling infrastructure for absolutely everyone.

test: Create E2E tests for bookings for all questions together as custom/required (teste2e-allQuestions) (#11592)

gitstart-app[bot]5348464972cb
diff --git a/apps/web/playwright/booking/allQuestions.e2e.ts b/apps/web/playwright/booking/allQuestions.e2e.ts
new file mode 100644
index 00000000000..14870f96727
--- /dev/null
+++ b/apps/web/playwright/booking/allQuestions.e2e.ts
@@ -0,0 +1,110 @@
+/* eslint-disable playwright/no-conditional-in-test */
+import { loginUser } from "../fixtures/regularBookings";
+import { test } from "../lib/fixtures";
+
+test.describe("Booking With All Questions", () => {
+ test.beforeEach(async ({ page, users, bookingPage }) => {
+ await loginUser(users);
+ await page.goto("/event-types");
+ await bookingPage.goToEventType("30 min");
+ await bookingPage.goToTab("event_advanced_tab_title");
+ });
+
+ const bookingOptions = { isAllRequired: true };
+
+ 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" &&
+ 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", async ({ bookingPage }) => {
+ const allQuestions = [
+ "phone",
+ "address",
+ "checkbox",
+ "boolean",
+ "textarea",
+ "multiemail",
+ "multiselect",
+ "number",
+ "radio",
+ "select",
+ "text",
+ ];
+ 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);
+ }
+
+ 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);
+ });
+});
diff --git a/apps/web/playwright/fixtures/regularBookings.ts b/apps/web/playwright/fixtures/regularBookings.ts
index 5fea0d62fad..72c8e44fea3 100644
--- a/apps/web/playwright/fixtures/regularBookings.ts
+++ b/apps/web/playwright/fixtures/regularBookings.ts
@@ -15,6 +15,7 @@ type BookingOptions = {
hasPlaceholder?: boolean;
isReschedule?: boolean;
isRequired?: boolean;
+ isAllRequired?: boolean;
isMultiSelect?: boolean;
};
@@ -116,6 +117,61 @@ const fillQuestion = async (eventTypePage: Page, questionType: string, customLoc
}
};
+const fillAllQuestions = async (eventTypePage: Page, questions: string[], options: BookingOptions) => {
+ if (options.isAllRequired) {
+ for (const question of questions) {
+ switch (question) {
+ case "email":
+ await eventTypePage.getByPlaceholder("Email").click();
+ await eventTypePage.getByPlaceholder("Email").fill(EMAIL);
+ break;
+ case "phone":
+ await eventTypePage.getByPlaceholder("Phone test").click();
+ await eventTypePage.getByPlaceholder("Phone test").fill(PHONE);
+ break;
+ case "address":
+ await eventTypePage.getByPlaceholder("Address test").click();
+ await eventTypePage.getByPlaceholder("Address test").fill("123 Main St, City, Country");
+ break;
+ case "textarea":
+ await eventTypePage.getByPlaceholder("Textarea test").click();
+ await eventTypePage.getByPlaceholder("Textarea test").fill("This is a sample text for textarea.");
+ break;
+ case "select":
+ await eventTypePage.locator("form svg").last().click();
+ await eventTypePage.getByTestId("select-option-Option 1").click();
+ break;
+ case "multiselect":
+ await eventTypePage.locator("form svg").nth(4).click();
+ await eventTypePage.getByTestId("select-option-Option 1").click();
+ break;
+ case "number":
+ await eventTypePage.getByLabel("number test").click();
+ await eventTypePage.getByLabel("number test").fill("123");
+ break;
+ case "radio":
+ await eventTypePage.getByRole("radiogroup").getByText("Option 1").check();
+ break;
+ case "text":
+ await eventTypePage.getByPlaceholder("Text test").click();
+ await eventTypePage.getByPlaceholder("Text test").fill("Sample text");
+ break;
+ case "checkbox":
+ await eventTypePage.getByLabel("Option 1").first().check();
+ await eventTypePage.getByLabel("Option 2").first().check();
+ break;
+ case "boolean":
+ await eventTypePage.getByLabel(`${question} test`).check();
+ break;
+ case "multiemail":
+ await eventTypePage.getByRole("button", { name: "multiemail test" }).click();
+ await eventTypePage.getByPlaceholder("multiemail test").fill(EMAIL);
+ break;
+ }
+ }
+ }
+};
+
export async function loginUser(users: UserFixture) {
const pro = await users.create({ name: "testuser" });
await pro.apiLogin();
@@ -282,5 +338,23 @@ export function createBookingPageFixture(page: Page) {
await scheduleSuccessfullyPage.waitFor({ state: "visible" });
await expect(scheduleSuccessfullyPage).toBeVisible();
},
+ checkField: async (question: string) => {
+ await expect(page.getByTestId(`field-${question}-test`)).toBeVisible();
+ },
+ fillAllQuestions: async (eventTypePage: Page, questions: string[], options: BookingOptions) => {
+ const confirmButton = options.isReschedule ? "confirm-reschedule-button" : "confirm-book-button";
+ await fillAllQuestions(eventTypePage, questions, options);
+ 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 fillAllQuestions(eventTypePage, questions, options);
+ await eventTypePage.getByTestId(confirmButton).click();
+ }
+ const scheduleSuccessfullyPage = eventTypePage.getByText(scheduleSuccessfullyText);
+ await scheduleSuccessfullyPage.waitFor({ state: "visible" });
+ await expect(scheduleSuccessfullyPage).toBeVisible();
+ },
};
}