fix: Snippet path in preview (#14830)

* fix: Snippet path in preview

* Add test
This commit is contained in:
Hariom Balhara
2024-05-02 16:03:57 +00:00
committed by GitHub
parent 52813b01e6
commit 6c8fced247
2 changed files with 18 additions and 2 deletions
@@ -3,7 +3,7 @@ import { expect } from "@playwright/test";
import { test } from "@calcom/web/playwright/lib/fixtures";
test.describe("Preview", () => {
test("Preview - embed-core should load", async ({ page }) => {
test("Preview - embed-core should load if correct embedLibUrl is provided", async ({ page }) => {
await page.goto(
"http://localhost:3000/embed/preview.html?embedLibUrl=http://localhost:3000/embed/embed.js&bookerUrl=http://localhost:3000&calLink=pro/30min"
);
@@ -26,4 +26,20 @@ test.describe("Preview", () => {
});
expect(libraryLoaded).toBe(true);
});
test("Preview - embed-core should load from embedLibUrl", async ({ page }) => {
// Intentionally pass a URL that will not load to be able to easily test that the embed was loaded from there
page.goto(
"http://localhost:3000/embed/preview.html?embedLibUrl=http://wronglocalhost:3000/embed/embed.js&bookerUrl=http://localhost:3000&calLink=pro/30min"
);
const failedRequestUrl = await new Promise<string>((resolve) =>
page.on("requestfailed", (request) => {
console.log("request failed");
resolve(request.url());
})
);
expect(failedRequestUrl).toBe("http://wronglocalhost:3000/embed/embed.js");
});
});
+1 -1
View File
@@ -47,7 +47,7 @@ if (!bookerUrl || !embedLibUrl) {
}
p(cal, ar);
};
})(window, "//localhost:3000/embed/embed.js", "init");
})(window, embedLibUrl, "init");
const previewWindow = window;
previewWindow.Cal.fingerprint = process.env.EMBED_PUBLIC_EMBED_FINGER_PRINT as string;