Skip to content

Commit

Permalink
Merge branch 'main' into chore/event-type-app-router
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj authored Dec 30, 2024
2 parents 4d083f5 + d8027fe commit ef08a5a
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 82 deletions.
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.10",
"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));
}
}
}
155 changes: 113 additions & 42 deletions apps/web/playwright/out-of-office.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { randomString } from "@calcom/lib/random";
import prisma from "@calcom/prisma";

import { test } from "./lib/fixtures";
import { submitAndWaitForResponse, localize, clickUntilDialogVisible } from "./lib/testUtils";
import { submitAndWaitForResponse, localize } from "./lib/testUtils";

test.describe.configure({ mode: "parallel" });
test.afterEach(async ({ users }) => {
Expand All @@ -20,12 +20,18 @@ test.describe("Out of office", () => {

await user.apiLogin();

const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await page.getByTestId("add_entry_ooo").click();
await reasonListRespPromise;

await page.getByTestId("reason_select").click();

Expand Down Expand Up @@ -71,12 +77,18 @@ test.describe("Out of office", () => {

await user.apiLogin();

await page.goto(`/settings/my-account/out-of-office`);
const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await page.getByTestId("add_entry_ooo").click();
await reasonListRespPromise;

await page.getByTestId("reason_select").click();

Expand Down Expand Up @@ -152,7 +164,12 @@ test.describe("Out of office", () => {

await user.apiLogin();

await page.goto(`/settings/my-account/out-of-office`);
const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

// expect table-redirect-toUserId to be visible
await expect(page.locator(`data-testid=table-redirect-${userTo.username}`)).toBeVisible();
Expand Down Expand Up @@ -211,14 +228,20 @@ test.describe("Out of office", () => {

await user.apiLogin();

const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await page.getByTestId("add_entry_ooo").click();
await reasonListRespPromise;

await dateButton.click();
await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22", true);

Expand Down Expand Up @@ -254,14 +277,20 @@ test.describe("Out of office", () => {

await user.apiLogin();

const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await page.getByTestId("add_entry_ooo").click();
await reasonListRespPromise;

await dateButton.click();
await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22");

Expand All @@ -270,8 +299,11 @@ test.describe("Out of office", () => {
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();

// add another entry
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await entriesListRespPromise;
await page.getByTestId("add_entry_ooo").click();
await reasonListRespPromise;

await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "11", "24");

Expand All @@ -286,14 +318,20 @@ test.describe("Out of office", () => {

await user.apiLogin();

const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await page.getByTestId("add_entry_ooo").click();
await reasonListRespPromise;

await dateButton.click();
await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22");

Expand All @@ -302,8 +340,11 @@ test.describe("Out of office", () => {
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();

// add another entry
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await entriesListRespPromise;
await page.getByTestId("add_entry_ooo").click();
await reasonListRespPromise;

await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22");

Expand All @@ -315,21 +356,31 @@ test.describe("Out of office", () => {
const user = await users.create({ name: "userOne" });
await user.apiLogin();

const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState();
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = await page.getByTestId("add_entry_ooo");
const dateButton = await page.locator('[data-testid="date-range"]');
const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await addOOOButton.click();
await reasonListRespPromise;

//Creates 2 OOO entries:
//First OOO is created on Next month 1st - 3rd
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3");
await expect(page.locator(`data-testid=table-redirect-n-a`).nth(0)).toBeVisible();

//Second OOO is created on Next month 4th - 6th
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await entriesListRespPromise;
await addOOOButton.click();
await reasonListRespPromise;
await dateButton.click();
await selectDateAndCreateOOO(page, "4", "6");
await expect(page.locator(`data-testid=table-redirect-n-a`).nth(1)).toBeVisible();
Expand All @@ -349,14 +400,22 @@ test.describe("Out of office", () => {

await owner.apiLogin();

const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState();
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = await page.getByTestId("add_entry_ooo");
const dateButton = await page.locator('[data-testid="date-range"]');
const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await addOOOButton.click();
await reasonListRespPromise;

//As owner,OOO is created on Next month 1st - 3rd, forwarding to 'member-1'
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3", "member-1");
await expect(
Expand All @@ -366,8 +425,10 @@ test.describe("Out of office", () => {
//As member1, OOO is created on Next month 4th - 5th, forwarding to 'owner'
await member1User?.apiLogin();
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState();
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;
await addOOOButton.click();
await reasonListRespPromise;
await dateButton.click();
await selectDateAndCreateOOO(page, "4", "5", "owner");
await expect(page.locator(`data-testid=table-redirect-${owner.username ?? "n-a"}`).nth(0)).toBeVisible();
Expand All @@ -388,14 +449,22 @@ test.describe("Out of office", () => {

await owner.apiLogin();

const entriesListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeEntriesList") && response.status() === 200
);
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState();
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;

const addOOOButton = await page.getByTestId("add_entry_ooo");
const dateButton = await page.locator('[data-testid="date-range"]');
const addOOOButton = page.getByTestId("add_entry_ooo");
const dateButton = page.locator('[data-testid="date-range"]');
const reasonListRespPromise = page.waitForResponse(
(response) => response.url().includes("outOfOfficeReasonList?batch=1") && response.status() === 200
);
await addOOOButton.click();
await reasonListRespPromise;

//As owner,OOO is created on Next month 1st - 3rd, forwarding to 'member-1'
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3", "member-1");
await expect(
Expand All @@ -405,8 +474,10 @@ test.describe("Out of office", () => {
//As member1, expect error while OOO is created on Next month 2nd - 5th, forwarding to 'owner'
await member1User?.apiLogin();
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState();
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await page.waitForLoadState("domcontentloaded");
await entriesListRespPromise;
await addOOOButton.click();
await reasonListRespPromise;
await dateButton.click();
await selectDateAndCreateOOO(page, "2", "5", "owner", 400);
await expect(page.locator(`text=${t("booking_redirect_infinite_not_allowed")}`)).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function HowToUse() {
<div className="bg-default m-auto rounded p-10">
<div className="flex flex-row">
<div className="mr-5">
<img className="w-11" src="/api/app-store/typeform/icon.svg" alt="Zapier Logo" />
<img className="w-11" src="/api/app-store/typeform/icon.svg" alt="Typeform Logo" />
</div>
<div className="ml-5">
<div className="text-md text-default">How to route a Typeform with Cal.com Routing</div>
Expand Down
3 changes: 3 additions & 0 deletions packages/app-store/typeform/static/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ async function getTeamMembers({
},
cursor: cursor ? { id: cursor } : undefined,
take: limit + 1, // We take +1 as itll be used for the next cursor
orderBy: {
id: "asc",
},
orderBy: [{ userId: "asc" }, { id: "asc" }], // Prisma require a unique field for tie breaking duplicate value for pagination
distinct: ["userId"],
});

Expand Down
Loading

0 comments on commit ef08a5a

Please sign in to comment.