test: New Booker Tests for Embed (#9666)
This commit is contained in:
parent
79b3875af3
commit
2272da5ee7
|
@ -101,7 +101,7 @@ async function selectFirstAvailableTimeSlotNextMonth(frame: Frame, page: Page) {
|
||||||
await frame.click('[data-testid="time"]');
|
await frame.click('[data-testid="time"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bookFirstEvent(username: string, frame: Frame, page: Page) {
|
export async function bookFirstEvent(username: string, frame: Frame, page: Page, bookerVariant: string) {
|
||||||
// Click first event type on Profile Page
|
// Click first event type on Profile Page
|
||||||
await frame.click('[data-testid="event-type-link"]');
|
await frame.click('[data-testid="event-type-link"]');
|
||||||
await frame.waitForURL((url) => {
|
await frame.waitForURL((url) => {
|
||||||
|
@ -125,9 +125,11 @@ export async function bookFirstEvent(username: string, frame: Frame, page: Page)
|
||||||
// Remove /embed from the end if present.
|
// Remove /embed from the end if present.
|
||||||
const eventSlug = new URL(frame.url()).pathname.replace(/\/embed$/, "");
|
const eventSlug = new URL(frame.url()).pathname.replace(/\/embed$/, "");
|
||||||
await selectFirstAvailableTimeSlotNextMonth(frame, page);
|
await selectFirstAvailableTimeSlotNextMonth(frame, page);
|
||||||
await frame.waitForURL((url) => {
|
if (bookerVariant !== "new-booker") {
|
||||||
return url.pathname.includes(`/${username}/book`);
|
await frame.waitForURL((url) => {
|
||||||
});
|
return url.pathname.includes(`/${username}/book`);
|
||||||
|
});
|
||||||
|
}
|
||||||
// expect(await page.screenshot()).toMatchSnapshot("booking-page.png");
|
// expect(await page.screenshot()).toMatchSnapshot("booking-page.png");
|
||||||
// --- fill form
|
// --- fill form
|
||||||
await frame.fill('[name="name"]', "Embed User");
|
await frame.fill('[name="name"]', "Embed User");
|
||||||
|
@ -150,11 +152,13 @@ export async function bookFirstEvent(username: string, frame: Frame, page: Page)
|
||||||
return booking;
|
return booking;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function rescheduleEvent(username: string, frame: Frame, page: Page) {
|
export async function rescheduleEvent(username: string, frame: Frame, page: Page, bookerVariant: string) {
|
||||||
await selectFirstAvailableTimeSlotNextMonth(frame, page);
|
await selectFirstAvailableTimeSlotNextMonth(frame, page);
|
||||||
await frame.waitForURL((url: { pathname: string | string[] }) => {
|
if (bookerVariant !== "new-booker") {
|
||||||
return url.pathname.includes(`/${username}/book`);
|
await frame.waitForURL((url: { pathname: string | string[] }) => {
|
||||||
});
|
return url.pathname.includes(`/${username}/book`);
|
||||||
|
});
|
||||||
|
}
|
||||||
// --- fill form
|
// --- fill form
|
||||||
await frame.press('[name="email"]', "Enter");
|
await frame.press('[name="email"]', "Enter");
|
||||||
await frame.click("[data-testid=confirm-reschedule-button]");
|
await frame.click("[data-testid=confirm-reschedule-button]");
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { expect } from "@playwright/test";
|
||||||
|
|
||||||
import { test } from "@calcom/web/playwright/lib/fixtures";
|
import { test } from "@calcom/web/playwright/lib/fixtures";
|
||||||
import type { Fixtures } from "@calcom/web/playwright/lib/fixtures";
|
import type { Fixtures } from "@calcom/web/playwright/lib/fixtures";
|
||||||
|
import { testBothBookers } from "@calcom/web/playwright/lib/new-booker";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
todo,
|
todo,
|
||||||
|
@ -17,10 +18,12 @@ async function bookFirstFreeUserEventThroughEmbed({
|
||||||
addEmbedListeners,
|
addEmbedListeners,
|
||||||
page,
|
page,
|
||||||
getActionFiredDetails,
|
getActionFiredDetails,
|
||||||
|
bookerVariant,
|
||||||
}: {
|
}: {
|
||||||
addEmbedListeners: Fixtures["addEmbedListeners"];
|
addEmbedListeners: Fixtures["addEmbedListeners"];
|
||||||
page: Page;
|
page: Page;
|
||||||
getActionFiredDetails: Fixtures["getActionFiredDetails"];
|
getActionFiredDetails: Fixtures["getActionFiredDetails"];
|
||||||
|
bookerVariant: string;
|
||||||
}) {
|
}) {
|
||||||
const embedButtonLocator = page.locator('[data-cal-link="free"]').first();
|
const embedButtonLocator = page.locator('[data-cal-link="free"]').first();
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
|
@ -40,11 +43,11 @@ async function bookFirstFreeUserEventThroughEmbed({
|
||||||
if (!embedIframe) {
|
if (!embedIframe) {
|
||||||
throw new Error("Embed iframe not found");
|
throw new Error("Embed iframe not found");
|
||||||
}
|
}
|
||||||
const booking = await bookFirstEvent("free", embedIframe, page);
|
const booking = await bookFirstEvent("free", embedIframe, page, bookerVariant);
|
||||||
return booking;
|
return booking;
|
||||||
}
|
}
|
||||||
|
|
||||||
test.describe("Popup Tests", () => {
|
testBothBookers.describe("Popup Tests", (bookerVariant) => {
|
||||||
test.afterEach(async () => {
|
test.afterEach(async () => {
|
||||||
await deleteAllBookingsByEmail("embed-user@example.com");
|
await deleteAllBookingsByEmail("embed-user@example.com");
|
||||||
});
|
});
|
||||||
|
@ -72,7 +75,7 @@ test.describe("Popup Tests", () => {
|
||||||
if (!embedIframe) {
|
if (!embedIframe) {
|
||||||
throw new Error("Embed iframe not found");
|
throw new Error("Embed iframe not found");
|
||||||
}
|
}
|
||||||
const { uid: bookingId } = await bookFirstEvent("free", embedIframe, page);
|
const { uid: bookingId } = await bookFirstEvent("free", embedIframe, page, bookerVariant);
|
||||||
const booking = await getBooking(bookingId);
|
const booking = await getBooking(bookingId);
|
||||||
|
|
||||||
expect(booking.attendees.length).toBe(1);
|
expect(booking.attendees.length).toBe(1);
|
||||||
|
@ -85,6 +88,7 @@ test.describe("Popup Tests", () => {
|
||||||
page,
|
page,
|
||||||
addEmbedListeners,
|
addEmbedListeners,
|
||||||
getActionFiredDetails,
|
getActionFiredDetails,
|
||||||
|
bookerVariant,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -97,7 +101,7 @@ test.describe("Popup Tests", () => {
|
||||||
if (!embedIframe) {
|
if (!embedIframe) {
|
||||||
throw new Error("Embed iframe not found");
|
throw new Error("Embed iframe not found");
|
||||||
}
|
}
|
||||||
await rescheduleEvent("free", embedIframe, page);
|
await rescheduleEvent("free", embedIframe, page, bookerVariant);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,38 @@
|
||||||
import { expect } from "@playwright/test";
|
import { expect } from "@playwright/test";
|
||||||
|
|
||||||
import { test } from "@calcom/web/playwright/lib/fixtures";
|
import { test } from "@calcom/web/playwright/lib/fixtures";
|
||||||
|
import { testBothBookers } from "@calcom/web/playwright/lib/new-booker";
|
||||||
|
|
||||||
import { bookFirstEvent, deleteAllBookingsByEmail, getEmbedIframe, todo } from "../lib/testUtils";
|
import { bookFirstEvent, deleteAllBookingsByEmail, getEmbedIframe, todo } from "../lib/testUtils";
|
||||||
|
|
||||||
test("Inline Iframe - Configured with Dark Theme", async ({
|
testBothBookers.describe("Inline Iframe", (bookerVariant) => {
|
||||||
page,
|
test("Inline Iframe - Configured with Dark Theme", async ({
|
||||||
getActionFiredDetails,
|
page,
|
||||||
addEmbedListeners,
|
getActionFiredDetails,
|
||||||
}) => {
|
addEmbedListeners,
|
||||||
await deleteAllBookingsByEmail("embed-user@example.com");
|
}) => {
|
||||||
await addEmbedListeners("");
|
await deleteAllBookingsByEmail("embed-user@example.com");
|
||||||
await page.goto("/?only=ns:default");
|
await addEmbedListeners("");
|
||||||
const calNamespace = "";
|
await page.goto("/?only=ns:default");
|
||||||
const embedIframe = await getEmbedIframe({ calNamespace, page, pathname: "/pro" });
|
const calNamespace = "";
|
||||||
expect(embedIframe).toBeEmbedCalLink(calNamespace, getActionFiredDetails, {
|
const embedIframe = await getEmbedIframe({ calNamespace, page, pathname: "/pro" });
|
||||||
pathname: "/pro",
|
expect(embedIframe).toBeEmbedCalLink(calNamespace, getActionFiredDetails, {
|
||||||
searchParams: {
|
pathname: "/pro",
|
||||||
theme: "dark",
|
searchParams: {
|
||||||
},
|
theme: "dark",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// expect(await page.screenshot()).toMatchSnapshot("event-types-list.png");
|
||||||
|
if (!embedIframe) {
|
||||||
|
throw new Error("Embed iframe not found");
|
||||||
|
}
|
||||||
|
await bookFirstEvent("pro", embedIframe, page, bookerVariant);
|
||||||
|
await deleteAllBookingsByEmail("embed-user@example.com");
|
||||||
});
|
});
|
||||||
// expect(await page.screenshot()).toMatchSnapshot("event-types-list.png");
|
|
||||||
if (!embedIframe) {
|
todo(
|
||||||
throw new Error("Embed iframe not found");
|
"Ensure that on all pages - [user], [user]/[type], team/[slug], team/[slug]/book, UI styling works if these pages are directly linked in embed"
|
||||||
}
|
);
|
||||||
await bookFirstEvent("pro", embedIframe, page);
|
|
||||||
await deleteAllBookingsByEmail("embed-user@example.com");
|
todo("Check that UI Configuration doesn't work for Free Plan");
|
||||||
});
|
});
|
||||||
|
|
||||||
todo(
|
|
||||||
"Ensure that on all pages - [user], [user]/[type], team/[slug], team/[slug]/book, UI styling works if these pages are directly linked in embed"
|
|
||||||
);
|
|
||||||
|
|
||||||
todo("Check that UI Configuration doesn't work for Free Plan");
|
|
||||||
|
|
|
@ -1,25 +1,28 @@
|
||||||
import { expect } from "@playwright/test";
|
import { expect } from "@playwright/test";
|
||||||
|
|
||||||
import { test } from "@calcom/web/playwright/lib/fixtures";
|
import { test } from "@calcom/web/playwright/lib/fixtures";
|
||||||
|
import { testBothBookers } from "@calcom/web/playwright/lib/new-booker";
|
||||||
|
|
||||||
test("Preview - embed-core should load", async ({ page }) => {
|
testBothBookers.describe("Preview", () => {
|
||||||
await page.goto("http://localhost:3000/embed/preview.html");
|
test("Preview - embed-core should load", async ({ page }) => {
|
||||||
const libraryLoaded = await page.evaluate(() => {
|
await page.goto("http://localhost:3000/embed/preview.html");
|
||||||
return new Promise((resolve) => {
|
const libraryLoaded = await page.evaluate(() => {
|
||||||
setInterval(() => {
|
return new Promise((resolve) => {
|
||||||
if (
|
setInterval(() => {
|
||||||
(
|
if (
|
||||||
window as unknown as {
|
(
|
||||||
Cal: {
|
window as unknown as {
|
||||||
__css: string;
|
Cal: {
|
||||||
};
|
__css: string;
|
||||||
}
|
};
|
||||||
).Cal.__css
|
}
|
||||||
) {
|
).Cal.__css
|
||||||
resolve(true);
|
) {
|
||||||
}
|
resolve(true);
|
||||||
}, 1000);
|
}
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
expect(libraryLoaded).toBe(true);
|
||||||
});
|
});
|
||||||
expect(libraryLoaded).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,8 +2,9 @@ import { expect } from "@playwright/test";
|
||||||
|
|
||||||
import { getEmbedIframe } from "@calcom/embed-core/playwright/lib/testUtils";
|
import { getEmbedIframe } from "@calcom/embed-core/playwright/lib/testUtils";
|
||||||
import { test } from "@calcom/web/playwright/lib/fixtures";
|
import { test } from "@calcom/web/playwright/lib/fixtures";
|
||||||
|
import { testBothBookers } from "@calcom/web/playwright/lib/new-booker";
|
||||||
|
|
||||||
test.describe("Inline Embed", () => {
|
testBothBookers.describe("Inline Embed", () => {
|
||||||
test("should verify that the iframe got created with correct URL", async ({
|
test("should verify that the iframe got created with correct URL", async ({
|
||||||
page,
|
page,
|
||||||
getActionFiredDetails,
|
getActionFiredDetails,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user