Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Flaky organization.spec.ts test for i.cal.com (#20421)

Hariom Balhara96fcf7beece4
diff --git a/__checks__/organization.spec.ts b/__checks__/organization.spec.ts
index 65255cffdcd..95af227fe00 100644
--- a/__checks__/organization.spec.ts
+++ b/__checks__/organization.spec.ts
@@ -1,4 +1,3 @@
-import type { Page } from "@playwright/test";
import { test, expect } from "@playwright/test";
test.describe("Org", () => {
@@ -8,14 +7,16 @@ test.describe("Org", () => {
const response = await page.goto("https://i.cal.com/embed");
expect(response?.status()).toBe(200);
await page.screenshot({ path: "screenshot.jpg" });
- await expectPageToBeRenderedWithEmbedSsr(page);
+ const body = await response?.text();
+ await expectPageToBeRenderedWithEmbedSsr(body);
});
test("Org User(Rick) Page should be embeddable", async ({ page }) => {
const response = await page.goto("https://i.cal.com/team-rick/embed");
expect(response?.status()).toBe(200);
await expect(page.locator("text=Used by Checkly")).toBeVisible();
- await expectPageToBeRenderedWithEmbedSsr(page);
+ const body = await response?.text();
+ await expectPageToBeRenderedWithEmbedSsr(body);
});
test("Org User Event(/team-rick/test-event) Page should be embeddable", async ({ page }) => {
@@ -23,14 +24,16 @@ test.describe("Org", () => {
expect(response?.status()).toBe(200);
await expect(page.locator('[data-testid="decrementMonth"]')).toBeVisible();
await expect(page.locator('[data-testid="incrementMonth"]')).toBeVisible();
- await expectPageToBeRenderedWithEmbedSsr(page);
+ const body = await response?.text();
+ await expectPageToBeRenderedWithEmbedSsr(body);
});
test("Org Team Profile(/sales) page should be embeddable", async ({ page }) => {
const response = await page.goto("https://i.cal.com/sales/embed");
expect(response?.status()).toBe(200);
await expect(page.locator("text=Cal.com Sales")).toBeVisible();
- await expectPageToBeRenderedWithEmbedSsr(page);
+ const body = await response?.text();
+ await expectPageToBeRenderedWithEmbedSsr(body);
});
test("Org Team Event page(/sales/hippa) should be embeddable", async ({ page }) => {
@@ -38,7 +41,8 @@ test.describe("Org", () => {
expect(response?.status()).toBe(200);
await expect(page.locator('[data-testid="decrementMonth"]')).toBeVisible();
await expect(page.locator('[data-testid="incrementMonth"]')).toBeVisible();
- await expectPageToBeRenderedWithEmbedSsr(page);
+ const body = await response?.text();
+ await expectPageToBeRenderedWithEmbedSsr(body);
});
});
@@ -68,7 +72,8 @@ test.describe("Org", () => {
test("Organization Homepage - Has Engineering and Marketing Teams", async ({ page }) => {
const response = await page.goto("https://i.cal.com");
expect(response?.status()).toBe(200);
- await expect(page.locator("text=Cal.com")).toBeVisible();
+ // Somehow there are two Cal.com text momentarily, but shouldn't be the concern of this check
+ await expect(page.locator("text=Cal.com").first()).toBeVisible();
await expect(page.locator("text=Engineering")).toBeVisible();
await expect(page.locator("text=Marketing")).toBeVisible();
});
@@ -95,11 +100,6 @@ test.describe("Org", () => {
});
// This ensures that the route is actually mapped to a page that is using withEmbedSsr
-async function expectPageToBeRenderedWithEmbedSsr(page: Page) {
- expect(
- await page.evaluate(() => {
- //@ts-expect-error - __NEXT_DATA__ is a global variable defined by Next.js
- return window.__NEXT_DATA__.props.pageProps.isEmbed;
- })
- ).toBe(true);
+async function expectPageToBeRenderedWithEmbedSsr(responseText: string | undefined) {
+ expect(responseText).toContain('\\"isEmbed\\":true');
}