Skip to content

Commit

Permalink
Merge branch 'main' into chore/app-router-team-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj authored Dec 30, 2024
2 parents 43d29cd + 116c765 commit cbae15a
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 161 deletions.
Empty file added .yarn/versions/6e890e70.yml
Empty file.
Empty file added .yarn/versions/d1e07a23.yml
Empty file.
9 changes: 7 additions & 2 deletions apps/web/lib/plain/plainChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ const PlainChat = () => {
const userEmail = session?.user?.email;

const isAppDomain = useMemo(() => {
const restrictedPaths = process.env.NEXT_PUBLIC_PLAIN_CHAT_EXCLUDED_PATHS?.split(",") || [];
const restrictedPathsSet = new Set(
(process.env.NEXT_PUBLIC_PLAIN_CHAT_EXCLUDED_PATHS?.split(",") || []).map((path) => path.trim())
);

const pathSegments = pathname?.split("/").filter(Boolean) || [];

return (
typeof window !== "undefined" &&
window.location.origin === process.env.NEXT_PUBLIC_WEBAPP_URL &&
!restrictedPaths.some((path) => pathname?.startsWith(path.trim()))
!pathSegments.some((segment) => restrictedPathsSet.has(segment))
);
}, [pathname]);

Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@calcom/web",
"version": "4.8.9",
"version": "4.8.11",
"private": true,
"scripts": {
"analyze": "ANALYZE=true next build",
Expand Down
30 changes: 1 addition & 29 deletions apps/web/playwright/lib/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Frame, Locator, Page, Request as PlaywrightRequest } from "@playwright/test";
import type { Frame, Page, Request as PlaywrightRequest } from "@playwright/test";
import { expect } from "@playwright/test";
import { createHash } from "crypto";
import EventEmitter from "events";
Expand Down Expand Up @@ -538,31 +538,3 @@ export async function expectPageToBeNotFound({ page, url }: { page: Page; url: s
await page.goto(`${url}`);
await expect(page.getByTestId(`404-page`)).toBeVisible();
}

export async function clickUntilDialogVisible(
dialogOpenButton: Locator,
visibleLocatorOnDialog: Locator,
page: Page,
matchUrl: string,
retries = 3,
delay = 2000
) {
for (let i = 0; i < retries; i++) {
try {
const responsePromise = page.waitForResponse(
(response) => response.url().includes(matchUrl) && response.status() === 200
);
await dialogOpenButton.click();
await responsePromise;
await visibleLocatorOnDialog.waitFor({ state: "visible", timeout: delay });
return;
} catch {
console.warn(`clickUntilDialogVisible: Attempt ${i + 1} failed to open dialog`);
if (i === retries - 1) {
console.log("clickUntilDialogVisible: Dialog did not appear after multiple attempts.");
return;
}
await new Promise((resolve) => setTimeout(resolve, delay));
}
}
}
153 changes: 73 additions & 80 deletions apps/web/playwright/onboarding.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,93 +1,86 @@
/* eslint-disable playwright/no-skipped-test */
import { expect } from "@playwright/test";

import { IdentityProvider } from "@calcom/prisma/enums";

import { test } from "./lib/fixtures";

test.describe.configure({ mode: "serial" });
test.describe.configure({ mode: "parallel" });

test.afterEach(({ users }) => users.deleteAll());

test.describe("Onboarding", () => {
test.describe("Onboarding v2", () => {
const testOnboarding = (identityProvider: IdentityProvider) => {
test(`Onboarding Flow - ${identityProvider} user`, async ({ page, users }) => {
const user = await users.create({
completedOnboarding: false,
name: null,
identityProvider,
});
await user.apiLogin();
await page.goto("/getting-started");
// tests whether the user makes it to /getting-started
// after login with completedOnboarding false
await page.waitForURL("/getting-started");

await test.step("step 1 - User Settings", async () => {
// Check required fields
await page.locator("button[type=submit]").click();
await expect(page.locator("data-testid=required")).toBeVisible();

// happy path
await page.locator("input[name=username]").fill("new user onboarding");
await page.locator("input[name=name]").fill("new user 2");
await page.locator("input[role=combobox]").click();
await page
.locator("*")
.filter({ hasText: /^Europe\/London/ })
.first()
.click();
await page.locator("button[type=submit]").click();

await expect(page).toHaveURL(/.*connected-calendar/);

const userComplete = await user.self();
expect(userComplete.name).toBe("new user 2");
});

await test.step("step 2 - Connected Calendar", async () => {
const isDisabled = await page.locator("button[data-testid=save-calendar-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();

await expect(page).toHaveURL(/.*connected-video/);
});

await test.step("step 3 - Connected Video", async () => {
const isDisabled = await page.locator("button[data-testid=save-video-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();

await expect(page).toHaveURL(/.*setup-availability/);
});

await test.step("step 4 - Setup Availability", async () => {
const isDisabled = await page.locator("button[data-testid=save-availability]").isDisabled();
await expect(isDisabled).toBe(false);
// same here, skip this step.
await page.locator("button[data-testid=save-availability]").click();

await expect(page).toHaveURL(/.*user-profile/);
});

await test.step("step 5- User Profile", async () => {
await page.locator("button[type=submit]").click();

// should redirect to /event-types after onboarding
await page.waitForURL("/event-types");

const userComplete = await user.self();

expect(userComplete.bio?.replace("<p><br></p>", "").length).toBe(0);
});
const testOnboarding = (identityProvider: IdentityProvider) => {
test(`Onboarding Flow - ${identityProvider} user`, async ({ page, users }) => {
const user = await users.create({
completedOnboarding: false,
name: null,
identityProvider,
});
};
await user.apiLogin();
await page.goto("/getting-started");
// tests whether the user makes it to /getting-started
// after login with completedOnboarding false
await page.waitForURL("/getting-started");

await test.step("step 1 - User Settings", async () => {
// Check required fields
await page.locator("button[type=submit]").click();
await expect(page.locator("data-testid=required")).toBeVisible();

// happy path
await page.locator("input[name=username]").fill("new user onboarding");
await page.locator("input[name=name]").fill("new user 2");
await page.locator("input[role=combobox]").click();
await page
.locator("*")
.filter({ hasText: /^Europe\/London/ })
.first()
.click();
await page.locator("button[type=submit]").click();

await expect(page).toHaveURL(/.*connected-calendar/);

const userComplete = await user.self();
expect(userComplete.name).toBe("new user 2");
});

await test.step("step 2 - Connected Calendar", async () => {
const isDisabled = await page.locator("button[data-testid=save-calendar-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();
await expect(page).toHaveURL(/.*connected-video/);
});

await test.step("step 3 - Connected Video", async () => {
const isDisabled = await page.locator("button[data-testid=save-video-button]").isDisabled();
await expect(isDisabled).toBe(true);
// tests skip button, we don't want to test entire flow.
await page.locator("button[data-testid=skip-step]").click();
await expect(page).toHaveURL(/.*setup-availability/);
});

await test.step("step 4 - Setup Availability", async () => {
const isDisabled = await page.locator("button[data-testid=save-availability]").isDisabled();
await expect(isDisabled).toBe(false);
// same here, skip this step.

await page.locator("button[data-testid=save-availability]").click();
await expect(page).toHaveURL(/.*user-profile/);
});

await test.step("step 5- User Profile", async () => {
await page.locator("button[type=submit]").click();
// should redirect to /event-types after onboarding
await page.waitForURL("/event-types");

const userComplete = await user.self();
expect(userComplete.bio?.replace("<p><br></p>", "").length).toBe(0);
});
});
};

testOnboarding(IdentityProvider.GOOGLE);
testOnboarding(IdentityProvider.CAL);
testOnboarding(IdentityProvider.SAML);
});
testOnboarding(IdentityProvider.GOOGLE);
testOnboarding(IdentityProvider.CAL);
testOnboarding(IdentityProvider.SAML);
});
Loading

0 comments on commit cbae15a

Please sign in to comment.