Add embed tests in CI (#2887)

* Add embed tests in CI

* Update e2e-embed.yml

* Run quick tests only

* Ignore certain folders

* Add embed-react tests as well

* Fix commands

* Dont run unit tests

* Update playwright.config.ts

* Update playwright.config.ts

* Update playwright.config.ts

* Create correct artifcats

* Create correct artifcats

* Fi ignore path

* Update package.json

* Add back embed-react typecheck

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Hariom Balharaandkodiakhq[bot] authored and GitHub committed 2022-05-30 22:41:05 +05:30
1 parent f7cec8d71f
commit 3035412cdc
13 files changed
+205 -43

No files matched your search

+5 -2
View File
@@ -1,12 +1,14 @@
{
"name": "@calcom/embed-core",
"version": "1.1.0-beta.10",
"version": "1.1.0",
"description": "This is the vanilla JS core script that embeds Cal Link",
"main": "./dist/embed/embed.js",
"types": "./dist/index.d.ts",
"scripts": {
"embed-dev": "yarn workspace @calcom/embed-core dev",
"embed-web-start": "yarn workspace @calcom/web start",
"__build": "yarn tailwind && vite build && yarn tsc --emitDeclarationOnly --declarationDir dist && cp -r ../../../apps/web/public/embed ./dist/",
"__dev": "yarn __build --mode development",
"__dev": "yarn tailwind && vite build --mode development",
"build": "NEXT_PUBLIC_EMBED_FINGER_PRINT=$(git rev-parse --short HEAD) yarn __build",
"build-preview": "PREVIEW_BUILD=1 yarn __build ",
"vite": "vite",
@@ -18,6 +20,7 @@
"lint": "eslint --ext .ts,.js src",
"embed-tests": "yarn playwright test --config=playwright/config/playwright.config.ts",
"embed-tests-quick": "QUICK=true yarn embed-tests",
"embed-tests-update-snapshots:ci": "yarn embed-tests-quick --update-snapshots",
"prepare": "NEXT_PUBLIC_WEBAPP_URL='https://app.cal.com' yarn build"
},
"files": [
@@ -1,6 +1,8 @@
import { PlaywrightTestConfig, Frame, devices, expect } from "@playwright/test";
import * as path from "path";
require("dotenv").config({ path: "../../../../../.env" });
const outputDir = path.join("../results");
const testDir = path.join("../tests");
const quickMode = process.env.QUICK === "true";
@@ -27,8 +29,8 @@ const config: PlaywrightTestConfig = {
},
},
webServer: {
// Start App Server manually - Can't be handled here. See https://github.com/microsoft/playwright/issues/8206
command: "yarn workspace @calcom/embed-core dev",
// Run servers in parallel as Playwright doesn't support two different webserver commands at the moment See https://github.com/microsoft/playwright/issues/8206
command: "yarn run-p 'embed-dev' 'embed-web-start'",
port: 3100,
timeout: 60_000,
reuseExistingServer: !process.env.CI,
@@ -34,7 +34,18 @@ export const getBooking = async (bookingId: string) => {
export const getEmbedIframe = async ({ page, pathname }: { page: Page; pathname: string }) => {
// FIXME: Need to wait for the iframe to be properly added to shadow dom. There should be a no time boundation way to do it.
await new Promise((resolve) => {
setTimeout(resolve, 2000);
// Keep checking
const interval = setInterval(() => {
if (page.frame("cal-embed")) {
resolve(true);
}
}, 1000);
// Hard Timer
setTimeout(() => {
clearInterval(interval);
resolve(true);
}, 10000);
});
const embedIframe = page.frame("cal-embed");
if (!embedIframe) {
+8 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@calcom/embed-react",
"version": "1.0.6-beta.10",
"version": "1.0.6",
"description": "Embed Cal Link as a React Component",
"scripts": {
"dev": "vite --port=3101 --open",
@@ -8,11 +8,15 @@
"build": "vite build && yarn tsc --emitDeclarationOnly --declarationDir dist",
"preview": "vite preview",
"prepare": "NEXT_PUBLIC_EMBED_LIB_URL='https://app.cal.com/embed/embed.js' NEXT_PUBLIC_WEBAPP_URL='https://app.cal.com' yarn build",
"type-check": "tsc --pretty --noEmit",
"lint": "eslint --ext .ts,.js,.tsx,.jsx ./src",
"embed-tests": "yarn playwright test --config=./playwright/config/playwright.config.ts",
"embed-tests-quick": "QUICK=true yarn embed-tests",
"publish-prod": "npm version patch && npm publish --access public",
"publish-beta": "npm version prepatch && npm publish --access public --tag beta"
"publish-beta": "npm version prepatch && npm publish --access public --tag beta",
"embed-tests-update-snapshots:ci": "yarn embed-tests-quick --update-snapshots",
"embed-web-start": "yarn workspace @calcom/web start",
"embed-dev": "yarn workspace @calcom/embed-react dev"
},
"main": "./dist/Cal.umd.js",
"module": "./dist/Cal.es.js",
@@ -40,7 +44,7 @@
"typescript": "^4.6.4"
},
"dependencies": {
"@calcom/embed-snippet": "1.0.1-beta.10",
"@calcom/embed-core": "1.1.0-beta.10"
"@calcom/embed-snippet": "1.0.1",
"@calcom/embed-core": "1.1.0"
}
}
@@ -19,11 +19,10 @@ const projects = baseConfig.projects?.map((project) => {
const config: PlaywrightTestConfig = {
...baseConfig,
webServer: {
// Start App Server manually - Can't be handled here. See https://github.com/microsoft/playwright/issues/8206
command: "yarn workspace @calcom/embed-react dev",
port: 3101,
command: "yarn run-p 'embed-dev' 'embed-web-start'",
port: 3000,
timeout: 60_000,
reuseExistingServer: true,
reuseExistingServer: !process.env.CI,
},
use: {
...baseConfig.use,
+1 -1
View File
@@ -10,6 +10,6 @@
"@lib/*": ["../../../apps/web/lib/*"]
}
},
"include": ["src","env.d.ts"],
"include": ["src", "env.d.ts"],
"exclude": ["dist", "build", "node_modules", "test-cal.tsx"]
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@calcom/embed-snippet",
"version": "1.0.1-beta.10",
"version": "1.0.1",
"main": "./dist/snippet.umd.js",
"module": "./dist/snippet.es.js",
"description": "Vanilla JS embed snippet that is responsible to fetch @calcom/embed-core and thus show Cal Link as an embed on a page.",
@@ -8,7 +8,7 @@
"build": "vite build && yarn tsc --emitDeclarationOnly --declarationDir dist",
"type-check": "tsc --pretty --noEmit",
"lint": "eslint --ext .ts,.js src",
"prepare":"NEXT_PUBLIC_EMBED_LIB_URL='https://app.cal.com/embed/embed.js' NEXT_PUBLIC_WEBAPP_URL='https://app.cal.com' yarn build"
"prepare": "NEXT_PUBLIC_EMBED_LIB_URL='https://app.cal.com/embed/embed.js' NEXT_PUBLIC_WEBAPP_URL='https://app.cal.com' yarn build"
},
"files": [
"dist"
@@ -18,6 +18,6 @@
"eslint": "^8.15.0"
},
"dependencies": {
"@calcom/embed-core": "^1.1.0-beta.10"
"@calcom/embed-core": "^1.1.0"
}
}