Fix booker top margin embed (#10357)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2023-07-25 10:58:47 +01:00
1 parent 10bd332405
commit 47739a7636
6 files changed
+53 -26

No files matched your search

@@ -6,17 +6,20 @@ test.describe("Embed Pages", () => {
test("Event Type Page: should not have margin top on embed page", async ({ page }) => {
await page.goto("http://localhost:3000/free/30min/embed");
// Checks the margin from top by checking the distance between the div inside main from the viewport
const marginFromTop = await page.evaluate(() => {
const mainElement = document.querySelector("main");
const divElement = mainElement?.querySelector("div");
const marginFromTop = await page.evaluate(async () => {
return await new Promise((resolve) => {
(function tryGettingBoundingRect() {
const mainElement = document.querySelector(".main");
if (mainElement && divElement) {
// This returns the distance of the div element from the viewport
const divRect = divElement.getBoundingClientRect();
return divRect.top;
}
return null;
if (mainElement) {
// This returns the distance of the div element from the viewport
const mainElBoundingRect = mainElement.getBoundingClientRect();
resolve(mainElBoundingRect.top);
} else {
setTimeout(tryGettingBoundingRect, 500);
}
})();
});
});
expect(marginFromTop).toBe(0);