Skip to content

Scheduling infrastructure for absolutely everyone.

test: Make embed tests stable. (#9718)

Hariom Balhara4f0e843ac619
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 7bba9c794cb..ebd48c7b7fe 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -34,12 +34,15 @@ jobs:
app-store:
- 'apps/web/**'
- 'packages/app-store/**'
+ - 'playwright.config.ts'
embed:
- 'apps/web/**'
- 'packages/embeds/**'
+ - 'playwright.config.ts'
embed-react:
- 'apps/web/**'
- 'packages/embeds/**'
+ - 'playwright.config.ts'
env:
name: Create env file
diff --git a/packages/embeds/README.md b/packages/embeds/README.md
index fd486535d3e..b02831d7438 100644
--- a/packages/embeds/README.md
+++ b/packages/embeds/README.md
@@ -7,7 +7,7 @@ This folder contains all the various flavours of embeds.
Please see the respective folder READMEs for details on them.
-## Publishing to NPM - Soon to be automated using changesets github action
+## Publishing to NPM. It will soon be automated using changesets github action
To publish the packages. Following steps should be followed. All commands are to be run at the root.
1. `yarn changeset` -> Creates changelog files and adds summary to changelog. Select embed packages only here.
diff --git a/playwright.config.ts b/playwright.config.ts
index 7b45b1f672a..db570d1f465 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -34,6 +34,8 @@ const webServer: PlaywrightTestConfig["webServer"] = [
];
if (IS_EMBED_TEST) {
+ ensureAppServerIsReadyToServeEmbed(webServer[0]);
+
webServer.push({
command: "yarn workspace @calcom/embed-core dev",
port: 3100,
@@ -43,6 +45,8 @@ if (IS_EMBED_TEST) {
}
if (IS_EMBED_REACT_TEST) {
+ ensureAppServerIsReadyToServeEmbed(webServer[0]);
+
webServer.push({
command: "yarn workspace @calcom/embed-react dev",
port: 3101,
@@ -261,3 +265,11 @@ expect.extend({
});
export default config;
+
+function ensureAppServerIsReadyToServeEmbed(webServer: { port?: number; url?: string }) {
+ // We should't depend on an embed dependency for App's tests. So, conditionally modify App webServer.
+ // Only one of port or url can be specified, so remove port.
+ delete webServer.port;
+ webServer.url = `${process.env.NEXT_PUBLIC_WEBAPP_URL}/embed/embed.js`;
+ console.log("Ensuring that /embed/embed.js is 200 before starting tests");
+}