Skip to content

Commit 9e3465e

Browse files
fix: Support embedding org profile page (#12116)
* support embedding org profile page * Add checkly tests * Fix test titles --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
1 parent 31fc472 commit 9e3465e

File tree

7 files changed

+1010
-56
lines changed

7 files changed

+1010
-56
lines changed

__checks__/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Checkly Tests
2+
3+
Run as `yarn checkly test`
4+
Deploy the tests as `yarn checkly deploy`

__checks__/organization.spec.ts

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { Page } from "@playwright/test";
2+
import { test, expect } from "@playwright/test";
3+
4+
test.describe("Org", () => {
5+
// Because these pages involve next.config.js rewrites, it's better to test them on production
6+
test.describe("Embeds - i.cal.com", () => {
7+
test("Org Profile Page should be embeddable", async ({ page }) => {
8+
const response = await page.goto("https://i.cal.com/embed");
9+
expect(response?.status()).toBe(200);
10+
await page.screenshot({ path: "screenshot.jpg" });
11+
await expectPageToBeServerSideRendered(page);
12+
});
13+
14+
test("Org User(Peer) Page should be embeddable", async ({ page }) => {
15+
const response = await page.goto("https://i.cal.com/peer/embed");
16+
expect(response?.status()).toBe(200);
17+
await expect(page.locator("text=Peer Richelsen")).toBeVisible();
18+
await expectPageToBeServerSideRendered(page);
19+
});
20+
21+
test("Org User Event(peer/meet) Page should be embeddable", async ({ page }) => {
22+
const response = await page.goto("https://i.cal.com/peer/meet/embed");
23+
expect(response?.status()).toBe(200);
24+
await expect(page.locator('[data-testid="decrementMonth"]')).toBeVisible();
25+
await expect(page.locator('[data-testid="incrementMonth"]')).toBeVisible();
26+
await expectPageToBeServerSideRendered(page);
27+
});
28+
29+
test("Org Team Profile(/sales) page should be embeddable", async ({ page }) => {
30+
const response = await page.goto("https://i.cal.com/sales/embed");
31+
expect(response?.status()).toBe(200);
32+
await expect(page.locator("text=Cal.com Sales")).toBeVisible();
33+
await expectPageToBeServerSideRendered(page);
34+
});
35+
36+
test("Org Team Event page(/sales/hippa) should be embeddable", async ({ page }) => {
37+
const response = await page.goto("https://i.cal.com/sales/hipaa/embed");
38+
expect(response?.status()).toBe(200);
39+
await expect(page.locator('[data-testid="decrementMonth"]')).toBeVisible();
40+
await expect(page.locator('[data-testid="incrementMonth"]')).toBeVisible();
41+
await expectPageToBeServerSideRendered(page);
42+
});
43+
});
44+
});
45+
46+
// This ensures that the route is actually mapped to a page that is using withEmbedSsr
47+
async function expectPageToBeServerSideRendered(page: Page) {
48+
expect(
49+
await page.evaluate(() => {
50+
return window.__NEXT_DATA__.props.pageProps.isEmbed;
51+
})
52+
).toBe(true);
53+
}

apps/web/next.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ const matcherConfigRootPath = {
102102
source: "/",
103103
};
104104

105+
const matcherConfigRootPathEmbed = {
106+
has: [
107+
{
108+
type: "host",
109+
value: orgHostPath,
110+
},
111+
],
112+
source: "/embed",
113+
};
114+
105115
const matcherConfigUserRoute = {
106116
has: [
107117
{
@@ -245,6 +255,10 @@ const nextConfig = {
245255
...matcherConfigRootPath,
246256
destination: "/team/:orgSlug?isOrgProfile=1",
247257
},
258+
{
259+
...matcherConfigRootPathEmbed,
260+
destination: "/team/:orgSlug/embed?isOrgProfile=1",
261+
},
248262
{
249263
...matcherConfigUserRoute,
250264
destination: "/org/:orgSlug/:user",
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import withEmbedSsr from "@lib/withEmbedSsr";
2+
3+
import { getServerSideProps as _getServerSideProps } from "./index";
4+
5+
export { default } from "./index";
6+
7+
export const getServerSideProps = withEmbedSsr(_getServerSideProps);

checkly.config.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { defineConfig } from "checkly";
2+
3+
/**
4+
* See https://www.checklyhq.com/docs/cli/project-structure/
5+
*/
6+
const config = defineConfig({
7+
/* A human friendly name for your project */
8+
projectName: "calcom-monorepo",
9+
/** A logical ID that needs to be unique across your Checkly account,
10+
* See https://www.checklyhq.com/docs/cli/constructs/ to learn more about logical IDs.
11+
*/
12+
logicalId: "calcom-monorepo",
13+
/* An optional URL to your Git repo */
14+
repoUrl: "https://github.com/checkly/checkly-cli",
15+
/* Sets default values for Checks */
16+
checks: {
17+
/* A default for how often your Check should run in minutes */
18+
frequency: 10,
19+
/* Checkly data centers to run your Checks as monitors */
20+
locations: ["us-east-1", "eu-west-1"],
21+
/* An optional array of tags to organize your Checks */
22+
tags: ["Web"],
23+
/** The Checkly Runtime identifier, determining npm packages and the Node.js version available at runtime.
24+
* See https://www.checklyhq.com/docs/cli/npm-packages/
25+
*/
26+
runtimeId: "2023.02",
27+
/* A glob pattern that matches the Checks inside your repo, see https://www.checklyhq.com/docs/cli/using-check-test-match/ */
28+
checkMatch: "**/__checks__/**/*.check.ts",
29+
browserChecks: {
30+
/* A glob pattern matches any Playwright .spec.ts files and automagically creates a Browser Check. This way, you
31+
* can just write native Playwright code. See https://www.checklyhq.com/docs/cli/using-check-test-match/
32+
* */
33+
testMatch: "**/__checks__/**/*.spec.ts",
34+
},
35+
},
36+
cli: {
37+
/* The default datacenter location to use when running npx checkly test */
38+
runLocation: "eu-west-1",
39+
/* An array of default reporters to use when a reporter is not specified with the "--reporter" flag */
40+
reporters: ["list"],
41+
},
42+
});
43+
44+
export default config;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"@testing-library/jest-dom": "^5.16.5",
8282
"@types/jsonwebtoken": "^9.0.3",
8383
"c8": "^7.13.0",
84+
"checkly": "latest",
8485
"dotenv-checker": "^1.1.5",
8586
"husky": "^8.0.0",
8687
"i18n-unused": "^0.13.0",

0 commit comments

Comments
 (0)