fix: fix-e2e-tests (#13330)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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" } };
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
import { test } from "./lib/fixtures";
|
||||
@@ -5,8 +6,16 @@ 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();
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user