Compare commits

...

1 Commits

Author SHA1 Message Date
gitstart-calcom 819376417f Add new functions / create test 2023-10-24 15:18:58 +00:00
4 changed files with 100 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { loginUser } from "../fixtures/regularBookings";
import { loginUser } from "../fixtures/bookingPage";
import { test } from "../lib/fixtures";
test.describe("Booking With Phone Question and Each Other Question", () => {

View File

@ -1,5 +1,7 @@
import { expect, type Page } from "@playwright/test";
import { randomString } from "@calcom/lib/random";
import type { createUsersFixture } from "./users";
const reschedulePlaceholderText = "Let others know why you need to reschedule";
@ -115,8 +117,21 @@ export async function loginUser(users: UserFixture) {
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();
@ -251,5 +266,63 @@ 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();
},
createManagedEventType: async (name: string) => {
await page.getByTestId("new-event-type").click();
await page.getByTestId("option-0").click();
await page.getByTestId("dialog-rejection").click();
// We first simulate to creste 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("new-event-type").click();
await page.getByTestId("option-team-1").click();
await page.getByPlaceholder("Quick Chat").fill(name);
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 page.getByTestId("update-eventtype").click();
},
removeManagedEventType: async () => {
await page.getByRole("main").getByRole("button").nth(1).click();
await page
.locator("header")
.filter({ hasText: "Test Managed Event TypeSave" })
.getByRole("button")
.first()
.click();
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();
},
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();
},
};
}

View File

@ -7,10 +7,10 @@ import { IS_MAILHOG_ENABLED } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import type { ExpectedUrlDetails } from "../../../../playwright.config";
import { createBookingPageFixture } from "../fixtures/bookingPage";
import { createBookingsFixture } from "../fixtures/bookings";
import { createEmbedsFixture } from "../fixtures/embeds";
import { createPaymentsFixture } from "../fixtures/payments";
import { createBookingPageFixture } from "../fixtures/regularBookings";
import { createRoutingFormsFixture } from "../fixtures/routingForms";
import { createServersFixture } from "../fixtures/servers";
import { createUsersFixture } from "../fixtures/users";

View File

@ -0,0 +1,23 @@
import { expect } from "@playwright/test";
import { loginUser } from "../fixtures/bookingPage";
import { test } from "../lib/fixtures";
test.describe("Create a Managed Event Type", () => {
test("Check if the event type is showed correctly", async ({ page, bookingPage, users }) => {
await loginUser(users);
await page.goto("/event-types");
await bookingPage.createTeam("Test Team");
await bookingPage.goToTab("Back");
await bookingPage.createManagedEventType("Test Managed Event Type");
await bookingPage.goToEventType("Event Types");
await expect(
page.getByRole("link", {
name: "Test Managed Event Type",
})
).toBeVisible();
await bookingPage.goToEventType("Test Managed Event", { clickOnFirst: true });
await bookingPage.removeManagedEventType();
await bookingPage.deleteTeam();
});
});