Compare commits
18 Commits
main
...
teste2e-al
Author | SHA1 | Date |
---|---|---|
gitstart-calcom | ebb9b9f459 | |
GitStart-Cal.com | 032bd9d373 | |
GitStart-Cal.com | d45ccc15ba | |
GitStart-Cal.com | 2b2f1abbec | |
gitstart-calcom | 18facb7626 | |
gitstart-calcom | 65b614182d | |
gitstart-calcom | d6b7620b84 | |
gitstart-calcom | 9a17ffbdc3 | |
gitstart-calcom | 398e00afed | |
GitStart-Cal.com | 19fe881094 | |
GitStart-Cal.com | 5dd1a0f7a4 | |
gitstart-calcom | 61ead4f4a2 | |
gitstart-calcom | 3e2d0ce603 | |
GitStart-Cal.com | a48ed7e126 | |
gitstart-calcom | 5f32d4652a | |
gitstart-calcom | 972cb6b9af | |
GitStart-Cal.com | 06612d3dfb | |
gitstart-calcom | 2d154979d2 |
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
|
@ -13,6 +13,7 @@ type BookingOptions = {
|
||||||
hasPlaceholder?: boolean;
|
hasPlaceholder?: boolean;
|
||||||
isReschedule?: boolean;
|
isReschedule?: boolean;
|
||||||
isRequired?: boolean;
|
isRequired?: boolean;
|
||||||
|
isAllRequired?: boolean;
|
||||||
isMultiSelect?: boolean;
|
isMultiSelect?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,6 +110,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) {
|
export async function loginUser(users: UserFixture) {
|
||||||
const pro = await users.create({ name: "testuser" });
|
const pro = await users.create({ name: "testuser" });
|
||||||
await pro.apiLogin();
|
await pro.apiLogin();
|
||||||
|
@ -194,6 +250,14 @@ export function createBookingPageFixture(page: Page) {
|
||||||
await eventTypePage.getByPlaceholder(reschedulePlaceholderText).click();
|
await eventTypePage.getByPlaceholder(reschedulePlaceholderText).click();
|
||||||
await eventTypePage.getByPlaceholder(reschedulePlaceholderText).fill("Test reschedule");
|
await eventTypePage.getByPlaceholder(reschedulePlaceholderText).fill("Test reschedule");
|
||||||
await eventTypePage.getByTestId("confirm-reschedule-button").click();
|
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) => {
|
assertBookingRescheduled: async (page: Page) => {
|
||||||
|
@ -252,5 +316,23 @@ export function createBookingPageFixture(page: Page) {
|
||||||
await scheduleSuccessfullyPage.waitFor({ state: "visible" });
|
await scheduleSuccessfullyPage.waitFor({ state: "visible" });
|
||||||
await expect(scheduleSuccessfullyPage).toBeVisible();
|
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();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue