Skip to content

Commit

Permalink
Merge branch 'main' into chore/verify-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj authored Jan 19, 2024
2 parents a7c80dd + 3983351 commit 9fe174c
Show file tree
Hide file tree
Showing 28 changed files with 1,205 additions and 63 deletions.
4 changes: 2 additions & 2 deletions apps/api/pages/api/slots/_get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
const { usernameList, ...rest } = req.query;
let slugs = usernameList;
if (!Array.isArray(usernameList)) {
slugs = usernameList ? [usernameList] : [];
slugs = usernameList ? [usernameList] : undefined;
}
const input = getScheduleSchema.parse({ usernameList: slugs, ...rest });
const timeZoneSupported = input.timeZone ? isSupportedTimeZone(input.timeZone) : false;
Expand All @@ -40,7 +40,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
)
: availableSlots;

return slotsInProvidedTimeZone;
return { slots: slotsInProvidedTimeZone };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (cause) {
if (cause instanceof TRPCError) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pages/api/webhooks/[id]/_patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export async function patchHandler(req: NextApiRequest) {
args.data.userId = bodyUserId;
}

if (args.data.eventTriggers) {
if (eventTriggers) {
const eventTriggersSet = new Set(eventTriggers);
args.data.eventTriggers = Array.from(eventTriggersSet);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pages/api/webhooks/_post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async function postHandler(req: NextApiRequest) {
args.data.userId = bodyUserId;
}

if (args.data.eventTriggers) {
if (eventTriggers) {
const eventTriggersSet = new Set(eventTriggers);
args.data.eventTriggers = Array.from(eventTriggersSet);
}
Expand Down
5 changes: 4 additions & 1 deletion apps/web/components/eventtype/EventLimitsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ const IntervalLimitItem = ({
onIntervalSelect,
}: IntervalLimitItemProps) => {
return (
<div className="mb-4 flex max-h-9 items-center space-x-2 text-sm rtl:space-x-reverse" key={limitKey}>
<div
data-testid="add-limit"
className="mb-4 flex max-h-9 items-center space-x-2 text-sm rtl:space-x-reverse"
key={limitKey}>
<TextField
required
type="number"
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/apps/categories/getServerSideProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { ssrInit } from "@server/lib/ssr";

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const { req, res } = context;
const { req } = context;

const ssr = await ssrInit(context);

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });

let appStore;
if (session?.user?.id) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/apps/getServerSideProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import type { AppCategories } from "@calcom/prisma/enums";
import { ssrInit } from "@server/lib/ssr";

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const { req, res } = context;
const { req } = context;

const ssr = await ssrInit(context);

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });

let appStore, userAdminTeams: UserAdminTeams;
if (session?.user?.id) {
Expand Down
30 changes: 13 additions & 17 deletions apps/web/lib/buildLegacyCtx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,18 @@ export const buildLegacyCtx = (
params: Params,
searchParams: SearchParams
) => {
return new Proxy<Record<string, any>>(
{
query: { ...searchParams, ...params },
params,
req: { headers: buildLegacyHeaders(headers), cookies: buildLegacyCookies(cookies) },
},
{
get(obj, prop) {
if (prop === "res") {
throw new Error(
"You are trying to access the 'res' property of the context, which is not supported in app dir"
);
}

return obj[prop as keyof typeof obj];
return {
query: { ...searchParams, ...params },
params,
req: { headers: buildLegacyHeaders(headers), cookies: buildLegacyCookies(cookies) },
res: new Proxy(Object.create(null), {
// const { req, res } = ctx - valid
// res.anything - throw
get() {
throw new Error(
"You are trying to access the 'res' property of the context, which is not supported in app dir"
);
},
}
) as unknown as GetServerSidePropsContext;
}),
} as unknown as GetServerSidePropsContext;
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import prisma from "@calcom/prisma";
import { ssrInit } from "@server/lib/ssr";

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const { req, res } = context;
const { req } = context;

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });

if (!session?.user?.id) {
return { redirect: { permanent: false, destination: "/auth/login" } };
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/video/[uid]/getServerSideProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ssrInit } from "@server/lib/ssr";
const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true });

export async function getServerSideProps(context: GetServerSidePropsContext) {
const { req, res } = context;
const { req } = context;

const ssr = await ssrInit(context);

Expand Down Expand Up @@ -79,7 +79,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
endTime: booking.endTime.toString(),
});

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });

// set meetingPassword to null for guests
if (session?.user.id !== bookingObj.user?.id) {
Expand Down
1 change: 1 addition & 0 deletions apps/web/pages/api/avatar/[uuid].ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res.writeHead(200, {
"Content-Type": "image/png",
"Content-Length": imageResp.length,
"Cache-Control": "max-age=86400",
});

res.end(imageResp);
Expand Down
3 changes: 2 additions & 1 deletion apps/web/pages/auth/forgot-password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ ForgotPassword.PageWrapper = PageWrapper;
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const { req, res } = context;

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });

// @TODO res will not be available in future pages (app dir)
if (session) {
res.writeHead(302, { Location: "/" });
res.end();
Expand Down
4 changes: 2 additions & 2 deletions apps/web/pages/auth/setup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ Setup.PageWrapper = PageWrapper;
export default Setup;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const { req, res } = context;
const { req } = context;

const ssr = await ssrInit(context);
const userCount = await prisma.user.count();

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });

if (session?.user.role && session?.user.role !== UserPermissionRole.ADMIN) {
return {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ signin.PageWrapper = PageWrapper;
export default signin;

export async function getServerSideProps(context: GetServerSidePropsContext) {
const { req, res } = context;
const { req } = context;

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });
const csrfToken = await getCsrfToken(context);
const providers = await getProviders();
if (session) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/pages/auth/sso/[provider].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
throw new Error(`File is not named sso/[provider]`);
}

const { req, res } = context;
const { req } = context;

const session = await getServerSession({ req, res });
const session = await getServerSession({ req });
const ssr = await ssrInit(context);
const { currentOrgDomain } = orgDomainConfig(context.req);

Expand Down
14 changes: 10 additions & 4 deletions apps/web/pages/booking/[uid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ export default function Success(props: PageProps) {
name="email"
id="email"
defaultValue={email}
className="mr- focus:border-brand-default border-default text-default mt-0 block w-full rounded-none rounded-l-md shadow-sm focus:ring-black sm:text-sm"
className="mr- focus:border-brand-default border-default text-default mt-0 block w-full rounded-none rounded-l-md shadow-sm focus:ring-black sm:text-sm"
placeholder="[email protected]"
/>
<Button
Expand Down Expand Up @@ -893,10 +893,16 @@ export function RecurringBookings({
{eventType.recurringEvent?.count &&
recurringBookingsSorted.slice(4).map((dateStr: string, idx: number) => (
<div key={idx} className={classNames("mb-2", isCancelled ? "line-through" : "")}>
{formatToLocalizedDate(dayjs.tz(date, tz), language, "full", tz)}
{formatToLocalizedDate(dayjs.tz(dateStr, tz), language, "full", tz)}
<br />
{formatToLocalizedTime(date, language, undefined, !is24h, tz)} -{" "}
{formatToLocalizedTime(dayjs(date).add(duration, "m"), language, undefined, !is24h, tz)}{" "}
{formatToLocalizedTime(dayjs(dateStr), language, undefined, !is24h, tz)} -{" "}
{formatToLocalizedTime(
dayjs(dateStr).add(duration, "m"),
language,
undefined,
!is24h,
tz
)}{" "}
<span className="text-bookinglight">
({formatToLocalizedTimezone(dayjs(dateStr), language, tz)})
</span>
Expand Down
53 changes: 44 additions & 9 deletions apps/web/playwright/ab-tests-redirect.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import type { Page } from "@playwright/test";
import { expect } from "@playwright/test";

import { test } from "./lib/fixtures";
import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes";

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

const ensureAppDir = async (page: Page) => {
const dataNextJsRouter = await page.evaluate(() =>
window.document.documentElement.getAttribute("data-nextjs-router")
);

expect(dataNextJsRouter).toEqual("app");
};

testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {
test("should render the /apps/installed/[category]", async ({ page, users, context }) => {
test("should render the /apps/installed/[category]", async ({ page, users }) => {
const user = await users.create();

await user.apiLogin();
Expand All @@ -15,10 +24,14 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {

const locator = page.getByRole("heading", { name: "Messaging" });

if (routeVariant === "future") {
await ensureAppDir(page);
}

await expect(locator).toBeVisible();
});

test("should render the /apps/[slug]", async ({ page, users, context }) => {
test("should render the /apps/[slug]", async ({ page, users }) => {
const user = await users.create();

await user.apiLogin();
Expand All @@ -27,10 +40,14 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {

const locator = page.getByRole("heading", { name: "Telegram" });

if (routeVariant === "future") {
await ensureAppDir(page);
}

await expect(locator).toBeVisible();
});

test("should render the /apps/[slug]/setup", async ({ page, users, context }) => {
test("should render the /apps/[slug]/setup", async ({ page, users }) => {
const user = await users.create();

await user.apiLogin();
Expand All @@ -39,11 +56,14 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {

const locator = page.getByRole("heading", { name: "Connect to Apple Server" });

if (routeVariant === "future") {
await ensureAppDir(page);
}

await expect(locator).toBeVisible();
});

test("should render the /apps/categories", async ({ page, users, context }) => {
test.skip(routeVariant === "future", "Future route not ready yet");
test("should render the /apps/categories", async ({ page, users }) => {
const user = await users.create();

await user.apiLogin();
Expand All @@ -52,10 +72,14 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {

const locator = page.getByTestId("app-store-category-messaging");

if (routeVariant === "future") {
await ensureAppDir(page);
}

await expect(locator).toBeVisible();
});

test("should render the /apps/categories/[category]", async ({ page, users, context }) => {
test("should render the /apps/categories/[category]", async ({ page, users }) => {
const user = await users.create();

await user.apiLogin();
Expand All @@ -64,10 +88,14 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {

const locator = page.getByText(/messaging apps/i);

if (routeVariant === "future") {
await ensureAppDir(page);
}

await expect(locator).toBeVisible();
});

test("should render the /bookings/[status]", async ({ page, users, context }) => {
test("should render the /bookings/[status]", async ({ page, users }) => {
const user = await users.create();

await user.apiLogin();
Expand All @@ -76,11 +104,14 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {

const locator = page.getByTestId("horizontal-tab-upcoming");

if (routeVariant === "future") {
await ensureAppDir(page);
}

await expect(locator).toHaveClass(/bg-emphasis/);
});

test("should render the /getting-started", async ({ page, users, context }) => {
test.skip(routeVariant === "future", "Future route not ready yet");
test("should render the /getting-started", async ({ page, users }) => {
const user = await users.create({ completedOnboarding: false, name: null });

await user.apiLogin();
Expand All @@ -89,6 +120,10 @@ testBothFutureAndLegacyRoutes.describe("apps/ A/B tests", (routeVariant) => {

const locator = page.getByText("Apple Calendar");

if (routeVariant === "future") {
await ensureAppDir(page);
}

await expect(locator).toBeVisible();
});
});
27 changes: 27 additions & 0 deletions apps/web/playwright/eventType/limit-tab.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";

test.describe("Limits Tab - Event Type", () => {
test.beforeEach(async ({ page, users, bookingPage }) => {
await loginUser(users);
await page.goto("/event-types");
await bookingPage.goToEventType("30 min");
await bookingPage.goToTab("event_limit_tab_title");
});

test("Check the functionalities of the Limits Tab", async ({ bookingPage }) => {
await bookingPage.checkLimitBookingFrequency();
await bookingPage.checkLimitBookingDuration();
await bookingPage.checkLimitFutureBookings();
await bookingPage.checkOffsetTimes();
await bookingPage.checkBufferTime();

await bookingPage.updateEventType();
const eventTypePage = await bookingPage.previewEventType();

await eventTypePage.waitForTimeout(10000);

const counter = await eventTypePage.getByTestId("time").count();
await bookingPage.checkTimeSlotsCount(eventTypePage, counter);
});
});
Loading

0 comments on commit 9fe174c

Please sign in to comment.