Skip to content

Scheduling infrastructure for absolutely everyone.

refactor: remove @calcom/web imports from @calcom/features and add @calcom/testing package (#26480)

Benny Joof5d345b133f4
diff --git a/apps/api/v1/package.json b/apps/api/v1/package.json
index 42de9c995ab..5972bbee324 100644
--- a/apps/api/v1/package.json
+++ b/apps/api/v1/package.json
@@ -18,6 +18,7 @@
"type-check:ci": "tsc-absolute --pretty --noEmit"
},
"devDependencies": {
+ "@calcom/testing": "workspace:*",
"@calcom/tsconfig": "workspace:*",
"@calcom/types": "workspace:*",
"node-mocks-http": "1.16.2",
diff --git a/apps/api/v1/pages/api/slots/_get.test.ts b/apps/api/v1/pages/api/slots/_get.test.ts
index ed5b50b3478..e7ed5bd126b 100644
--- a/apps/api/v1/pages/api/slots/_get.test.ts
+++ b/apps/api/v1/pages/api/slots/_get.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/attendees/_post.test.ts b/apps/api/v1/test/lib/attendees/_post.test.ts
index b0b5773ad00..2467c806384 100644
--- a/apps/api/v1/test/lib/attendees/_post.test.ts
+++ b/apps/api/v1/test/lib/attendees/_post.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/bookings/[id]/_delete.test.ts b/apps/api/v1/test/lib/bookings/[id]/_delete.test.ts
index 53c1239572d..5e66eb52c43 100644
--- a/apps/api/v1/test/lib/bookings/[id]/_delete.test.ts
+++ b/apps/api/v1/test/lib/bookings/[id]/_delete.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/bookings/[id]/_patch.test.ts b/apps/api/v1/test/lib/bookings/[id]/_patch.test.ts
index 1799226e180..11798591395 100644
--- a/apps/api/v1/test/lib/bookings/[id]/_patch.test.ts
+++ b/apps/api/v1/test/lib/bookings/[id]/_patch.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/bookings/[id]/recordings/_get.test.ts b/apps/api/v1/test/lib/bookings/[id]/recordings/_get.test.ts
index 05a2a180706..cf18112f70d 100644
--- a/apps/api/v1/test/lib/bookings/[id]/recordings/_get.test.ts
+++ b/apps/api/v1/test/lib/bookings/[id]/recordings/_get.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/bookings/[id]/transcripts/[recordingId]/_get.test.ts b/apps/api/v1/test/lib/bookings/[id]/transcripts/[recordingId]/_get.test.ts
index 3a9eebba247..7eab2398e56 100644
--- a/apps/api/v1/test/lib/bookings/[id]/transcripts/[recordingId]/_get.test.ts
+++ b/apps/api/v1/test/lib/bookings/[id]/transcripts/[recordingId]/_get.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/bookings/[id]/transcripts/_get.test.ts b/apps/api/v1/test/lib/bookings/[id]/transcripts/_get.test.ts
index b4b8bbc901c..e632b59d9e9 100644
--- a/apps/api/v1/test/lib/bookings/[id]/transcripts/_get.test.ts
+++ b/apps/api/v1/test/lib/bookings/[id]/transcripts/_get.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/bookings/_get.test.ts b/apps/api/v1/test/lib/bookings/_get.test.ts
index f9585cee880..8ffbec59749 100644
--- a/apps/api/v1/test/lib/bookings/_get.test.ts
+++ b/apps/api/v1/test/lib/bookings/_get.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/bookings/_post.test.ts b/apps/api/v1/test/lib/bookings/_post.test.ts
index c415a6cd2c8..4d46a65ac4c 100644
--- a/apps/api/v1/test/lib/bookings/_post.test.ts
+++ b/apps/api/v1/test/lib/bookings/_post.test.ts
@@ -1,5 +1,5 @@
// TODO: Fix tests (These test were never running due to the vitest workspace config)
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/event-types/[id]/_delete.test.ts b/apps/api/v1/test/lib/event-types/[id]/_delete.test.ts
index 2e891b09730..fa0a180c880 100644
--- a/apps/api/v1/test/lib/event-types/[id]/_delete.test.ts
+++ b/apps/api/v1/test/lib/event-types/[id]/_delete.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/event-types/[id]/_get.test.ts b/apps/api/v1/test/lib/event-types/[id]/_get.test.ts
index e1307b97223..2cf49027f3b 100644
--- a/apps/api/v1/test/lib/event-types/[id]/_get.test.ts
+++ b/apps/api/v1/test/lib/event-types/[id]/_get.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/event-types/_post.test.ts b/apps/api/v1/test/lib/event-types/_post.test.ts
index 4b467fe04f6..ca13d5b4b9d 100644
--- a/apps/api/v1/test/lib/event-types/_post.test.ts
+++ b/apps/api/v1/test/lib/event-types/_post.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/test/lib/selected-calendars/_post.test.ts b/apps/api/v1/test/lib/selected-calendars/_post.test.ts
index 45d65084d15..597221baa49 100644
--- a/apps/api/v1/test/lib/selected-calendars/_post.test.ts
+++ b/apps/api/v1/test/lib/selected-calendars/_post.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/apps/api/v1/tsconfig.json b/apps/api/v1/tsconfig.json
index e1f5e1e9435..b787a2b8bfb 100644
--- a/apps/api/v1/tsconfig.json
+++ b/apps/api/v1/tsconfig.json
@@ -6,7 +6,8 @@
"baseUrl": ".",
"paths": {
"~/*": ["*"],
- "@prisma/client/*": ["@calcom/prisma/client/*"]
+ "@prisma/client/*": ["@calcom/prisma/client/*"],
+ "@calcom/testing/*": ["../../../packages/testing/src/*"]
},
"experimentalDecorators": true
},
diff --git a/apps/web/app/(use-page-wrapper)/settings/(admin-layout)/admin/playground/weekly-calendar/page.tsx b/apps/web/app/(use-page-wrapper)/settings/(admin-layout)/admin/playground/weekly-calendar/page.tsx
index 2a2ac730624..8e868da77ea 100644
--- a/apps/web/app/(use-page-wrapper)/settings/(admin-layout)/admin/playground/weekly-calendar/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/settings/(admin-layout)/admin/playground/weekly-calendar/page.tsx
@@ -3,7 +3,7 @@
import { useState } from "react";
import dayjs from "@calcom/dayjs";
-import { Calendar } from "@calcom/features/calendars/weeklyview";
+import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
import type { CalendarEvent } from "@calcom/features/calendars/weeklyview/types/events";
import type { CalendarComponentProps, Hours } from "@calcom/features/calendars/weeklyview/types/state";
diff --git a/apps/web/app/api/auth/oauth/token/__tests__/route.test.ts b/apps/web/app/api/auth/oauth/token/__tests__/route.test.ts
index b7ad93001c6..3edd45fff18 100644
--- a/apps/web/app/api/auth/oauth/token/__tests__/route.test.ts
+++ b/apps/web/app/api/auth/oauth/token/__tests__/route.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import jwt from "jsonwebtoken";
// Import mocked dependencies after mocks are set up
diff --git a/packages/features/auth/signup/handlers/__tests__/calcomHandler.test.ts b/apps/web/app/api/auth/signup/handlers/calcomSignupHandler.test.ts
similarity index 64%
rename from packages/features/auth/signup/handlers/__tests__/calcomHandler.test.ts
rename to apps/web/app/api/auth/signup/handlers/calcomSignupHandler.test.ts
index a8ba3265480..32277a136c9 100644
--- a/packages/features/auth/signup/handlers/__tests__/calcomHandler.test.ts
+++ b/apps/web/app/api/auth/signup/handlers/calcomSignupHandler.test.ts
@@ -1,30 +1,17 @@
import type { Mock } from "vitest";
import { vi } from "vitest";
-import type { MockResponse } from "./mocks/next.mocks";
+import type { MockResponse } from "@calcom/features/auth/signup/handlers/__tests__/mocks/next.mocks";
-// Hoisted imports for proper mock initialization
-const {
+import {
prismaMock,
resetPrismaMock,
- createPrismaMock,
-} = (await vi.hoisted(
- async () => await import("./mocks/prisma.mocks")
-)) as Awaited<typeof import("./mocks/prisma.mocks")>;
-
-const {
- createNextServerMock,
- createNextHeadersMock,
-} = (await vi.hoisted(
- async () => await import("./mocks/next.mocks")
-)) as Awaited<typeof import("./mocks/next.mocks")>;
-
-const {
+} from "@calcom/features/auth/signup/handlers/__tests__/mocks/prisma.mocks";
+import {
createMockTeam,
createMockFoundToken,
-} = (await vi.hoisted(
- async () => await import("./mocks/signup.factories")
-)) as Awaited<typeof import("./mocks/signup.factories")>;
+} from "@calcom/features/auth/signup/handlers/__tests__/mocks/signup.factories";
+import type { SignupBody } from "@calcom/features/auth/signup/handlers/__tests__/mocks/signup.factories";
const mockFindTokenByToken: Mock = vi.fn();
const mockValidateAndGetCorrectedUsernameForTeam: Mock = vi.fn();
@@ -37,12 +24,24 @@ type UsernameStatus = {
type InnerHandler = (body: Record<string, string>, status: UsernameStatus) => Promise<MockResponse>;
-let capturedHandler: InnerHandler | null = null;
+var mockCapturedHandler: InnerHandler | null;
-vi.mock("next/server", createNextServerMock);
-vi.mock("next/headers", createNextHeadersMock);
-vi.mock("@calcom/prisma", createPrismaMock);
-vi.mock("@calcom/prisma/client", createPrismaMock);
+vi.mock("next/server", async () => {
+ const { createNextServerMock } = await import("@calcom/features/auth/signup/handlers/__tests__/mocks/next.mocks");
+ return createNextServerMock();
+});
+vi.mock("next/headers", async () => {
+ const { createNextHeadersMock } = await import("@calcom/features/auth/signup/handlers/__tests__/mocks/next.mocks");
+ return createNextHeadersMock();
+});
+vi.mock("@calcom/prisma", async () => {
+ const { createPrismaMock } = await import("@calcom/features/auth/signup/handlers/__tests__/mocks/prisma.mocks");
+ return createPrismaMock();
+});
+vi.mock("@calcom/prisma/client", async () => {
+ const { createPrismaMock } = await import("@calcom/features/auth/signup/handlers/__tests__/mocks/prisma.mocks");
+ return createPrismaMock();
+});
vi.mock("@calcom/lib/logger", () => ({
default: { getSubLogger: () => ({ warn: vi.fn(), error: vi.fn(), debug: vi.fn(), info: vi.fn() }) },
}));
@@ -67,8 +66,8 @@ vi.mock("@calcom/features/watchlist/operations/check-if-email-in-watchlist.contr
checkIfEmailIsBlockedInWatchlistController: vi.fn().mockResolvedValue(false),
}));
vi.mock("@calcom/web/lib/buildLegacyCtx", () => ({ buildLegacyRequest: vi.fn() }));
-vi.mock("../../utils/organization", () => ({ joinAnyChildTeamOnOrgInvite: vi.fn() }));
-vi.mock("../../utils/token", () => ({
+vi.mock("@calcom/features/auth/signup/utils/organization", () => ({ joinAnyChildTeamOnOrgInvite: vi.fn() }));
+vi.mock("@calcom/features/auth/signup/utils/token", () => ({
findTokenByToken: (...args: unknown[]) => mockFindTokenByToken(...args),
throwIfTokenExpired: vi.fn(),
validateAndGetCorrectedUsernameForTeam: (...args: unknown[]) => mockValidateAndGetCorrectedUsernameForTeam(...args),
@@ -77,18 +76,18 @@ vi.mock("../../utils/token", () => ({
// Capture inner handler from usernameHandler wrapper
vi.mock("@calcom/lib/server/username", () => ({
usernameHandler: (handler: InnerHandler) => {
- capturedHandler = handler;
+ mockCapturedHandler = handler;
return handler;
},
}));
// Import after mocks
-await import("../calcomHandler");
-import { runP2002TestSuite } from "./p2002.test-suite";
+import "./calcomSignupHandler";
+import { runP2002TestSuite } from "@calcom/features/auth/signup/handlers/__tests__/p2002.test-suite";
-function callHandler(body: Record<string, string | undefined>): Promise<MockResponse> {
- if (!capturedHandler) throw new Error("Handler not captured");
- return capturedHandler(body as Record<string, string>, {
+function callHandler(body: SignupBody): Promise<MockResponse> {
+ if (!mockCapturedHandler) throw new Error("Handler not captured");
+ return mockCapturedHandler(body as unknown as Record<string, string>, {
statusCode: 200,
requestedUserName: body.username || "testuser",
json: { available: true, premium: false },
diff --git a/packages/features/auth/signup/handlers/calcomHandler.ts b/apps/web/app/api/auth/signup/handlers/calcomSignupHandler.ts
similarity index 97%
rename from packages/features/auth/signup/handlers/calcomHandler.ts
rename to apps/web/app/api/auth/signup/handlers/calcomSignupHandler.ts
index 3d9d1a33a68..7aac999fe38 100644
--- a/packages/features/auth/signup/handlers/calcomHandler.ts
+++ b/apps/web/app/api/auth/signup/handlers/calcomSignupHandler.ts
@@ -24,13 +24,14 @@ import { IdentityProvider } from "@calcom/prisma/enums";
import { signupSchema } from "@calcom/prisma/zod-utils";
import { buildLegacyRequest } from "@calcom/web/lib/buildLegacyCtx";
-import { SIGNUP_ERROR_CODES } from "../constants";
-import { joinAnyChildTeamOnOrgInvite } from "../utils/organization";
+import { joinAnyChildTeamOnOrgInvite } from "@calcom/features/auth/signup/utils/organization";
+import { SIGNUP_ERROR_CODES } from "@calcom/features/auth/signup/constants";
+
import {
findTokenByToken,
throwIfTokenExpired,
validateAndGetCorrectedUsernameForTeam,
-} from "../utils/token";
+} from "@calcom/features/auth/signup/utils/token";
const log = logger.getSubLogger({ prefix: ["signupCalcomHandler"] });
diff --git a/packages/features/auth/signup/handlers/__tests__/selfHostedHandler.test.ts b/apps/web/app/api/auth/signup/handlers/selfHostedHandler.test.ts
similarity index 56%
rename from packages/features/auth/signup/handlers/__tests__/selfHostedHandler.test.ts
rename to apps/web/app/api/auth/signup/handlers/selfHostedHandler.test.ts
index 7fcb740bece..cfd74f3697b 100644
--- a/packages/features/auth/signup/handlers/__tests__/selfHostedHandler.test.ts
+++ b/apps/web/app/api/auth/signup/handlers/selfHostedHandler.test.ts
@@ -1,32 +1,31 @@
import type { Mock } from "vitest";
import { vi } from "vitest";
-// Hoisted imports for proper mock initialization
-const {
+import {
prismaMock,
resetPrismaMock,
- createPrismaMock,
-} = (await vi.hoisted(
- async () => await import("./mocks/prisma.mocks")
-)) as Awaited<typeof import("./mocks/prisma.mocks")>;
-
-const { createNextServerMock } = (await vi.hoisted(
- async () => await import("./mocks/next.mocks")
-)) as Awaited<typeof import("./mocks/next.mocks")>;
-
-const {
+} from "@calcom/features/auth/signup/handlers/__tests__/mocks/prisma.mocks";
+import {
createMockTeam,
createMockFoundToken,
-} = (await vi.hoisted(
- async () => await import("./mocks/signup.factories")
-)) as Awaited<typeof import("./mocks/signup.factories")>;
+} from "@calcom/features/auth/signup/handlers/__tests__/mocks/signup.factories";
+import type { SignupBody } from "@calcom/features/auth/signup/handlers/__tests__/mocks/signup.factories";
const mockFindTokenByToken: Mock = vi.fn();
const mockValidateAndGetCorrectedUsernameForTeam: Mock = vi.fn();
-vi.mock("next/server", createNextServerMock);
-vi.mock("@calcom/prisma", createPrismaMock);
-vi.mock("@calcom/prisma/client", createPrismaMock);
+vi.mock("next/server", async () => {
+ const { createNextServerMock } = await import("@calcom/features/auth/signup/handlers/__tests__/mocks/next.mocks");
+ return createNextServerMock();
+});
+vi.mock("@calcom/prisma", async () => {
+ const { createPrismaMock } = await import("@calcom/features/auth/signup/handlers/__tests__/mocks/prisma.mocks");
+ return createPrismaMock();
+});
+vi.mock("@calcom/prisma/client", async () => {
+ const { createPrismaMock } = await import("@calcom/features/auth/signup/handlers/__tests__/mocks/prisma.mocks");
+ return createPrismaMock();
+});
vi.mock("@calcom/lib/logger", () => ({
default: { getSubLogger: () => ({ warn: vi.fn(), error: vi.fn(), debug: vi.fn(), info: vi.fn() }) },
}));
@@ -39,20 +38,20 @@ vi.mock("@calcom/features/auth/signup/utils/createOrUpdateMemberships", () => ({
vi.mock("@calcom/features/auth/signup/utils/validateUsername", () => ({
validateAndGetCorrectedUsernameAndEmail: vi.fn().mockResolvedValue({ isValid: true, username: "testuser" }),
}));
-vi.mock("../../utils/organization", () => ({ joinAnyChildTeamOnOrgInvite: vi.fn() }));
-vi.mock("../../utils/prefillAvatar", () => ({ prefillAvatar: vi.fn() }));
-vi.mock("../../utils/token", () => ({
+vi.mock("@calcom/features/auth/signup/utils/organization", () => ({ joinAnyChildTeamOnOrgInvite: vi.fn() }));
+vi.mock("@calcom/features/auth/signup/utils/prefillAvatar", () => ({ prefillAvatar: vi.fn() }));
+vi.mock("@calcom/features/auth/signup/utils/token", () => ({
findTokenByToken: (...args: unknown[]) => mockFindTokenByToken(...args),
throwIfTokenExpired: vi.fn(),
validateAndGetCorrectedUsernameForTeam: (...args: unknown[]) => mockValidateAndGetCorrectedUsernameForTeam(...args),
}));
// Import after mocks
-import handler from "../selfHostedHandler";
-import { runP2002TestSuite } from "./p2002.test-suite";
+import handler from "./selfHostedHandler";
+import { runP2002TestSuite } from "@calcom/features/auth/signup/handlers/__tests__/p2002.test-suite";
-function callHandler(body: Record<string, string | undefined>): ReturnType<typeof handler> {
- return handler(body as Record<string, string>);
+function callHandler(body: SignupBody): ReturnType<typeof handler> {
+ return handler(body as unknown as Record<string, string>);
}
runP2002TestSuite("selfHostedHandler", callHandler, () => {
diff --git a/packages/features/auth/signup/handlers/selfHostedHandler.ts b/apps/web/app/api/auth/signup/handlers/selfHostedHandler.ts
similarity index 96%
rename from packages/features/auth/signup/handlers/selfHostedHandler.ts
rename to apps/web/app/api/auth/signup/handlers/selfHostedHandler.ts
index e5252e52cf4..bc238eb3304 100644
--- a/packages/features/auth/signup/handlers/selfHostedHandler.ts
+++ b/apps/web/app/api/auth/signup/handlers/selfHostedHandler.ts
@@ -14,14 +14,14 @@ import prisma from "@calcom/prisma";
import { IdentityProvider } from "@calcom/prisma/enums";
import { signupSchema } from "@calcom/prisma/zod-utils";
-import { SIGNUP_ERROR_CODES } from "../constants";
-import { joinAnyChildTeamOnOrgInvite } from "../utils/organization";
-import { prefillAvatar } from "../utils/prefillAvatar";
+import { joinAnyChildTeamOnOrgInvite } from "@calcom/features/auth/signup/utils/organization";
+import { prefillAvatar } from "@calcom/features/auth/signup/utils/prefillAvatar";
+import { SIGNUP_ERROR_CODES } from "@calcom/features/auth/signup/constants";
import {
findTokenByToken,
throwIfTokenExpired,
validateAndGetCorrectedUsernameForTeam,
-} from "../utils/token";
+} from "@calcom/features/auth/signup/utils/token";
export default async function handler(body: Record<string, string>) {
const { email, password, language, token } = signupSchema.parse(body);
diff --git a/apps/web/app/api/auth/signup/route.ts b/apps/web/app/api/auth/signup/route.ts
index db31e4ab95f..33cbd26b126 100644
--- a/apps/web/app/api/auth/signup/route.ts
+++ b/apps/web/app/api/auth/signup/route.ts
@@ -2,8 +2,8 @@ import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
import { parseRequestData } from "app/api/parseRequestData";
import { NextResponse, type NextRequest } from "next/server";
-import calcomSignupHandler from "@calcom/feature-auth/signup/handlers/calcomHandler";
-import selfHostedSignupHandler from "@calcom/feature-auth/signup/handlers/selfHostedHandler";
+import calcomSignupHandler from "./handlers/calcomSignupHandler";
+import selfHostedSignupHandler from "./handlers/selfHostedHandler";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
import { IS_PREMIUM_USERNAME_ENABLED } from "@calcom/lib/constants";
diff --git a/apps/web/app/api/cron/credentials/__tests__/cron.test.ts b/apps/web/app/api/cron/credentials/__tests__/cron.test.ts
index 2bad734ab80..d8872338783 100644
--- a/apps/web/app/api/cron/credentials/__tests__/cron.test.ts
+++ b/apps/web/app/api/cron/credentials/__tests__/cron.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, it, expect, beforeEach } from "vitest";
diff --git a/apps/web/app/api/cron/selected-calendars/__tests__/cron.test.ts b/apps/web/app/api/cron/selected-calendars/__tests__/cron.test.ts
index 37037d4b1e5..5f1a7941797 100644
--- a/apps/web/app/api/cron/selected-calendars/__tests__/cron.test.ts
+++ b/apps/web/app/api/cron/selected-calendars/__tests__/cron.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import "@calcom/lib/server/__mocks__/serviceAccountKey";
import { describe, it, expect, beforeEach, vi } from "vitest";
diff --git a/apps/web/app/api/routing-forms/queued-response/__tests__/queued-response.test.ts b/apps/web/app/api/routing-forms/queued-response/__tests__/queued-response.test.ts
index ec51b25d242..8434e084788 100644
--- a/apps/web/app/api/routing-forms/queued-response/__tests__/queued-response.test.ts
+++ b/apps/web/app/api/routing-forms/queued-response/__tests__/queued-response.test.ts
@@ -1,4 +1,4 @@
-import "../../../../../../../tests/libs/__mocks__/prisma";
+import "@calcom/testing/lib/__mocks__/prisma";
import { beforeEach, describe, it, expect, vi } from "vitest";
import { onSubmissionOfFormResponse } from "@calcom/app-store/routing-forms/lib/formSubmissionUtils";
diff --git a/apps/web/lib/__tests__/getTeamMemberEmailFromCrm.test.ts b/apps/web/lib/__tests__/getTeamMemberEmailFromCrm.test.ts
index 303f7928a27..62a441cf876 100644
--- a/apps/web/lib/__tests__/getTeamMemberEmailFromCrm.test.ts
+++ b/apps/web/lib/__tests__/getTeamMemberEmailFromCrm.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { v4 } from "uuid";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/apps/web/lib/app-providers-app-dir.tsx b/apps/web/lib/app-providers-app-dir.tsx
index e26329f39ca..239fb54bca9 100644
--- a/apps/web/lib/app-providers-app-dir.tsx
+++ b/apps/web/lib/app-providers-app-dir.tsx
@@ -7,8 +7,8 @@ import type { ReadonlyURLSearchParams } from "next/navigation";
import { usePathname, useSearchParams } from "next/navigation";
import { NuqsAdapter } from "nuqs/adapters/next/app";
-import DynamicPostHogProvider from "@calcom/features/ee/event-tracking/lib/posthog/providerDynamic";
-import DynamicPostHogPageView from "@calcom/features/ee/event-tracking/lib/posthog/web/pageViewDynamic";
+import DynamicPostHogProvider from "~/ee/posthog/providerDynamic";
+import DynamicPostHogPageView from "~/ee/posthog/pageViewDynamic";
import { OrgBrandingProvider } from "@calcom/features/ee/organizations/context/provider";
import { FeatureProvider } from "@calcom/features/flags/context/provider";
import { useFlags } from "@calcom/features/flags/hooks";
diff --git a/apps/web/lib/daily-webhook/tests/recorded-daily-video.test.ts b/apps/web/lib/daily-webhook/tests/recorded-daily-video.test.ts
index 24528075cab..2bdc07a976b 100644
--- a/apps/web/lib/daily-webhook/tests/recorded-daily-video.test.ts
+++ b/apps/web/lib/daily-webhook/tests/recorded-daily-video.test.ts
@@ -6,8 +6,8 @@ import {
getMockBookingAttendee,
getOrganizer,
getBooker,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectWebhookToHaveBeenCalledWith } from "@calcom/web/test/utils/bookingScenario/expects";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectWebhookToHaveBeenCalledWith } from "@calcom/testing/lib/bookingScenario/expects";
import { NextRequest } from "next/server";
import { createMocks } from "node-mocks-http";
diff --git a/apps/web/modules/availability/troubleshoot/troubleshoot-view.tsx b/apps/web/modules/availability/troubleshoot/troubleshoot-view.tsx
index c1207f22620..9ec58a3a249 100644
--- a/apps/web/modules/availability/troubleshoot/troubleshoot-view.tsx
+++ b/apps/web/modules/availability/troubleshoot/troubleshoot-view.tsx
@@ -6,7 +6,7 @@ import { Suspense } from "react";
import { Loader } from "@calcom/ui/components/skeleton";
const TroubleshooterClientOnly = dynamic(
- () => import("@calcom/features/troubleshooter/Troubleshooter").then((mod) => mod.Troubleshooter),
+ () => import("@calcom/web/modules/troubleshooter/components/Troubleshooter").then((mod) => mod.Troubleshooter),
{
ssr: false,
}
diff --git a/apps/web/modules/bookings/components/BookingCalendarView.tsx b/apps/web/modules/bookings/components/BookingCalendarView.tsx
index 1bea45ffcc9..b733bfebb6a 100644
--- a/apps/web/modules/bookings/components/BookingCalendarView.tsx
+++ b/apps/web/modules/bookings/components/BookingCalendarView.tsx
@@ -4,7 +4,7 @@ import { useMemo, useEffect } from "react";
import dayjs from "@calcom/dayjs";
import { useTimePreferences } from "@calcom/features/bookings/lib";
-import { Calendar } from "@calcom/features/calendars/weeklyview";
+import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
import type { CalendarEvent } from "@calcom/features/calendars/weeklyview/types/events";
import { useGetTheme } from "@calcom/lib/hooks/useTheme";
import { useBanners } from "@calcom/web/modules/shell/banners/useBanners";
diff --git a/apps/web/modules/bookings/components/LargeCalendar.tsx b/apps/web/modules/bookings/components/LargeCalendar.tsx
index 9f22ba57176..0e2b07aa080 100644
--- a/apps/web/modules/bookings/components/LargeCalendar.tsx
+++ b/apps/web/modules/bookings/components/LargeCalendar.tsx
@@ -5,7 +5,7 @@ import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerSt
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/components/hooks/useAvailableTimeSlots";
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
import type { BookerEvent } from "@calcom/features/bookings/types";
-import { Calendar } from "@calcom/features/calendars/weeklyview";
+import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
import type { CalendarEvent } from "@calcom/features/calendars/weeklyview/types/events";
import { localStorage } from "@calcom/lib/webstorage";
diff --git a/packages/features/calendar-view/LargeCalendar.tsx b/apps/web/modules/calendar-view/components/LargeCalendar.tsx
similarity index 92%
rename from packages/features/calendar-view/LargeCalendar.tsx
rename to apps/web/modules/calendar-view/components/LargeCalendar.tsx
index 544f38c91c0..664b555cd4e 100644
--- a/packages/features/calendar-view/LargeCalendar.tsx
+++ b/apps/web/modules/calendar-view/components/LargeCalendar.tsx
@@ -4,15 +4,15 @@ import dayjs from "@calcom/dayjs";
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
import type { BookerEvent } from "@calcom/features/bookings/types";
-import { Calendar } from "@calcom/features/calendars/weeklyview";
+import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
import type { CalendarAvailableTimeslots } from "@calcom/features/calendars/weeklyview/types/state";
import { localStorage } from "@calcom/lib/webstorage";
import type { BookingStatus } from "@calcom/prisma/enums";
-import { useBookings } from "../../platform/atoms/hooks/bookings/useBookings";
-import { useCalendarsBusyTimes } from "../../platform/atoms/hooks/useCalendarsBusyTimes";
-import { useConnectedCalendars } from "../../platform/atoms/hooks/useConnectedCalendars";
-import { getQueryParam } from "../bookings/Booker/utils/query-param";
+import { useBookings } from "@calcom/atoms/hooks/bookings/useBookings";
+import { useCalendarsBusyTimes } from "@calcom/atoms/hooks/useCalendarsBusyTimes";
+import { useConnectedCalendars } from "@calcom/atoms/hooks/useConnectedCalendars";
+import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
export const LargeCalendar = ({
extraDays,
diff --git a/packages/features/ee/event-tracking/lib/posthog/web/PostHogPageView.tsx b/apps/web/modules/ee/posthog/PostHogPageView.tsx
similarity index 100%
rename from packages/features/ee/event-tracking/lib/posthog/web/PostHogPageView.tsx
rename to apps/web/modules/ee/posthog/PostHogPageView.tsx
diff --git a/packages/features/ee/event-tracking/lib/posthog/web/pageViewDynamic.tsx b/apps/web/modules/ee/posthog/pageViewDynamic.tsx
similarity index 100%
rename from packages/features/ee/event-tracking/lib/posthog/web/pageViewDynamic.tsx
rename to apps/web/modules/ee/posthog/pageViewDynamic.tsx
diff --git a/packages/features/ee/event-tracking/lib/posthog/provider.tsx b/apps/web/modules/ee/posthog/provider.tsx
similarity index 100%
rename from packages/features/ee/event-tracking/lib/posthog/provider.tsx
rename to apps/web/modules/ee/posthog/provider.tsx
diff --git a/packages/features/ee/event-tracking/lib/posthog/providerDynamic.tsx b/apps/web/modules/ee/posthog/providerDynamic.tsx
similarity index 100%
rename from packages/features/ee/event-tracking/lib/posthog/providerDynamic.tsx
rename to apps/web/modules/ee/posthog/providerDynamic.tsx
diff --git a/apps/web/modules/ee/teams/components/EditMemberSheet.test.tsx b/apps/web/modules/ee/teams/components/EditMemberSheet.test.tsx
index 0a7cbb653e5..dec9e6d05d0 100644
--- a/apps/web/modules/ee/teams/components/EditMemberSheet.test.tsx
+++ b/apps/web/modules/ee/teams/components/EditMemberSheet.test.tsx
@@ -4,7 +4,7 @@ import { vi } from "vitest";
import { MembershipRole } from "@calcom/prisma/enums";
import { EditMemberSheet } from "@calcom/web/modules/ee/teams/components/EditMemberSheet";
-import type { MemberPermissions } from "@calcom/web/modules/users/components/UserTable/types";
+import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
import type { State, User } from "./MemberList";
diff --git a/apps/web/modules/ee/teams/components/EditMemberSheet.tsx b/apps/web/modules/ee/teams/components/EditMemberSheet.tsx
index d8be9d9ffc8..5b6aea0fb53 100644
--- a/apps/web/modules/ee/teams/components/EditMemberSheet.tsx
+++ b/apps/web/modules/ee/teams/components/EditMemberSheet.tsx
@@ -19,7 +19,7 @@ import { Tooltip } from "@calcom/ui/components/tooltip";
import { DisplayInfo } from "@calcom/web/modules/users/components/UserTable/EditSheet/DisplayInfo";
import { SheetFooterControls } from "@calcom/web/modules/users/components/UserTable/EditSheet/SheetFooterControls";
import { useEditMode } from "@calcom/web/modules/users/components/UserTable/EditSheet/store";
-import type { MemberPermissions } from "@calcom/web/modules/users/components/UserTable/types";
+import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
import { updateRoleInCache, getUpdatedUser } from "./MemberChangeRoleModal";
import type { Action, State, User } from "./MemberList";
diff --git a/apps/web/modules/ee/teams/components/MemberList.tsx b/apps/web/modules/ee/teams/components/MemberList.tsx
index e3494f48c77..9f38735f5ef 100644
--- a/apps/web/modules/ee/teams/components/MemberList.tsx
+++ b/apps/web/modules/ee/teams/components/MemberList.tsx
@@ -56,7 +56,7 @@ import { showToast } from "@calcom/ui/components/toast";
import { Tooltip } from "@calcom/ui/components/tooltip";
import TeamAvailabilityModal from "@calcom/web/modules/ee/teams/components/TeamAvailabilityModal";
import { DynamicLink } from "@calcom/web/modules/users/components/UserTable/BulkActions/DynamicLink";
-import type { MemberPermissions } from "@calcom/web/modules/users/components/UserTable/types";
+import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
import DeleteBulkTeamMembers from "./DeleteBulkTeamMembers";
import { EditMemberSheet } from "./EditMemberSheet";
diff --git a/apps/web/modules/ee/teams/views/team-members-view.tsx b/apps/web/modules/ee/teams/views/team-members-view.tsx
index 6cb88bf86c8..a9de10ce536 100644
--- a/apps/web/modules/ee/teams/views/team-members-view.tsx
+++ b/apps/web/modules/ee/teams/views/team-members-view.tsx
@@ -5,7 +5,7 @@ import { useState } from "react";
import LicenseRequired from "~/ee/common/components/LicenseRequired";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { RouterOutputs } from "@calcom/trpc/react";
-import type { MemberPermissions } from "@calcom/web/modules/users/components/UserTable/types";
+import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
import { MemberInvitationModalWithoutMembers } from "~/ee/teams/components/MemberInvitationModal";
diff --git a/apps/web/modules/members/members-view.tsx b/apps/web/modules/members/members-view.tsx
index 9dbc5ee8d59..d2cab5684e0 100644
--- a/apps/web/modules/members/members-view.tsx
+++ b/apps/web/modules/members/members-view.tsx
@@ -5,7 +5,7 @@ import LicenseRequired from "~/ee/common/components/LicenseRequired";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { UserListTable } from "@calcom/web/modules/users/components/UserTable/UserListTable";
import type { UserListTableProps } from "@calcom/web/modules/users/components/UserTable/UserListTable";
-import type { MemberPermissions } from "@calcom/web/modules/users/components/UserTable/types";
+import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
export const MembersView = (props: UserListTableProps & { permissions?: MemberPermissions }) => {
const { t } = useLocale();
diff --git a/apps/web/modules/onboarding/components/onboarding-calendar-browser-view.tsx b/apps/web/modules/onboarding/components/onboarding-calendar-browser-view.tsx
index 32fdafe0d7c..614d8a8c670 100644
--- a/apps/web/modules/onboarding/components/onboarding-calendar-browser-view.tsx
+++ b/apps/web/modules/onboarding/components/onboarding-calendar-browser-view.tsx
@@ -5,7 +5,7 @@ import { usePathname } from "next/navigation";
import { useMemo } from "react";
import dayjs from "@calcom/dayjs";
-import { Calendar } from "@calcom/features/calendars/weeklyview";
+import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
import type { CalendarComponentProps, Hours } from "@calcom/features/calendars/weeklyview/types/state";
import { weekdayDates } from "@calcom/features/calendars/weeklyview/utils";
import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants";
diff --git a/packages/features/troubleshooter/components/AvailabilitySchedulesContainer.tsx b/apps/web/modules/troubleshooter/components/AvailabilitySchedulesContainer.tsx
similarity index 100%
rename from packages/features/troubleshooter/components/AvailabilitySchedulesContainer.tsx
rename to apps/web/modules/troubleshooter/components/AvailabilitySchedulesContainer.tsx
diff --git a/packages/features/troubleshooter/components/CalendarToggleContainer.tsx b/apps/web/modules/troubleshooter/components/CalendarToggleContainer.tsx
similarity index 100%
rename from packages/features/troubleshooter/components/CalendarToggleContainer.tsx
rename to apps/web/modules/troubleshooter/components/CalendarToggleContainer.tsx
diff --git a/packages/features/troubleshooter/components/ConnectedAppsContainer.tsx b/apps/web/modules/troubleshooter/components/ConnectedAppsContainer.tsx
similarity index 100%
rename from packages/features/troubleshooter/components/ConnectedAppsContainer.tsx
rename to apps/web/modules/troubleshooter/components/ConnectedAppsContainer.tsx
diff --git a/packages/features/troubleshooter/components/EventScheduleItem.tsx b/apps/web/modules/troubleshooter/components/EventScheduleItem.tsx
similarity index 94%
rename from packages/features/troubleshooter/components/EventScheduleItem.tsx
rename to apps/web/modules/troubleshooter/components/EventScheduleItem.tsx
index 45aa1d8c1bb..de2d292d6dc 100644
--- a/packages/features/troubleshooter/components/EventScheduleItem.tsx
+++ b/apps/web/modules/troubleshooter/components/EventScheduleItem.tsx
@@ -5,7 +5,7 @@ import { trpc } from "@calcom/trpc/react";
import { Badge } from "@calcom/ui/components/badge";
import { Label } from "@calcom/ui/components/form";
-import { useTroubleshooterStore } from "../store";
+import { useTroubleshooterStore } from "@calcom/features/troubleshooter/store";
import { TroubleshooterListItemHeader } from "./TroubleshooterListItemContainer";
export function EventScheduleItem() {
diff --git a/packages/features/troubleshooter/components/EventTypeSelect.tsx b/apps/web/modules/troubleshooter/components/EventTypeSelect.tsx
similarity index 94%
rename from packages/features/troubleshooter/components/EventTypeSelect.tsx
rename to apps/web/modules/troubleshooter/components/EventTypeSelect.tsx
index a7000a249e2..f41a064ab7c 100644
--- a/packages/features/troubleshooter/components/EventTypeSelect.tsx
+++ b/apps/web/modules/troubleshooter/components/EventTypeSelect.tsx
@@ -4,8 +4,8 @@ import { shallow } from "zustand/shallow";
import { trpc } from "@calcom/trpc/react";
import { SelectField } from "@calcom/ui/components/form";
-import { getQueryParam } from "../../bookings/Booker/utils/query-param";
-import { useTroubleshooterStore } from "../store";
+import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
+import { useTroubleshooterStore } from "@calcom/features/troubleshooter/store";
export function EventTypeSelect() {
const { data: eventTypes, isPending } = trpc.viewer.eventTypes.listWithTeam.useQuery();
diff --git a/packages/features/troubleshooter/components/LargeCalendar.tsx b/apps/web/modules/troubleshooter/components/LargeCalendar.tsx
similarity index 92%
rename from packages/features/troubleshooter/components/LargeCalendar.tsx
rename to apps/web/modules/troubleshooter/components/LargeCalendar.tsx
index 9e3002fe1d3..30b09151f09 100644
--- a/packages/features/troubleshooter/components/LargeCalendar.tsx
+++ b/apps/web/modules/troubleshooter/components/LargeCalendar.tsx
@@ -3,13 +3,13 @@ import { useMemo } from "react";
import dayjs from "@calcom/dayjs";
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/components/hooks/useAvailableTimeSlots";
-import { Calendar } from "@calcom/features/calendars/weeklyview";
+import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
import { BookingStatus } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
-import { useTimePreferences } from "../../bookings/lib/timePreferences";
-import { useSchedule } from "../../schedules/lib/use-schedule/useSchedule";
-import { useTroubleshooterStore } from "../store";
+import { useTimePreferences } from "@calcom/features/bookings/lib/timePreferences";
+import { useSchedule } from "@calcom/features/schedules/lib/use-schedule/useSchedule";
+import { useTroubleshooterStore } from "@calcom/features/troubleshooter/store";
export const LargeCalendar = ({ extraDays }: { extraDays: number }) => {
const { timezone } = useTimePreferences();
diff --git a/packages/features/troubleshooter/Troubleshooter.tsx b/apps/web/modules/troubleshooter/components/Troubleshooter.tsx
similarity index 86%
rename from packages/features/troubleshooter/Troubleshooter.tsx
rename to apps/web/modules/troubleshooter/components/Troubleshooter.tsx
index 3c96fd2a455..aea5687d71e 100644
--- a/packages/features/troubleshooter/Troubleshooter.tsx
+++ b/apps/web/modules/troubleshooter/components/Troubleshooter.tsx
@@ -2,11 +2,11 @@ import { BookerStoreProvider } from "@calcom/features/bookings/Booker/BookerStor
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
import classNames from "@calcom/ui/classNames";
-import { LargeCalendar } from "./components/LargeCalendar";
-import { TroubleshooterHeader } from "./components/TroubleshooterHeader";
-import { TroubleshooterSidebar } from "./components/TroubleshooterSidebar";
-import { useInitalizeTroubleshooterStore } from "./store";
-import type { TroubleshooterProps } from "./types";
+import { LargeCalendar } from "./LargeCalendar";
+import { TroubleshooterHeader } from "./TroubleshooterHeader";
+import { TroubleshooterSidebar } from "./TroubleshooterSidebar";
+import { useInitalizeTroubleshooterStore } from "@calcom/features/troubleshooter/store";
+import type { TroubleshooterProps } from "@calcom/features/troubleshooter/types";
const extraDaysConfig = {
desktop: 7,
diff --git a/packages/features/troubleshooter/components/TroubleshooterHeader.tsx b/apps/web/modules/troubleshooter/components/TroubleshooterHeader.tsx
similarity index 97%
rename from packages/features/troubleshooter/components/TroubleshooterHeader.tsx
rename to apps/web/modules/troubleshooter/components/TroubleshooterHeader.tsx
index b8994471603..1326b698f82 100644
--- a/packages/features/troubleshooter/components/TroubleshooterHeader.tsx
+++ b/apps/web/modules/troubleshooter/components/TroubleshooterHeader.tsx
@@ -5,7 +5,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button } from "@calcom/ui/components/button";
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
-import { useTroubleshooterStore } from "../store";
+import { useTroubleshooterStore } from "@calcom/features/troubleshooter/store";
export function TroubleshooterHeader({ extraDays, isMobile }: { extraDays: number; isMobile: boolean }) {
const { t, i18n } = useLocale();
diff --git a/packages/features/troubleshooter/components/TroubleshooterListItemContainer.tsx b/apps/web/modules/troubleshooter/components/TroubleshooterListItemContainer.tsx
similarity index 100%
rename from packages/features/troubleshooter/components/TroubleshooterListItemContainer.tsx
rename to apps/web/modules/troubleshooter/components/TroubleshooterListItemContainer.tsx
diff --git a/packages/features/troubleshooter/components/TroubleshooterSidebar.tsx b/apps/web/modules/troubleshooter/components/TroubleshooterSidebar.tsx
similarity index 100%
rename from packages/features/troubleshooter/components/TroubleshooterSidebar.tsx
rename to apps/web/modules/troubleshooter/components/TroubleshooterSidebar.tsx
diff --git a/apps/web/modules/users/components/UserTable/UserListTable.tsx b/apps/web/modules/users/components/UserTable/UserListTable.tsx
index e8dff1dd2ae..3412157b7f0 100644
--- a/apps/web/modules/users/components/UserTable/UserListTable.tsx
+++ b/apps/web/modules/users/components/UserTable/UserListTable.tsx
@@ -23,7 +23,7 @@ import { useOrgBranding } from "@calcom/features/ee/organizations/context/provid
import {
generateCsvRawForMembersTable,
generateHeaderFromReactTable,
-} from "@calcom/features/users/lib/UserListTableUtils";
+} from "@calcom/web/modules/users/lib/UserListTableUtils";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { downloadAsCsv } from "@calcom/lib/csvUtils";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
@@ -48,7 +48,8 @@ import { EditUserSheet } from "./EditSheet/EditUserSheet";
import { ImpersonationMemberModal } from "./ImpersonationMemberModal";
import { InviteMemberModal } from "./InviteMemberModal";
import { TableActions } from "./UserTableActions";
-import type { UserTableState, UserTableAction, UserTableUser, MemberPermissions } from "./types";
+import type { UserTableState, UserTableAction, UserTableUser } from "./types";
+import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
const initialState: UserTableState = {
changeMemberRole: {
diff --git a/apps/web/modules/users/components/UserTable/types.ts b/apps/web/modules/users/components/UserTable/types.ts
index e37c028d1c2..4d3d17196ce 100644
--- a/apps/web/modules/users/components/UserTable/types.ts
+++ b/apps/web/modules/users/components/UserTable/types.ts
@@ -1,6 +1,7 @@
import type { RouterOutputs } from "@calcom/trpc/react";
-export type UserTableUser = RouterOutputs["viewer"]["organizations"]["listMembers"]["rows"][number];
+export type UserTableUser =
+ RouterOutputs["viewer"]["organizations"]["listMembers"]["rows"][number];
export type PlatformManagedUserTableUser = Omit<
UserTableUser,
@@ -12,11 +13,6 @@ export type UserTablePayload = {
user?: UserTableUser;
};
-export type PlatformUserTablePayload = {
- showModal: boolean;
- user?: PlatformManagedUserTableUser;
-};
-
export type UserTableState = {
changeMemberRole: UserTablePayload;
deleteMember: UserTablePayload;
@@ -25,10 +21,6 @@ export type UserTableState = {
editSheet: UserTablePayload & { user?: UserTableUser };
};
-export type PlatforManagedUserTableState = {
- deleteMember: UserTablePayload;
-};
-
export type UserTableAction =
| {
type:
@@ -43,22 +35,3 @@ export type UserTableAction =
| {
type: "CLOSE_MODAL";
};
-
-export type PlatformManagedUserTableAction =
- | {
- type: "SET_DELETE_ID";
- payload: PlatformUserTablePayload;
- }
- | {
- type: "CLOSE_MODAL";
- };
-
-export interface MemberPermissions {
- canListMembers: boolean;
- canInvite: boolean;
- canChangeMemberRole: boolean;
- canRemove: boolean;
- canImpersonate: boolean;
- canEditAttributesForUser?: boolean;
- canViewAttributes?: boolean;
-}
diff --git a/apps/web/test/lib/generateCsv.test.ts b/apps/web/modules/users/lib/UserListTableUtils.test.ts
similarity index 99%
rename from apps/web/test/lib/generateCsv.test.ts
rename to apps/web/modules/users/lib/UserListTableUtils.test.ts
index 0d712299c82..115ad49c618 100644
--- a/apps/web/test/lib/generateCsv.test.ts
+++ b/apps/web/modules/users/lib/UserListTableUtils.test.ts
@@ -4,7 +4,7 @@ import { describe, it, expect, vi } from "vitest";
import {
generateCsvRawForMembersTable,
generateHeaderFromReactTable,
-} from "@calcom/features/users/lib/UserListTableUtils";
+} from "@calcom/web/modules/users/lib/UserListTableUtils";
import { MembershipRole } from "@calcom/prisma/enums";
import type { UserTableUser } from "@calcom/web/modules/users/components/UserTable/types";
diff --git a/packages/features/users/lib/UserListTableUtils.ts b/apps/web/modules/users/lib/UserListTableUtils.ts
similarity index 100%
rename from packages/features/users/lib/UserListTableUtils.ts
rename to apps/web/modules/users/lib/UserListTableUtils.ts
diff --git a/apps/web/package.json b/apps/web/package.json
index e55ac7aca11..e1872c3d04d 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -152,6 +152,7 @@
"@babel/core": "7.26.10",
"@biomejs/biome": "2.3.10",
"@calcom/config": "workspace:*",
+ "@calcom/testing": "workspace:*",
"@calcom/types": "workspace:*",
"@microsoft/microsoft-graph-types-beta": "0.15.0-preview",
"@playwright/test": "1.57.0",
diff --git a/packages/features/bookings/lib/handleNewBooking/test/recurring-event.test.ts b/apps/web/pages/api/book/recurring-event.test.ts
similarity index 98%
rename from packages/features/bookings/lib/handleNewBooking/test/recurring-event.test.ts
rename to apps/web/pages/api/book/recurring-event.test.ts
index 4ead5d4050e..8f662c116dc 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/recurring-event.test.ts
+++ b/apps/web/pages/api/book/recurring-event.test.ts
@@ -9,16 +9,16 @@ import {
mockSuccessfulVideoMeetingCreation,
TestData,
Timezones,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { createMockNextJsRequest } from "@calcom/web/test/utils/bookingScenario/createMockNextJsRequest";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { createMockNextJsRequest } from "@calcom/testing/lib/bookingScenario/createMockNextJsRequest";
import {
expectBookingCreatedWebhookToHaveBeenFired,
expectBookingToBeInDatabase, // expectWorkflowToBeTriggered,
expectSuccessfulBookingCreationEmails,
expectSuccessfulCalendarEventCreationInCalendar,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { v4 as uuidv4 } from "uuid";
import { describe, expect } from "vitest";
@@ -27,7 +27,7 @@ import { WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants";
import { ErrorCode } from "@calcom/lib/errorCodes";
import logger from "@calcom/lib/logger";
import { BookingStatus, SchedulingType } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
const DAY_IN_MS = 1000 * 60 * 60 * 24;
@@ -156,7 +156,7 @@ describe("handleNewBooking", () => {
}),
});
- const createdBookings = await handleRecurringEventBooking(req, res);
+ const createdBookings = await handleRecurringEventBooking(req);
expect(createdBookings.length).toBe(numOfSlotsToBeBooked);
for (const [index, createdBooking] of Object.entries(createdBookings)) {
logger.debug("Assertion for Booking with index:", index, { createdBooking });
@@ -374,7 +374,7 @@ describe("handleNewBooking", () => {
}),
});
- expect(() => handleRecurringEventBooking(req, res)).rejects.toThrow(
+ await expect(handleRecurringEventBooking(req)).rejects.toThrow(
ErrorCode.NoAvailableUsersFound
);
// Actually the first booking goes through in this case but the status is still a failure. We should do a dry run to check if booking is possible for the 2 slots and if yes, then only go for the actual booking otherwise fail the recurring bookign
@@ -507,7 +507,7 @@ describe("handleNewBooking", () => {
}),
});
- const createdBookings = await handleRecurringEventBooking(req, res);
+ const createdBookings = await handleRecurringEventBooking(req);
expect(createdBookings.length).toBe(numOfSlotsToBeBooked);
for (const [index, createdBooking] of Object.entries(createdBookings)) {
logger.debug("Assertion for Booking with index:", index, { createdBooking });
@@ -725,7 +725,7 @@ describe("handleNewBooking", () => {
}),
});
- const createdBookings = await handleRecurringEventBooking(req, res);
+ const createdBookings = await handleRecurringEventBooking(req);
expect(createdBookings.length).toBe(numOfSlotsToBeBooked);
for (const [index, createdBooking] of Object.entries(createdBookings)) {
logger.debug("Assertion for Booking with index:", index, { createdBooking });
@@ -985,7 +985,7 @@ describe("handleNewBooking", () => {
});
let error = { message: "" };
try {
- await handleRecurringEventBooking(req, res);
+ await handleRecurringEventBooking(req);
} catch (e) {
error = e as Error;
}
@@ -1167,11 +1167,11 @@ describe("handleNewBooking", () => {
}),
});
- const createdBookings1 = await handleRecurringEventBooking(req, res);
+ const createdBookings1 = await handleRecurringEventBooking(req);
const assignedUserIds1 = createdBookings1.map((booking) => booking.userId);
- const createdBookings2 = await handleRecurringEventBooking(req1, res1);
+ const createdBookings2 = await handleRecurringEventBooking(req1);
const assignedUserIds2 = createdBookings2.map((booking) => booking.userId);
@@ -1388,11 +1388,11 @@ describe("handleNewBooking", () => {
}),
});
- const createdBookings1 = await handleRecurringEventBooking(req, res);
+ const createdBookings1 = await handleRecurringEventBooking(req);
const assignedUserIds1 = createdBookings1.map((booking) => booking.userId);
- const createdBookings2 = await handleRecurringEventBooking(req1, res1);
+ const createdBookings2 = await handleRecurringEventBooking(req1);
const assignedUserIds2 = createdBookings2.map((booking) => booking.userId);
diff --git a/apps/web/test/handlers/requestReschedule.test.ts b/apps/web/test/handlers/requestReschedule.test.ts
index 66c62db57b0..5e3f8388166 100644
--- a/apps/web/test/handlers/requestReschedule.test.ts
+++ b/apps/web/test/handlers/requestReschedule.test.ts
@@ -1,5 +1,5 @@
-import { getSampleUserInSession } from "../utils/bookingScenario/getSampleUserInSession";
-import { setupAndTeardown } from "../utils/bookingScenario/setupAndTeardown";
+import { getSampleUserInSession } from "@calcom/testing/lib/bookingScenario/getSampleUserInSession";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import {
createBookingScenario,
getGoogleCalendarCredential,
@@ -10,8 +10,8 @@ import {
getMockBookingAttendee,
getDate,
mockCalendar,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectBookingRequestRescheduledEmails } from "@calcom/web/test/utils/bookingScenario/expects";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectBookingRequestRescheduledEmails } from "@calcom/testing/lib/bookingScenario/expects";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -21,7 +21,7 @@ import { SchedulingType, MembershipRole } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
import type { TRequestRescheduleInputSchema } from "@calcom/trpc/server/routers/viewer/bookings/requestReschedule.schema";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
export type CustomNextApiRequest = NextApiRequest & Request;
diff --git a/apps/web/test/lib/confirm.handler.test.ts b/apps/web/test/lib/confirm.handler.test.ts
index eca68e13eb6..d5de99fc585 100644
--- a/apps/web/test/lib/confirm.handler.test.ts
+++ b/apps/web/test/lib/confirm.handler.test.ts
@@ -4,7 +4,7 @@ import {
getScenarioData,
TestData,
mockSuccessfulVideoMeetingCreation,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, it, beforeEach, vi, expect } from "vitest";
diff --git a/apps/web/test/lib/getSchedule.test.ts b/apps/web/test/lib/getSchedule.test.ts
index d6c8ebcb7fb..e3534ee17df 100644
--- a/apps/web/test/lib/getSchedule.test.ts
+++ b/apps/web/test/lib/getSchedule.test.ts
@@ -1,4 +1,4 @@
-import CalendarManagerMock from "../../../../tests/libs/__mocks__/CalendarManager";
+import CalendarManagerMock from "@calcom/features/calendars/lib/__mocks__/CalendarManager";
import { constantsScenarios } from "@calcom/lib/__mocks__/constants";
import {
@@ -12,7 +12,7 @@ import {
TestData,
createCredentials,
mockCrmApp,
-} from "../utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, vi, test } from "vitest";
diff --git a/apps/web/test/lib/getSchedule/calendarEvents.test.ts b/apps/web/test/lib/getSchedule/calendarEvents.test.ts
index 7958d7999fd..14227763060 100644
--- a/apps/web/test/lib/getSchedule/calendarEvents.test.ts
+++ b/apps/web/test/lib/getSchedule/calendarEvents.test.ts
@@ -5,7 +5,7 @@ import {
Timezones,
TestData,
mockCalendar,
-} from "../../utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, test } from "vitest";
diff --git a/apps/web/test/lib/getSchedule/delegation-credential.test.ts b/apps/web/test/lib/getSchedule/delegation-credential.test.ts
index 04ec01ce1ca..b6fe73a6342 100644
--- a/apps/web/test/lib/getSchedule/delegation-credential.test.ts
+++ b/apps/web/test/lib/getSchedule/delegation-credential.test.ts
@@ -7,8 +7,8 @@ import {
createDelegationCredential,
createOrganization,
getOrganizer,
-} from "../../utils/bookingScenario/bookingScenario";
-import { expectNoAttemptToGetAvailability } from "../../utils/bookingScenario/expects";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectNoAttemptToGetAvailability } from "@calcom/testing/lib/bookingScenario/expects";
import { describe, test } from "vitest";
diff --git a/apps/web/test/lib/getSchedule/futureLimit.timezone.test.ts b/apps/web/test/lib/getSchedule/futureLimit.timezone.test.ts
index c59a4fa9ede..f3bf7daec58 100644
--- a/apps/web/test/lib/getSchedule/futureLimit.timezone.test.ts
+++ b/apps/web/test/lib/getSchedule/futureLimit.timezone.test.ts
@@ -3,8 +3,8 @@ import {
Timezones,
createBookingScenario,
replaceDates,
-} from "../../utils/bookingScenario/bookingScenario";
-import type { ScenarioData } from "../../utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import type { ScenarioData } from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, expect, vi, test } from "vitest";
diff --git a/apps/web/test/lib/getSchedule/restrictionSchedule.test.ts b/apps/web/test/lib/getSchedule/restrictionSchedule.test.ts
index 975c588449a..458923fd7af 100644
--- a/apps/web/test/lib/getSchedule/restrictionSchedule.test.ts
+++ b/apps/web/test/lib/getSchedule/restrictionSchedule.test.ts
@@ -1,11 +1,11 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import {
createBookingScenario,
Timezones,
TestData,
type ScenarioData,
-} from "../../utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, test, vi } from "vitest";
import type { z } from "zod";
diff --git a/apps/web/test/lib/getSchedule/selectedSlots.test.ts b/apps/web/test/lib/getSchedule/selectedSlots.test.ts
index a9b0381d00d..c854cee5476 100644
--- a/apps/web/test/lib/getSchedule/selectedSlots.test.ts
+++ b/apps/web/test/lib/getSchedule/selectedSlots.test.ts
@@ -5,7 +5,7 @@ import {
TestData,
mockCalendarToHaveNoBusySlots,
type ScenarioData,
-} from "../../utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import type { IncomingMessage } from "node:http";
import { describe, test, beforeEach, vi } from "vitest";
diff --git a/apps/web/test/lib/getSchedule/setupAndTeardown.ts b/apps/web/test/lib/getSchedule/setupAndTeardown.ts
index c28a3767d2a..c7c22b825a2 100644
--- a/apps/web/test/lib/getSchedule/setupAndTeardown.ts
+++ b/apps/web/test/lib/getSchedule/setupAndTeardown.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { vi, beforeEach, afterEach } from "vitest";
diff --git a/apps/web/test/lib/getSchedule/utils.ts b/apps/web/test/lib/getSchedule/utils.ts
index ccf25055618..d8a74d9e691 100644
--- a/apps/web/test/lib/getSchedule/utils.ts
+++ b/apps/web/test/lib/getSchedule/utils.ts
@@ -1,4 +1,4 @@
-import { getDate } from "../../utils/bookingScenario/bookingScenario";
+import { getDate } from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { vi } from "vitest";
diff --git a/apps/web/test/lib/handleChildrenEventTypes.test.ts b/apps/web/test/lib/handleChildrenEventTypes.test.ts
index 79db3cd9cf4..8b4200380b6 100644
--- a/apps/web/test/lib/handleChildrenEventTypes.test.ts
+++ b/apps/web/test/lib/handleChildrenEventTypes.test.ts
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
-import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, vi } from "vitest";
diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json
index 3e7d673a63f..ee947350bc6 100644
--- a/apps/web/tsconfig.json
+++ b/apps/web/tsconfig.json
@@ -9,6 +9,7 @@
"@lib/*": ["lib/*"],
"@server/*": ["server/*"],
"@prisma/client/*": ["@calcom/prisma/client/*"],
+ "@calcom/testing/*": ["../../packages/testing/src/*"],
"@calcom/repository/*": ["@calcom/lib/server/repository/*"],
"@coss/ui/*": ["../../packages/coss-ui/src/*"]
},
diff --git a/biome.json b/biome.json
index 5bb3280913e..1e0634944ca 100644
--- a/biome.json
+++ b/biome.json
@@ -236,6 +236,14 @@
{
"group": ["../trpc/**"],
"message": "features package should not import from trpc to avoid circular dependencies."
+ },
+ {
+ "group": ["@calcom/web", "@calcom/web/**"],
+ "message": "features package should not import from @calcom/web to avoid circular dependencies."
+ },
+ {
+ "group": ["../../apps/web/**"],
+ "message": "features package should not import from apps/web to avoid circular dependencies."
}
]
}
@@ -263,6 +271,38 @@
}
}
}
+ },
+ {
+ "includes": ["packages/testing/**/*.{ts,tsx,js,jsx,mts,mjs,cjs,cts}"],
+ "linter": {
+ "rules": {
+ "style": {
+ "noRestrictedImports": {
+ "level": "error",
+ "options": {
+ "patterns": [
+ {
+ "group": ["@calcom/web", "@calcom/web/**"],
+ "message": "testing package should not import from @calcom/web to avoid circular dependencies."
+ },
+ {
+ "group": ["@calcom/features", "@calcom/features/**"],
+ "message": "testing package should not import from @calcom/features to avoid circular dependencies."
+ },
+ {
+ "group": ["../../apps/web/**"],
+ "message": "testing package should not import from apps/web to avoid circular dependencies."
+ },
+ {
+ "group": ["../features/**"],
+ "message": "testing package should not import from features to avoid circular dependencies."
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
}
]
}
diff --git a/packages/app-store/_utils/getDefaultLocations.test.ts b/packages/app-store/_utils/getDefaultLocations.test.ts
index 456083f9f00..bf5a33b5799 100644
--- a/packages/app-store/_utils/getDefaultLocations.test.ts
+++ b/packages/app-store/_utils/getDefaultLocations.test.ts
@@ -1,6 +1,6 @@
-import prismaMock from "../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
-import { getGoogleMeetCredential, TestData } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+import { getGoogleMeetCredential, TestData } from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, expect, it } from "vitest";
diff --git a/packages/app-store/_utils/oauth/OAuthManager.test.ts b/packages/app-store/_utils/oauth/OAuthManager.test.ts
index 9870808fcbc..ba6253f899e 100644
--- a/packages/app-store/_utils/oauth/OAuthManager.test.ts
+++ b/packages/app-store/_utils/oauth/OAuthManager.test.ts
@@ -1,4 +1,4 @@
-// import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+// import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { afterEach, expect, test, vi, describe } from "vitest";
import "vitest-fetch-mock";
diff --git a/packages/app-store/delegationCredential.test.ts b/packages/app-store/delegationCredential.test.ts
index 256caced3fb..7e9f5b60688 100644
--- a/packages/app-store/delegationCredential.test.ts
+++ b/packages/app-store/delegationCredential.test.ts
@@ -1,6 +1,6 @@
import { organizationRepositoryMock } from "@calcom/features/ee/organizations/__mocks__/organizationMock";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, it, expect, beforeEach, vi } from "vitest";
diff --git a/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts b/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts
index 31af2e8eed2..61764f2372f 100644
--- a/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts
+++ b/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import "../__mocks__/features.repository";
import "../__mocks__/getGoogleAppKeys";
import {
diff --git a/packages/app-store/googlecalendar/lib/__tests__/utils.ts b/packages/app-store/googlecalendar/lib/__tests__/utils.ts
index 5e85dafb13c..4d52c1bfd6a 100644
--- a/packages/app-store/googlecalendar/lib/__tests__/utils.ts
+++ b/packages/app-store/googlecalendar/lib/__tests__/utils.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { MOCK_JWT_TOKEN, setLastCreatedJWT } from "../__mocks__/googleapis";
import { JWT } from "googleapis-common";
diff --git a/packages/app-store/hubspot/lib/CrmService.test.ts b/packages/app-store/hubspot/lib/CrmService.test.ts
index 0f5c099e0f0..ed019a7e659 100644
--- a/packages/app-store/hubspot/lib/CrmService.test.ts
+++ b/packages/app-store/hubspot/lib/CrmService.test.ts
@@ -2,7 +2,7 @@ import type { TFunction } from "i18next";
import type { CalendarEvent } from "@calcom/types/Calendar";
import type { CredentialPayload } from "@calcom/types/Credential";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { z } from "zod";
diff --git a/packages/app-store/office365video/lib/VideoApiAdapter.test.ts b/packages/app-store/office365video/lib/VideoApiAdapter.test.ts
index 2b969b91131..865e2e54f58 100644
--- a/packages/app-store/office365video/lib/VideoApiAdapter.test.ts
+++ b/packages/app-store/office365video/lib/VideoApiAdapter.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { expect, test, vi, describe } from "vitest";
diff --git a/packages/app-store/package.json b/packages/app-store/package.json
index d380a194a05..95c0a631003 100644
--- a/packages/app-store/package.json
+++ b/packages/app-store/package.json
@@ -33,6 +33,7 @@
"zod": "^3.0.0"
},
"devDependencies": {
+ "@calcom/testing": "workspace:*",
"@calcom/types": "workspace:*"
}
}
diff --git a/packages/app-store/salesforce/lib/CrmService.test.ts b/packages/app-store/salesforce/lib/CrmService.test.ts
index 3d3d9f807c2..b0f26a0b7bc 100644
--- a/packages/app-store/salesforce/lib/CrmService.test.ts
+++ b/packages/app-store/salesforce/lib/CrmService.test.ts
@@ -1,4 +1,4 @@
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect, it, beforeEach, vi } from "vitest";
import type { z } from "zod";
diff --git a/packages/app-store/tsconfig.json b/packages/app-store/tsconfig.json
index cacd085f240..17bd0282117 100644
--- a/packages/app-store/tsconfig.json
+++ b/packages/app-store/tsconfig.json
@@ -4,11 +4,8 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
- /* A `package` should never import from `apps` ↓ */
- "@components/*": ["../../apps/web/components/*"],
- /* A `package` should never import from `apps` ↓ */
- "@lib/*": ["../../apps/web/lib/*"],
- "@prisma/client/*": ["@calcom/prisma/client/*"]
+ "@prisma/client/*": ["@calcom/prisma/client/*"],
+ "@calcom/testing/*": ["../testing/src/*"]
},
"resolveJsonModule": true,
"experimentalDecorators": true
diff --git a/packages/emails/lib/generateIcsString.test.ts b/packages/emails/lib/generateIcsString.test.ts
index 43d0fe53873..d7b9887bc4c 100644
--- a/packages/emails/lib/generateIcsString.test.ts
+++ b/packages/emails/lib/generateIcsString.test.ts
@@ -4,7 +4,7 @@ import { ORGANIZER_EMAIL_EXEMPT_DOMAINS } from "@calcom/lib/constants";
import { buildCalendarEvent, buildPerson } from "@calcom/lib/test/builder";
import { buildVideoCallData } from "@calcom/lib/test/builder";
import type { CalendarEvent } from "@calcom/types/Calendar";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import generateIcsString from "./generateIcsString";
diff --git a/packages/emails/lib/getICalUID.test.ts b/packages/emails/lib/getICalUID.test.ts
index b8c518b9f35..8f8117b9fee 100644
--- a/packages/emails/lib/getICalUID.test.ts
+++ b/packages/emails/lib/getICalUID.test.ts
@@ -2,7 +2,7 @@ import { describe, expect } from "vitest";
import { APP_NAME } from "@calcom/lib/constants";
import { buildCalendarEvent } from "@calcom/lib/test/builder";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import getICalUID from "./getICalUID";
diff --git a/packages/emails/package.json b/packages/emails/package.json
index 64af5b257cb..a9d5e82aedb 100644
--- a/packages/emails/package.json
+++ b/packages/emails/package.json
@@ -16,6 +16,7 @@
"react-dom": "^18.0.0 || ^19.0.0"
},
"devDependencies": {
+ "@calcom/testing": "workspace:*",
"@calcom/tsconfig": "workspace:*",
"@calcom/types": "workspace:*"
}
diff --git a/packages/features/attributes/lib/getAttributes.test.ts b/packages/features/attributes/lib/getAttributes.test.ts
index 22f2adffee0..c35c073524c 100644
--- a/packages/features/attributes/lib/getAttributes.test.ts
+++ b/packages/features/attributes/lib/getAttributes.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, beforeEach } from "vitest";
diff --git a/packages/features/auth/signup/handlers/__tests__/p2002.test-suite.ts b/packages/features/auth/signup/handlers/__tests__/p2002.test-suite.ts
index 76ea04e24ec..1a112eaf073 100644
--- a/packages/features/auth/signup/handlers/__tests__/p2002.test-suite.ts
+++ b/packages/features/auth/signup/handlers/__tests__/p2002.test-suite.ts
@@ -91,7 +91,7 @@ export function runP2002TestSuite(
beforeEach(setupMocks);
it("returns 201 when user is created (non-token flow)", async () => {
- prismaMock.user.create.mockResolvedValue(createMockUser());
+ prismaMock.user.create.mockResolvedValue(createMockUser() as never);
const response = await callHandler(createSignupBody());
diff --git a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.test.ts b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.test.ts
index 0b8b9f155a9..e8ccf58b098 100644
--- a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.test.ts
+++ b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.test.ts
@@ -3,7 +3,7 @@ import {
addTeamsToDb,
addEventTypesToDb,
addUsersToDb,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, test, expect, vi } from "vitest";
diff --git a/packages/features/bookings/lib/getBookingResponsesSchema.test.ts b/packages/features/bookings/lib/getBookingResponsesSchema.test.ts
index 22a767d5d12..106dfb9d3e6 100644
--- a/packages/features/bookings/lib/getBookingResponsesSchema.test.ts
+++ b/packages/features/bookings/lib/getBookingResponsesSchema.test.ts
@@ -3,7 +3,7 @@ import { describe, expect } from "vitest";
import type { z } from "zod";
import type { eventTypeBookingFields } from "@calcom/prisma/zod-utils";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import getBookingResponsesSchema, { getBookingResponsesPartialSchema } from "./getBookingResponsesSchema";
diff --git a/packages/features/bookings/lib/getLuckyUser.test.ts b/packages/features/bookings/lib/getLuckyUser.test.ts
index 8ab4935f529..020bf783357 100644
--- a/packages/features/bookings/lib/getLuckyUser.test.ts
+++ b/packages/features/bookings/lib/getLuckyUser.test.ts
@@ -1,5 +1,5 @@
-import CalendarManagerMock from "../../../../tests/libs/__mocks__/CalendarManager";
-import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+import CalendarManagerMock from "@calcom/features/calendars/lib/__mocks__/CalendarManager";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { v4 as uuid } from "uuid";
import { expect, it, describe, vi, beforeAll } from "vitest";
diff --git a/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts b/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
index dabcdc8b5df..18f76fd7f9d 100644
--- a/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
+++ b/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
@@ -9,18 +9,18 @@ import {
mockSuccessfulVideoMeetingCreation,
TestData,
getDate,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectBookingCancelledWebhookToHaveBeenFired,
expectWorkflowToBeTriggered,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect, vi } from "vitest";
import { processPaymentRefund } from "@calcom/features/bookings/lib/payment/processPaymentRefund";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
vi.mock("@calcom/features/bookings/lib/payment/processPaymentRefund", () => ({
processPaymentRefund: vi.fn(),
diff --git a/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts b/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts
index 3cac0a282b3..e9a898716b1 100644
--- a/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts
@@ -6,16 +6,16 @@ import {
getScenarioData,
getGoogleCalendarCredential,
Timezones,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
// TODO: we should rename this - it doesnt get a mockRequestDataForBooking - it just gets mock booking data.
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect, vi, beforeAll } from "vitest";
import { SchedulingType } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./test/getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/booking-flags.test.ts b/packages/features/bookings/lib/handleNewBooking/test/booking-flags.test.ts
index 302c63b4196..7868bebd5fc 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/booking-flags.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/booking-flags.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
createBookingScenario,
@@ -10,10 +10,10 @@ import {
getScenarioData,
mockCalendarToHaveNoBusySlots,
mockCalendar,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectBookingToBeInDatabase } from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectBookingToBeInDatabase } from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect, test } from "vitest";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/booking-limits.test.ts b/packages/features/bookings/lib/handleNewBooking/test/booking-limits.test.ts
index ddf2019ee91..214fd30c7b0 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/booking-limits.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/booking-limits.test.ts
@@ -5,7 +5,7 @@
* see: https://github.com/calcom/cal.com/pull/10480
* https://github.com/calcom/cal.com/pull/10968
*/
-import prismock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import {
TestData,
@@ -19,16 +19,16 @@ import {
BookingLocations,
mockSuccessfulVideoMeetingCreation,
mockCalendarToHaveNoBusySlots,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectBookingToBeInDatabase } from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectBookingToBeInDatabase } from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect, vi } from "vitest";
import { PeriodType } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/booking-validations.test.ts b/packages/features/bookings/lib/handleNewBooking/test/booking-validations.test.ts
index 507ec19fdbb..df37f9c031b 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/booking-validations.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/booking-validations.test.ts
@@ -2,7 +2,7 @@
* Booking Validation Specifications
* These specifications verify the business rules and validation behavior for booking creation
*/
-import prismaMock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
createBookingScenario,
@@ -12,15 +12,15 @@ import {
getScenarioData,
getGoogleCalendarCredential,
mockCalendarToHaveNoBusySlots,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { afterEach, beforeEach, vi } from "vitest";
import { describe, expect } from "vitest";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.ts b/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.ts
index 9122e5b347c..ccf83703f69 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.ts
@@ -9,15 +9,15 @@ import {
mockSuccessfulVideoMeetingCreation,
mockCalendarToHaveNoBusySlots,
BookingLocations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectSuccessfulBookingCreationEmails,
expectBookingToBeInDatabase,
expectSuccessfulCalendarEventCreationInCalendar,
expectICalUIDAsString,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -26,7 +26,7 @@ import { describe, expect } from "vitest";
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
import dayjs from "@calcom/dayjs";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.ts b/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.ts
index 4b0dc1a33f4..1711928762c 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.ts
@@ -9,15 +9,15 @@ import {
mockSuccessfulVideoMeetingCreation,
mockCalendarToHaveNoBusySlots,
BookingLocations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectSuccessfulBookingCreationEmails,
expectBookingToBeInDatabase,
expectSuccessfulCalendarEventCreationInCalendar,
expectICalUIDAsString,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -26,7 +26,7 @@ import { describe, expect } from "vitest";
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
import dayjs from "@calcom/dayjs";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/delegation-credential.test.ts b/packages/features/bookings/lib/handleNewBooking/test/delegation-credential.test.ts
index b3e522a413d..bd0c6b3d304 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/delegation-credential.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/delegation-credential.test.ts
@@ -20,7 +20,7 @@ import {
createDelegationCredential,
createOrganization,
buildDelegationCredential,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectWorkflowToBeTriggered,
expectSuccessfulBookingCreationEmails,
@@ -30,12 +30,12 @@ import {
expectICalUIDAsString,
expectBookingToNotHaveReference,
expectNoAttemptToCreateCalendarEvent,
-} from "@calcom/web/test/utils/bookingScenario/expects";
+} from "@calcom/testing/lib/bookingScenario/expects";
import {
getMockRequestDataForBooking,
getMockRequestDataForDynamicGroupBooking,
-} from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { vi } from "vitest";
import { describe, expect } from "vitest";
@@ -43,7 +43,7 @@ import { describe, expect } from "vitest";
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
import { BookingStatus } from "@calcom/prisma/enums";
import { MembershipRole } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/dynamic-group-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/dynamic-group-booking.test.ts
index df22c09df0e..c6ddec8a2dc 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/dynamic-group-booking.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/dynamic-group-booking.test.ts
@@ -16,10 +16,10 @@ import {
getBooker,
getScenarioData,
mockCalendar,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectBookingToBeInDatabase } from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForDynamicGroupBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectBookingToBeInDatabase } from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForDynamicGroupBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -27,7 +27,7 @@ import { describe, expect } from "vitest";
import { ErrorCode } from "@calcom/lib/errorCodes";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts
index 46b6f0e60bd..65a57620f09 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts
@@ -11,13 +11,13 @@ import {
getOrganizer,
TestData,
getScenarioData,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { vi, describe, expect, beforeEach } from "vitest";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts
index 2f0b2877a51..e59736f6703 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts
@@ -7,7 +7,7 @@
*
* They don't intend to test what the apps logic should do, but rather test if the apps are called with the correct data. For testing that, once should write tests within each app.
*/
-import prismaMock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
createBookingScenario,
@@ -25,12 +25,11 @@ import {
getStripeAppCredential,
MockError,
mockPaymentApp,
- mockPaymentSuccessWebhookFromStripe,
mockCalendar,
mockCalendarToCrashOnCreateEvent,
mockVideoAppToCrashOnCreateMeeting,
BookingLocations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectWorkflowToBeTriggered,
expectWorkflowToBeNotTriggered,
@@ -45,26 +44,57 @@ import {
expectSuccessfulCalendarEventCreationInCalendar,
expectICalUIDAsString,
expectBookingTrackingToBeInDatabase,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
-import { testWithAndWithoutOrg } from "@calcom/web/test/utils/bookingScenario/test";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
+import { testWithAndWithoutOrg } from "@calcom/testing/lib/bookingScenario/test";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
import { describe, expect } from "vitest";
+import type Stripe from "stripe";
+
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
+import { handleStripePaymentSuccess } from "@calcom/features/ee/payments/api/webhook";
import { createWatchlistEntry } from "@calcom/features/watchlist/lib/testUtils";
import { WEBSITE_URL, WEBAPP_URL } from "@calcom/lib/constants";
+import type { HttpError } from "@calcom/lib/http-error";
+import logger from "@calcom/lib/logger";
+import { distributedTracing } from "@calcom/lib/tracing/factory";
import { ErrorCode } from "@calcom/lib/errorCodes";
import { resetTestEmails } from "@calcom/lib/testEmails";
import { CreationSource, WatchlistType } from "@calcom/prisma/enums";
import { BookingStatus, SchedulingType } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
+const log = logger.getSubLogger({ prefix: ["[fresh-booking.test]"] });
+
+function getMockedStripePaymentEvent({ paymentIntentId }: { paymentIntentId: string }) {
+ return {
+ id: null,
+ data: {
+ object: {
+ id: paymentIntentId,
+ },
+ },
+ } as unknown as Stripe.Event;
+}
+
+async function mockPaymentSuccessWebhookFromStripe({ externalId }: { externalId: string }) {
+ let webhookResponse = null;
+ try {
+ const traceContext = distributedTracing.createTrace("test_stripe_webhook");
+ await handleStripePaymentSuccess(getMockedStripePaymentEvent({ paymentIntentId: externalId }), traceContext);
+ } catch (e) {
+ log.silly("mockPaymentSuccessWebhookFromStripe:catch", JSON.stringify(e));
+ webhookResponse = e as HttpError;
+ }
+ return { webhookResponse };
+}
+
export type CustomNextApiRequest = NextApiRequest & Request;
export type CustomNextApiResponse = NextApiResponse & Response;
diff --git a/packages/features/bookings/lib/handleNewBooking/test/managed-event-type-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/managed-event-type-booking.test.ts
index 59214bf2601..46a3773b9ce 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/managed-event-type-booking.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/managed-event-type-booking.test.ts
@@ -1,8 +1,8 @@
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe } from "vitest";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
describe("handleNewBooking", () => {
setupAndTeardown();
diff --git a/packages/features/bookings/lib/handleNewBooking/test/post-booking-handling.test.ts b/packages/features/bookings/lib/handleNewBooking/test/post-booking-handling.test.ts
index f75b8f98505..ba86ad9ff78 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/post-booking-handling.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/post-booking-handling.test.ts
@@ -3,7 +3,7 @@
*
* These tests focus specifically on testing what happens after a successful booking or rescheduling.
*/
-import prismaMock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
createBookingScenario,
@@ -15,10 +15,10 @@ import {
getScenarioData,
mockCalendarToHaveNoBusySlots,
BookingLocations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectBookingToBeInDatabase } from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectBookingToBeInDatabase } from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts b/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts
index 07e1710c184..c70b6d6aaeb 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
createBookingScenario,
@@ -18,7 +18,7 @@ import {
getMockFailingAppStatus,
getMockPassingAppStatus,
getDefaultBookingFields,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectWorkflowToBeTriggered,
expectBookingToBeInDatabase,
@@ -32,9 +32,9 @@ import {
expectSuccessfulCalendarEventDeletionInCalendar,
expectSuccessfulVideoMeetingDeletionInCalendar,
expectSuccessfulRoundRobinReschedulingEmails,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect, beforeEach } from "vitest";
@@ -43,7 +43,7 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { resetTestSMS } from "@calcom/lib/testSMS";
import { BookingStatus, SchedulingType } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/round-robin-no-hosts.test.ts b/packages/features/bookings/lib/handleNewBooking/test/round-robin-no-hosts.test.ts
index e729a5228fa..cd3cc0ae77f 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/round-robin-no-hosts.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/round-robin-no-hosts.test.ts
@@ -8,15 +8,15 @@ import {
Timezones,
getDate,
getGoogleCalendarCredential,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect } from "vitest";
import { ErrorCode } from "@calcom/lib/errorCodes";
import { SchedulingType } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/spam-booking.integration-test.ts b/packages/features/bookings/lib/handleNewBooking/test/spam-booking.integration-test.ts
index aa2e8ea5f4f..e699aae7a62 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/spam-booking.integration-test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/spam-booking.integration-test.ts
@@ -9,15 +9,15 @@ import {
mockCalendarToCrashOnGetAvailability,
BookingLocations,
createOrganization,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect, vi } from "vitest";
import { prisma } from "@calcom/prisma";
import { WatchlistType, BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts
index 1a309971ac6..2134a18bb8f 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts
@@ -9,10 +9,10 @@ import {
mockCalendarToHaveNoBusySlots,
getDate,
BookingLocations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectBookingToBeInDatabase } from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectBookingToBeInDatabase } from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -22,7 +22,7 @@ import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
import { resetTestEmails } from "@calcom/lib/testEmails";
import { SchedulingType } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "../getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-scheduling.test.ts b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-scheduling.test.ts
index 6328739d1c8..d834a380fc2 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-scheduling.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-scheduling.test.ts
@@ -14,7 +14,7 @@ import {
BookingLocations,
getZoomAppCredential,
getDefaultBookingFields,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
// expectWorkflowToBeTriggered,
expectSuccessfulBookingCreationEmails,
@@ -25,9 +25,9 @@ import {
expectSMSToBeTriggered,
expectBookingRequestedEmails,
expectBookingRequestedWebhookToHaveBeenFired,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import type { Request, Response } from "express";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -41,7 +41,7 @@ import { ErrorCode } from "@calcom/lib/errorCodes";
import { resetTestSMS } from "@calcom/lib/testSMS";
import { SchedulingType } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "../getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/round-robin.test.ts b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/round-robin.test.ts
index 0c9de8d8280..9e52b9f3686 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/round-robin.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/round-robin.test.ts
@@ -11,10 +11,10 @@ import {
getMockBookingAttendee,
getGoogleCalendarCredential,
mockCalendarToHaveNoBusySlots,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectBookingCreatedWebhookToHaveBeenFired } from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectBookingCreatedWebhookToHaveBeenFired } from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, test, vi, expect } from "vitest";
diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts
index 1467227853f..20b9ad97689 100644
--- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts
+++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts
@@ -11,20 +11,20 @@ import {
getDate,
Timezones,
createOrganization,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectWorkflowToBeTriggered,
expectSMSWorkflowToBeTriggered,
expectSMSWorkflowToBeNotTriggered,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, beforeEach, vi } from "vitest";
import { resetTestSMS } from "@calcom/lib/testSMS";
import { SMSLockState, SchedulingType } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { getNewBookingHandler } from "./getNewBookingHandler";
diff --git a/packages/features/bookings/lib/handleSeats/test/handleSeats.test.ts b/packages/features/bookings/lib/handleSeats/test/handleSeats.test.ts
index e10ab3c4518..28efb97b51c 100644
--- a/packages/features/bookings/lib/handleSeats/test/handleSeats.test.ts
+++ b/packages/features/bookings/lib/handleSeats/test/handleSeats.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
getBooker,
@@ -12,11 +12,11 @@ import {
BookingLocations,
getDate,
getMockBookingAttendee,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { createMockNextJsRequest } from "@calcom/web/test/utils/bookingScenario/createMockNextJsRequest";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { getMockRequestDataForCancelBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForCancelBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { createMockNextJsRequest } from "@calcom/testing/lib/bookingScenario/createMockNextJsRequest";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { getMockRequestDataForCancelBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForCancelBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, test, vi, expect } from "vitest";
diff --git a/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.test.ts b/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.test.ts
index 2d067dc12c6..b8a0f53f579 100644
--- a/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.test.ts
+++ b/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { vi, it, describe, expect, afterEach } from "vitest";
import type { Mock } from "vitest";
diff --git a/packages/features/bookings/lib/payment/processPaymentRefund.test.ts b/packages/features/bookings/lib/payment/processPaymentRefund.test.ts
index ce59e666a75..1fe17dd5bdb 100644
--- a/packages/features/bookings/lib/payment/processPaymentRefund.test.ts
+++ b/packages/features/bookings/lib/payment/processPaymentRefund.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, it, expect, vi, beforeEach } from "vitest";
diff --git a/packages/features/bookings/lib/service/InstantBookingCreateService.test.ts b/packages/features/bookings/lib/service/InstantBookingCreateService.test.ts
index 45827697d86..73574053e6f 100644
--- a/packages/features/bookings/lib/service/InstantBookingCreateService.test.ts
+++ b/packages/features/bookings/lib/service/InstantBookingCreateService.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import {
createBookingScenario,
@@ -9,7 +9,7 @@ import {
mockSuccessfulVideoMeetingCreation,
mockCalendarToHaveNoBusySlots,
mockNoTranslations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, it, expect, vi, beforeEach } from "vitest";
diff --git a/packages/features/bookings/lib/service/RecurringBookingService.test.ts b/packages/features/bookings/lib/service/RecurringBookingService.test.ts
index 9453f3e3200..32506333d4d 100644
--- a/packages/features/bookings/lib/service/RecurringBookingService.test.ts
+++ b/packages/features/bookings/lib/service/RecurringBookingService.test.ts
@@ -8,15 +8,15 @@ import {
mockCalendarToHaveNoBusySlots,
mockSuccessfulVideoMeetingCreation,
TestData,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectBookingCreatedWebhookToHaveBeenFired,
expectBookingToBeInDatabase,
expectSuccessfulBookingCreationEmails,
expectSuccessfulCalendarEventCreationInCalendar,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { getMockRequestDataForBooking } from "@calcom/testing/lib/bookingScenario/getMockRequestDataForBooking";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { v4 as uuidv4 } from "uuid";
import { describe, expect } from "vitest";
@@ -25,7 +25,7 @@ import { getRecurringBookingService } from "@calcom/features/bookings/di/Recurri
import { WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
const DAY_IN_MS = 1000 * 60 * 60 * 24;
diff --git a/tests/libs/__mocks__/CalendarManager.ts b/packages/features/calendars/lib/__mocks__/CalendarManager.ts
similarity index 79%
rename from tests/libs/__mocks__/CalendarManager.ts
rename to packages/features/calendars/lib/__mocks__/CalendarManager.ts
index ecfdc6d4a2c..e73ca9094a9 100644
--- a/tests/libs/__mocks__/CalendarManager.ts
+++ b/packages/features/calendars/lib/__mocks__/CalendarManager.ts
@@ -1,7 +1,7 @@
import { beforeEach, vi } from "vitest";
import { mockReset, mockDeep } from "vitest-mock-extended";
-import type * as CalendarManager from "@calcom/features/calendars/lib/CalendarManager";
+import type * as CalendarManager from "../CalendarManager";
vi.mock("@calcom/features/calendars/lib/CalendarManager", () => CalendarManagerMock);
diff --git a/packages/features/calendars/lib/getCalendarsEvents.test.ts b/packages/features/calendars/lib/getCalendarsEvents.test.ts
index c480fb9e146..bb47d25bbee 100644
--- a/packages/features/calendars/lib/getCalendarsEvents.test.ts
+++ b/packages/features/calendars/lib/getCalendarsEvents.test.ts
@@ -1,4 +1,4 @@
-import "../../../../tests/libs/__mocks__/prisma";
+import "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
diff --git a/packages/features/calendars/weeklyview/index.tsx b/packages/features/calendars/weeklyview/index.tsx
deleted file mode 100644
index 76930d546e9..00000000000
--- a/packages/features/calendars/weeklyview/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
diff --git a/packages/features/credentials/deleteCredential.test.ts b/packages/features/credentials/deleteCredential.test.ts
index 1702a17f861..8c0b10e71a4 100644
--- a/packages/features/credentials/deleteCredential.test.ts
+++ b/packages/features/credentials/deleteCredential.test.ts
@@ -1,7 +1,7 @@
import {
addEventTypesToDb,
mockNoTranslations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, test, expect, beforeEach } from "vitest";
diff --git a/packages/features/credits/repositories/CreditsRepository.test.ts b/packages/features/credits/repositories/CreditsRepository.test.ts
index 53c3fd296fe..356ea4aa385 100644
--- a/packages/features/credits/repositories/CreditsRepository.test.ts
+++ b/packages/features/credits/repositories/CreditsRepository.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect, beforeEach, vi, afterEach } from "vitest";
diff --git a/packages/features/crmManager/crmManager.test.ts b/packages/features/crmManager/crmManager.test.ts
index 9ba35daafd7..fc01e2b9cfd 100644
--- a/packages/features/crmManager/crmManager.test.ts
+++ b/packages/features/crmManager/crmManager.test.ts
@@ -1,4 +1,4 @@
-import { mockCrmApp } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+import { mockCrmApp } from "@calcom/testing/lib/bookingScenario/bookingScenario";
import type { TFunction } from "i18next";
import { describe, expect, test, vi, afterEach } from "vitest";
diff --git a/packages/features/data-table/__tests__/filterSegments/create.test.ts b/packages/features/data-table/__tests__/filterSegments/create.test.ts
index 6f197f607e4..8332bf013c5 100644
--- a/packages/features/data-table/__tests__/filterSegments/create.test.ts
+++ b/packages/features/data-table/__tests__/filterSegments/create.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it } from "vitest";
diff --git a/packages/features/data-table/__tests__/filterSegments/delete.test.ts b/packages/features/data-table/__tests__/filterSegments/delete.test.ts
index 8b9e4641363..fffa2485343 100644
--- a/packages/features/data-table/__tests__/filterSegments/delete.test.ts
+++ b/packages/features/data-table/__tests__/filterSegments/delete.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it } from "vitest";
diff --git a/packages/features/data-table/__tests__/filterSegments/get.test.ts b/packages/features/data-table/__tests__/filterSegments/get.test.ts
index 6b4d42fc22d..eda9a8793a9 100644
--- a/packages/features/data-table/__tests__/filterSegments/get.test.ts
+++ b/packages/features/data-table/__tests__/filterSegments/get.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it } from "vitest";
diff --git a/packages/features/data-table/__tests__/filterSegments/update.test.ts b/packages/features/data-table/__tests__/filterSegments/update.test.ts
index 8cc3743aee6..22e6d9bb62d 100644
--- a/packages/features/data-table/__tests__/filterSegments/update.test.ts
+++ b/packages/features/data-table/__tests__/filterSegments/update.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it } from "vitest";
diff --git a/packages/features/delegation-credentials/repositories/DelegationCredentialRepository.test.ts b/packages/features/delegation-credentials/repositories/DelegationCredentialRepository.test.ts
index 53a4f1bf978..9a99d85aef6 100644
--- a/packages/features/delegation-credentials/repositories/DelegationCredentialRepository.test.ts
+++ b/packages/features/delegation-credentials/repositories/DelegationCredentialRepository.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, beforeEach, vi } from "vitest";
diff --git a/packages/features/ee/billing/service/teams/TeamBillingService.test.ts b/packages/features/ee/billing/service/teams/TeamBillingService.test.ts
index 59e54d61740..6e6605697e2 100644
--- a/packages/features/ee/billing/service/teams/TeamBillingService.test.ts
+++ b/packages/features/ee/billing/service/teams/TeamBillingService.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
diff --git a/packages/features/ee/billing/teams/internal-team-billing.test.ts b/packages/features/ee/billing/teams/internal-team-billing.test.ts
index 28501f2502e..dac7e034bdc 100644
--- a/packages/features/ee/billing/teams/internal-team-billing.test.ts
+++ b/packages/features/ee/billing/teams/internal-team-billing.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
diff --git a/packages/features/ee/common/server/LicenseKeyService.test.ts b/packages/features/ee/common/server/LicenseKeyService.test.ts
index 9390128bb0a..4aa27c083c5 100644
--- a/packages/features/ee/common/server/LicenseKeyService.test.ts
+++ b/packages/features/ee/common/server/LicenseKeyService.test.ts
@@ -1,4 +1,4 @@
-import "../../../../../tests/libs/__mocks__/prisma";
+import "@calcom/testing/lib/__mocks__/prisma";
import * as cache from "memory-cache";
import { describe, it, expect, beforeEach, vi, afterEach } from "vitest";
diff --git a/packages/features/ee/dsync/lib/assignValueToUser.test.ts b/packages/features/ee/dsync/lib/assignValueToUser.test.ts
index 955daf9833b..4c871a52eff 100644
--- a/packages/features/ee/dsync/lib/assignValueToUser.test.ts
+++ b/packages/features/ee/dsync/lib/assignValueToUser.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/features/ee/dsync/lib/handleUserEvents.test.ts b/packages/features/ee/dsync/lib/handleUserEvents.test.ts
index 944d8a1b06f..9742cceab31 100644
--- a/packages/features/ee/dsync/lib/handleUserEvents.test.ts
+++ b/packages/features/ee/dsync/lib/handleUserEvents.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import type { DirectorySyncEvent } from "@boxyhq/saml-jackson";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/features/ee/organizations/lib/service/onboarding/__tests__/BillingEnabledOrgOnboardingService.test.ts b/packages/features/ee/organizations/lib/service/onboarding/__tests__/BillingEnabledOrgOnboardingService.test.ts
index d1e878627b6..b9ddaba3af2 100644
--- a/packages/features/ee/organizations/lib/service/onboarding/__tests__/BillingEnabledOrgOnboardingService.test.ts
+++ b/packages/features/ee/organizations/lib/service/onboarding/__tests__/BillingEnabledOrgOnboardingService.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/features/ee/organizations/lib/service/onboarding/__tests__/SelfHostedOnboardingService.test.ts b/packages/features/ee/organizations/lib/service/onboarding/__tests__/SelfHostedOnboardingService.test.ts
index fef7ede407b..284dd45d5f3 100644
--- a/packages/features/ee/organizations/lib/service/onboarding/__tests__/SelfHostedOnboardingService.test.ts
+++ b/packages/features/ee/organizations/lib/service/onboarding/__tests__/SelfHostedOnboardingService.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/features/ee/organizations/repositories/OrganizationRepository.test.ts b/packages/features/ee/organizations/repositories/OrganizationRepository.test.ts
index 1fbef952d5d..a1b18bc7ce8 100644
--- a/packages/features/ee/organizations/repositories/OrganizationRepository.test.ts
+++ b/packages/features/ee/organizations/repositories/OrganizationRepository.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, it, expect, beforeEach, vi } from "vitest";
diff --git a/packages/features/ee/round-robin/roundRobinDeleteEvents.test.ts b/packages/features/ee/round-robin/roundRobinDeleteEvents.test.ts
index f86fdbfc977..c0142e296be 100644
--- a/packages/features/ee/round-robin/roundRobinDeleteEvents.test.ts
+++ b/packages/features/ee/round-robin/roundRobinDeleteEvents.test.ts
@@ -12,18 +12,18 @@ import {
getOrganizer,
getGoogleCalendarCredential,
mockCalendarToHaveNoBusySlots,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectBookingToBeInDatabase,
expectSuccessfulRoundRobinReschedulingEmails,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, expect } from "vitest";
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
import { SchedulingType, BookingStatus } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
describe("roundRobinReassignment test", () => {
setupAndTeardown();
diff --git a/packages/features/ee/round-robin/roundRobinManualReassignment.test.ts b/packages/features/ee/round-robin/roundRobinManualReassignment.test.ts
index 02d5ff60b93..192c6b2c326 100644
--- a/packages/features/ee/round-robin/roundRobinManualReassignment.test.ts
+++ b/packages/features/ee/round-robin/roundRobinManualReassignment.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
getDate,
@@ -7,20 +7,20 @@ import {
getMockBookingAttendee,
TestData,
addWorkflowReminders,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectBookingToBeInDatabase,
expectSuccessfulRoundRobinReschedulingEmails,
expectWorkflowToBeTriggered,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, vi, expect } from "vitest";
import { OrganizerDefaultConferencingAppType } from "@calcom/app-store/locations";
import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
import { SchedulingType, BookingStatus, WorkflowMethods } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
vi.mock("@calcom/features/bookings/lib/EventManager");
vi.mock("@calcom/app-store/utils", () => ({
diff --git a/packages/features/ee/round-robin/roundRobinReassignment.test.ts b/packages/features/ee/round-robin/roundRobinReassignment.test.ts
index 49dc590fb0c..d717da191cb 100644
--- a/packages/features/ee/round-robin/roundRobinReassignment.test.ts
+++ b/packages/features/ee/round-robin/roundRobinReassignment.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "@calcom/testing/lib/__mocks__/prisma";
import {
getDate,
@@ -7,19 +7,19 @@ import {
getMockBookingAttendee,
TestData,
addWorkflowReminders,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectBookingToBeInDatabase,
expectSuccessfulRoundRobinReschedulingEmails,
expectWorkflowToBeTriggered,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, vi, expect } from "vitest";
import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
import { SchedulingType, BookingStatus, WorkflowMethods } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
vi.mock("@calcom/features/bookings/lib/EventManager");
diff --git a/packages/features/ee/teams/lib/payments.test.ts b/packages/features/ee/teams/lib/payments.test.ts
index 62507743121..b98990ae5b9 100644
--- a/packages/features/ee/teams/lib/payments.test.ts
+++ b/packages/features/ee/teams/lib/payments.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
diff --git a/packages/features/ee/teams/repositories/TeamRepository.test.ts b/packages/features/ee/teams/repositories/TeamRepository.test.ts
index 9d56ec29f12..659d43add29 100644
--- a/packages/features/ee/teams/repositories/TeamRepository.test.ts
+++ b/packages/features/ee/teams/repositories/TeamRepository.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
diff --git a/packages/features/ee/teams/services/teamService.test.ts b/packages/features/ee/teams/services/teamService.test.ts
index cfa1c7c6df0..cb3ad49863f 100644
--- a/packages/features/ee/teams/services/teamService.test.ts
+++ b/packages/features/ee/teams/services/teamService.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
diff --git a/packages/features/ee/workflows/lib/reminders/reminderScheduler.test.ts b/packages/features/ee/workflows/lib/reminders/reminderScheduler.test.ts
index fbd3c98b024..f3d82c98f23 100644
--- a/packages/features/ee/workflows/lib/reminders/reminderScheduler.test.ts
+++ b/packages/features/ee/workflows/lib/reminders/reminderScheduler.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect, beforeEach, vi } from "vitest";
diff --git a/packages/features/ee/workflows/lib/service/WorkflowService.test.ts b/packages/features/ee/workflows/lib/service/WorkflowService.test.ts
index 8227470e07f..ec4ecda51fa 100644
--- a/packages/features/ee/workflows/lib/service/WorkflowService.test.ts
+++ b/packages/features/ee/workflows/lib/service/WorkflowService.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, vi, beforeEach } from "vitest";
import { scheduleWorkflowReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";
import { tasker } from "@calcom/features/tasker";
import { WorkflowTriggerEvents, WorkflowActions, WorkflowTemplates, TimeUnit } from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { WorkflowService } from "./WorkflowService";
diff --git a/packages/features/ee/workflows/lib/test/compareReminderBodyToTemplate.test.ts b/packages/features/ee/workflows/lib/test/compareReminderBodyToTemplate.test.ts
index 641cddfb9a9..74ca692ff6e 100644
--- a/packages/features/ee/workflows/lib/test/compareReminderBodyToTemplate.test.ts
+++ b/packages/features/ee/workflows/lib/test/compareReminderBodyToTemplate.test.ts
@@ -1,19 +1,39 @@
-import { createInstance } from "i18next";
import { vi, expect, test, describe } from "vitest";
import { getTranslation } from "@calcom/lib/server/i18n";
import { TimeFormat } from "@calcom/lib/timeFormat";
import { WorkflowActions, WorkflowTemplates } from "@calcom/prisma/enums";
-import en from "@calcom/web/public/static/locales/en/common.json";
+
+
import { getTemplateBodyForAction } from "../actionHelperFunctions";
import compareReminderBodyToTemplate from "../compareReminderBodyToTemplate";
import plainTextReminderTemplates from "../reminders/templates/plainTextTemplates";
+const tMock = (key: string) => {
+ const mocks: Record<string, string> = {
+ hi: "Hi",
+ reminder: "Reminder",
+ email_reminder_upcoming_event_notice: "This is a reminder about your upcoming event.",
+ event_upper_case: "Event",
+ date_and_time: "Date & Time",
+ attendees: "Attendees",
+ you_and_conjunction: "You &",
+ location: "Location",
+ scheduling_by: "Scheduling by",
+ experience_review_prompt: "How was your experience with",
+ improve_customer_experience_message: "We're always looking to improve our customer's experience.",
+ meeting_satisfaction_question: "How satisfied were you with your recent meeting?",
+ meeting_not_joined_question: "didn't join the meeting?",
+ reschedule_cta_short: "Reschedule here.",
+ };
+ return mocks[key] || key;
+};
+
vi.mock("@calcom/lib/server/i18n", () => {
return {
getTranslation: async (locale: string, namespace: string) => {
- const t = (key: string) => key;
+ const t = tMock as any;
t.locale = locale;
t.namespace = namespace;
return t;
@@ -21,18 +41,7 @@ vi.mock("@calcom/lib/server/i18n", () => {
};
});
-const translation = async () => {
- const _i18n = createInstance();
- await _i18n.init({
- lng: "en",
- resources: {
- en: {
- translation: en,
- },
- },
- });
- return _i18n.getFixedT("en");
-};
+const translation = async () => tMock as any;
describe("compareReminderBodyToTemplate", () => {
test("should return true if reminderBody and template are the same", () => {
diff --git a/packages/features/ee/workflows/lib/test/workflows.test.ts b/packages/features/ee/workflows/lib/test/workflows.test.ts
index 593aea91a86..6fd4feb6e15 100644
--- a/packages/features/ee/workflows/lib/test/workflows.test.ts
+++ b/packages/features/ee/workflows/lib/test/workflows.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import {
getOrganizer,
@@ -6,12 +6,12 @@ import {
TestData,
createBookingScenario,
createOrganization,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
import {
expectSMSWorkflowToBeTriggered,
expectSMSWorkflowToBeNotTriggered,
-} from "@calcom/web/test/utils/bookingScenario/expects";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/expects";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { v4 as uuidv4 } from "uuid";
import { describe, expect, beforeAll, vi, beforeEach } from "vitest";
@@ -29,7 +29,7 @@ import {
WorkflowTriggerEvents,
WorkflowActions,
} from "@calcom/prisma/enums";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { deleteWorkfowRemindersOfRemovedMember } from "../../../teams/lib/deleteWorkflowRemindersOfRemovedMember";
import { deleteRemindersOfActiveOnIds } from "../deleteRemindersOfActiveOnIds";
diff --git a/packages/features/ee/workflows/repositories/WorkflowRepository.test.ts b/packages/features/ee/workflows/repositories/WorkflowRepository.test.ts
index 50154c15c72..05228bc5043 100644
--- a/packages/features/ee/workflows/repositories/WorkflowRepository.test.ts
+++ b/packages/features/ee/workflows/repositories/WorkflowRepository.test.ts
@@ -1,5 +1,5 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect } from "vitest";
diff --git a/packages/features/eventtypes/lib/getEventTypeById.integration-test.ts b/packages/features/eventtypes/lib/getEventTypeById.integration-test.ts
index 6d7a1586787..337f7158a1e 100644
--- a/packages/features/eventtypes/lib/getEventTypeById.integration-test.ts
+++ b/packages/features/eventtypes/lib/getEventTypeById.integration-test.ts
@@ -1,8 +1,8 @@
import { prisma } from "@calcom/prisma"
import type { PrismaClient } from "@calcom/prisma";
-import i18nMock from "../../../../tests/libs/__mocks__/libServerI18n";
+import i18nMock from "@calcom/testing/lib/__mocks__/libServerI18n";
-// import { mockNoTranslations } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+// import { mockNoTranslations } from "@calcom/testing/lib/bookingScenario/bookingScenario";
import { describe, test, expect, beforeEach, afterEach, vi } from "vitest";
diff --git a/packages/features/flags/operations/check-if-user-has-feature.controller.test.ts b/packages/features/flags/operations/check-if-user-has-feature.controller.test.ts
index 225667dd83a..3ee3454fedd 100644
--- a/packages/features/flags/operations/check-if-user-has-feature.controller.test.ts
+++ b/packages/features/flags/operations/check-if-user-has-feature.controller.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { expect, it } from "vitest";
diff --git a/packages/features/flags/operations/check-if-user-has-feature.use-case.test.ts b/packages/features/flags/operations/check-if-user-has-feature.use-case.test.ts
index 78feb312f53..a7b87656934 100644
--- a/packages/features/flags/operations/check-if-user-has-feature.use-case.test.ts
+++ b/packages/features/flags/operations/check-if-user-has-feature.use-case.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { expect, it } from "vitest";
diff --git a/packages/features/insights/server/__tests__/events.test.ts b/packages/features/insights/server/__tests__/events.test.ts
index 076278615c1..168b9a13a71 100644
--- a/packages/features/insights/server/__tests__/events.test.ts
+++ b/packages/features/insights/server/__tests__/events.test.ts
@@ -1,4 +1,4 @@
-import "../../../../../tests/libs/__mocks__/prisma";
+import "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it } from "vitest";
diff --git a/packages/features/package.json b/packages/features/package.json
index 2cd6240b475..540a3330663 100644
--- a/packages/features/package.json
+++ b/packages/features/package.json
@@ -44,6 +44,7 @@
"zod": "^3.0.0"
},
"devDependencies": {
+ "@calcom/testing": "workspace:*",
"@testing-library/react-hooks": "8.0.1",
"@types/web-push": "3.6.3",
"trigger.dev": "4.3.1"
diff --git a/packages/features/pbac/lib/team-member-permissions.ts b/packages/features/pbac/lib/team-member-permissions.ts
index 11baf62bd14..473642b9abb 100644
--- a/packages/features/pbac/lib/team-member-permissions.ts
+++ b/packages/features/pbac/lib/team-member-permissions.ts
@@ -1,9 +1,18 @@
import { MembershipRole } from "@calcom/prisma/enums";
-import type { MemberPermissions } from "@calcom/web/modules/users/components/UserTable/types";
import { Resource, CustomAction } from "../domain/types/permission-registry";
import { getSpecificPermissions } from "./resource-permissions";
+export interface MemberPermissions {
+ canListMembers: boolean;
+ canInvite: boolean;
+ canChangeMemberRole: boolean;
+ canRemove: boolean;
+ canImpersonate: boolean;
+ canEditAttributesForUser?: boolean;
+ canViewAttributes?: boolean;
+}
+
interface TeamWithMembership {
id: number;
isPrivate: boolean;
diff --git a/packages/features/profile/repositories/ProfileRepository.test.ts b/packages/features/profile/repositories/ProfileRepository.test.ts
index 08417cdd431..723c68fdb26 100644
--- a/packages/features/profile/repositories/ProfileRepository.test.ts
+++ b/packages/features/profile/repositories/ProfileRepository.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, it, expect, beforeEach, vi } from "vitest";
diff --git a/packages/features/schedules/repositories/ScheduleRepository.test.ts b/packages/features/schedules/repositories/ScheduleRepository.test.ts
index 495bc03a71c..6a2db4fb4b4 100644
--- a/packages/features/schedules/repositories/ScheduleRepository.test.ts
+++ b/packages/features/schedules/repositories/ScheduleRepository.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/features/slots/handleNotificationWhenNoSlots.test.ts b/packages/features/slots/handleNotificationWhenNoSlots.test.ts
index 1a753e417da..d2c6d86b444 100644
--- a/packages/features/slots/handleNotificationWhenNoSlots.test.ts
+++ b/packages/features/slots/handleNotificationWhenNoSlots.test.ts
@@ -1,5 +1,5 @@
-import i18nMock from "../../../tests/libs/__mocks__/libServerI18n";
-import prismaMock from "../../../tests/libs/__mocks__/prismaMock";
+import i18nMock from "@calcom/testing/lib/__mocks__/libServerI18n";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { vi, describe, it, beforeAll, afterAll, expect, beforeEach, afterEach } from "vitest";
diff --git a/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts b/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts
index e3689dc4aa6..59e639ce544 100644
--- a/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts
+++ b/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, beforeEach, vi } from "vitest";
diff --git a/packages/features/tasker/tasks/scanWorkflowBody.test.ts b/packages/features/tasker/tasks/scanWorkflowBody.test.ts
index c26508b782f..5a2d20d9d53 100644
--- a/packages/features/tasker/tasks/scanWorkflowBody.test.ts
+++ b/packages/features/tasker/tasks/scanWorkflowBody.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWebhook.test.ts b/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWebhook.test.ts
index 7ff9dbb10f6..8761f287998 100644
--- a/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWebhook.test.ts
+++ b/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWebhook.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, beforeEach, vi } from "vitest";
diff --git a/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWorkflow.test.ts b/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWorkflow.test.ts
index aa52506256a..2f2949d6eec 100644
--- a/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWorkflow.test.ts
+++ b/packages/features/tasker/tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWorkflow.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, beforeEach, vi } from "vitest";
import type { z } from "zod";
diff --git a/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.test.ts b/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.test.ts
index 12443c869e0..4bfadc83fa8 100644
--- a/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.test.ts
+++ b/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.test.ts
@@ -5,9 +5,9 @@ import {
TestData,
getOrganizer,
getScenarioData,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectWebhookToHaveBeenCalledWith } from "@calcom/web/test/utils/bookingScenario/expects";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectWebhookToHaveBeenCalledWith } from "@calcom/testing/lib/bookingScenario/expects";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, vi, test, expect } from "vitest";
diff --git a/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts b/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts
index 2cd9dc845fa..d677f263e3e 100644
--- a/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts
+++ b/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts
@@ -5,9 +5,9 @@ import {
TestData,
getOrganizer,
getScenarioData,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
-import { expectWebhookToHaveBeenCalledWith } from "@calcom/web/test/utils/bookingScenario/expects";
-import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
+} from "@calcom/testing/lib/bookingScenario/bookingScenario";
+import { expectWebhookToHaveBeenCalledWith } from "@calcom/testing/lib/bookingScenario/expects";
+import { setupAndTeardown } from "@calcom/testing/lib/bookingScenario/setupAndTeardown";
import { describe, vi, test, expect } from "vitest";
diff --git a/packages/features/users/repositories/UserRepository.test.ts b/packages/features/users/repositories/UserRepository.test.ts
index 10c26ae85bf..8b281341269 100644
--- a/packages/features/users/repositories/UserRepository.test.ts
+++ b/packages/features/users/repositories/UserRepository.test.ts
@@ -1,5 +1,5 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, test, vi, expect, beforeEach } from "vitest";
diff --git a/packages/features/watchlist/lib/testUtils.ts b/packages/features/watchlist/lib/testUtils.ts
index ed2d6b173ac..b377a163d42 100644
--- a/packages/features/watchlist/lib/testUtils.ts
+++ b/packages/features/watchlist/lib/testUtils.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import type { WatchlistType } from "@calcom/prisma/enums";
diff --git a/packages/features/webhooks/lib/test/webhooks.test.ts b/packages/features/webhooks/lib/test/webhooks.test.ts
index ae3d407504b..f2fba10b6e2 100644
--- a/packages/features/webhooks/lib/test/webhooks.test.ts
+++ b/packages/features/webhooks/lib/test/webhooks.test.ts
@@ -1,11 +1,11 @@
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
-import { expectWebhookToHaveBeenCalledWith } from "@calcom/web/test/utils/bookingScenario/expects";
+import { expectWebhookToHaveBeenCalledWith } from "@calcom/testing/lib/bookingScenario/expects";
import { describe, expect, beforeEach } from "vitest";
import dayjs from "@calcom/dayjs";
-import { test } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "@calcom/testing/lib/fixtures/fixtures";
import { handleWebhookScheduledTriggers } from "../handleWebhookScheduledTriggers";
diff --git a/packages/lib/server/repository/HolidayRepository.test.ts b/packages/lib/server/repository/HolidayRepository.test.ts
index db23afe8d03..d44cb2750d5 100644
--- a/packages/lib/server/repository/HolidayRepository.test.ts
+++ b/packages/lib/server/repository/HolidayRepository.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { beforeEach, describe, expect, it, vi } from "vitest";
diff --git a/packages/lib/server/repository/selectedCalendar.test.ts b/packages/lib/server/repository/selectedCalendar.test.ts
index e356e4dd072..8690d579dc4 100644
--- a/packages/lib/server/repository/selectedCalendar.test.ts
+++ b/packages/lib/server/repository/selectedCalendar.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, beforeEach } from "vitest";
diff --git a/packages/lib/server/username.test.ts b/packages/lib/server/username.test.ts
index 480dd3ef0cf..c857a1a2664 100644
--- a/packages/lib/server/username.test.ts
+++ b/packages/lib/server/username.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, beforeEach } from "vitest";
diff --git a/packages/platform/atoms/calendar-view/CalendarViewComponent.tsx b/packages/platform/atoms/calendar-view/CalendarViewComponent.tsx
index 75f23773aee..946c40b177f 100644
--- a/packages/platform/atoms/calendar-view/CalendarViewComponent.tsx
+++ b/packages/platform/atoms/calendar-view/CalendarViewComponent.tsx
@@ -1,6 +1,6 @@
import { Header } from "@calcom/web/modules/bookings/components/Header";
import { BookerSection } from "@calcom/web/modules/bookings/components/Section";
-import { LargeCalendar } from "@calcom/features/calendar-view/LargeCalendar";
+import { LargeCalendar } from "@calcom/web/modules/calendar-view/components/LargeCalendar";
import { bookerLayoutOptions } from "@calcom/prisma/zod-utils";
import { AtomsWrapper } from "../src/components/atoms-wrapper";
diff --git a/packages/platform/atoms/calendar-view/EventTypeCalendarViewComponent.tsx b/packages/platform/atoms/calendar-view/EventTypeCalendarViewComponent.tsx
index 7e3e921d6e0..816ef0b3679 100644
--- a/packages/platform/atoms/calendar-view/EventTypeCalendarViewComponent.tsx
+++ b/packages/platform/atoms/calendar-view/EventTypeCalendarViewComponent.tsx
@@ -10,7 +10,7 @@ import { BookerSection } from "@calcom/web/modules/bookings/components/Section";
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/components/hooks/useAvailableTimeSlots";
import { useBookerLayout } from "@calcom/features/bookings/Booker/components/hooks/useBookerLayout";
import { useTimePreferences } from "@calcom/features/bookings/lib";
-import { LargeCalendar } from "@calcom/features/calendar-view/LargeCalendar";
+import { LargeCalendar } from "@calcom/web/modules/calendar-view/components/LargeCalendar";
import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents";
import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule";
diff --git a/packages/platform/atoms/package.json b/packages/platform/atoms/package.json
index 14e8d1af194..ee7096ad495 100644
--- a/packages/platform/atoms/package.json
+++ b/packages/platform/atoms/package.json
@@ -64,8 +64,11 @@
"./dist/index.d.ts": "./dist/index.d.ts",
"./event-types/wrappers/EventTypeWebWrapper": "./event-types/wrappers/EventTypeWebWrapper.tsx",
"./globals.min.css": "./globals.min.css",
+ "./hooks/bookings/useBookings": "./hooks/bookings/useBookings.ts",
"./hooks/bookings/useHandleBookEvent": "./hooks/bookings/useHandleBookEvent.ts",
"./hooks/useAtomsContext": "./hooks/useAtomsContext.ts",
+ "./hooks/useCalendarsBusyTimes": "./hooks/useCalendarsBusyTimes.ts",
+ "./hooks/useConnectedCalendars": "./hooks/useConnectedCalendars.tsx",
"./hooks/useIsPlatform": "./hooks/useIsPlatform.ts",
"./hooks/useIsPlatformBookerEmbed": "./hooks/useIsPlatformBookerEmbed.ts",
"./hooks/event-types/private/useEventTypeById": "./hooks/event-types/private/useEventTypeById.ts",
diff --git a/packages/testing/package.json b/packages/testing/package.json
new file mode 100644
index 00000000000..8e27dc90420
--- /dev/null
+++ b/packages/testing/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "@calcom/testing",
+ "version": "0.0.0",
+ "private": true,
+ "exports": {
+ "./setupVitest": "./src/setupVitest.ts",
+ "./lib/*": "./src/lib/*",
+ "./lib/__mocks__/*": "./src/lib/__mocks__/*",
+ "./lib/bookingScenario/*": "./src/lib/bookingScenario/*",
+ "./lib/fixtures/*": "./src/lib/fixtures/*"
+ },
+ "scripts": {
+ "lint": "biome lint .",
+ "lint:fix": "biome lint --write .",
+ "lint:report": "biome lint --reporter json . > ../../lint-results/testing.json"
+ },
+ "dependencies": {
+ "@calcom/lib": "workspace:*",
+ "@calcom/prisma": "workspace:*"
+ },
+ "devDependencies": {
+ "@biomejs/biome": "2.3.10",
+ "@calcom/tsconfig": "workspace:*",
+ "prismock": "1.35.3",
+ "vitest": "4.0.16"
+ }
+}
\ No newline at end of file
diff --git a/tests/performance/README.md b/packages/testing/performance/README.md
similarity index 100%
rename from tests/performance/README.md
rename to packages/testing/performance/README.md
diff --git a/tests/performance/load/booking.js b/packages/testing/performance/load/booking.js
similarity index 100%
rename from tests/performance/load/booking.js
rename to packages/testing/performance/load/booking.js
diff --git a/tests/performance/smoke/booking.js b/packages/testing/performance/smoke/booking.js
similarity index 100%
rename from tests/performance/smoke/booking.js
rename to packages/testing/performance/smoke/booking.js
diff --git a/tests/performance/spike/booking.js b/packages/testing/performance/spike/booking.js
similarity index 100%
rename from tests/performance/spike/booking.js
rename to packages/testing/performance/spike/booking.js
diff --git a/tests/performance/stress/booking.js b/packages/testing/performance/stress/booking.js
similarity index 100%
rename from tests/performance/stress/booking.js
rename to packages/testing/performance/stress/booking.js
diff --git a/tests/performance/utils/config.js b/packages/testing/performance/utils/config.js
similarity index 100%
rename from tests/performance/utils/config.js
rename to packages/testing/performance/utils/config.js
diff --git a/tests/performance/utils/helpers.js b/packages/testing/performance/utils/helpers.js
similarity index 100%
rename from tests/performance/utils/helpers.js
rename to packages/testing/performance/utils/helpers.js
diff --git a/tests/scripts/run-k6-local.sh b/packages/testing/scripts/run-k6-local.sh
similarity index 100%
rename from tests/scripts/run-k6-local.sh
rename to packages/testing/scripts/run-k6-local.sh
diff --git a/tests/libs/__mocks__/libServerI18n.ts b/packages/testing/src/lib/__mocks__/libServerI18n.ts
similarity index 100%
rename from tests/libs/__mocks__/libServerI18n.ts
rename to packages/testing/src/lib/__mocks__/libServerI18n.ts
diff --git a/tests/libs/__mocks__/prisma.ts b/packages/testing/src/lib/__mocks__/prisma.ts
similarity index 95%
rename from tests/libs/__mocks__/prisma.ts
rename to packages/testing/src/lib/__mocks__/prisma.ts
index 6978f8af46c..d21bb372bf5 100644
--- a/tests/libs/__mocks__/prisma.ts
+++ b/packages/testing/src/lib/__mocks__/prisma.ts
@@ -20,8 +20,6 @@ const handlePrismockBugs = (prismock: any) => {
rest[0].where = undefined;
logger.silly("Fixed Prismock bug-2");
}
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
return __findManyWebhook(...rest);
};
};
@@ -108,8 +106,6 @@ vi.mock("@calcom/prisma", async (importOriginal) => {
beforeEach(() => {
if (prismockInstance) {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
prismockInstance.reset();
handlePrismockBugs(prismockInstance);
}
diff --git a/tests/libs/__mocks__/prismaMock.ts b/packages/testing/src/lib/__mocks__/prismaMock.ts
similarity index 82%
rename from tests/libs/__mocks__/prismaMock.ts
rename to packages/testing/src/lib/__mocks__/prismaMock.ts
index 16f9f9868cf..1a4233003c2 100644
--- a/tests/libs/__mocks__/prismaMock.ts
+++ b/packages/testing/src/lib/__mocks__/prismaMock.ts
@@ -1,5 +1,5 @@
import { beforeEach, vi } from "vitest";
-import { DeepMockProxy, mockDeep, mockReset } from "vitest-mock-extended";
+import { type DeepMockProxy, mockDeep, mockReset } from "vitest-mock-extended";
import type { PrismaClient } from "@calcom/prisma";
diff --git a/apps/web/test/utils/bookingScenario/MockPaymentService.ts b/packages/testing/src/lib/bookingScenario/MockPaymentService.ts
similarity index 97%
rename from apps/web/test/utils/bookingScenario/MockPaymentService.ts
rename to packages/testing/src/lib/bookingScenario/MockPaymentService.ts
index 4ae9633afac..96ba63316e7 100644
--- a/apps/web/test/utils/bookingScenario/MockPaymentService.ts
+++ b/packages/testing/src/lib/bookingScenario/MockPaymentService.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "../__mocks__/prisma";
import "vitest-fetch-mock";
@@ -16,7 +16,7 @@ export function getMockPaymentService() {
const externalId = "mock_payment_external_id";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
+ // @ts-expect-error
class MockPaymentService implements IAbstractPaymentService {
// TODO: We shouldn't need to implement adding a row to Payment table but that's a requirement right now.
// We should actually delegate table creation to the core app. Here, only the payment app specific logic should come
diff --git a/apps/web/test/utils/bookingScenario/bookingScenario.ts b/packages/testing/src/lib/bookingScenario/bookingScenario.ts
similarity index 96%
rename from apps/web/test/utils/bookingScenario/bookingScenario.ts
rename to packages/testing/src/lib/bookingScenario/bookingScenario.ts
index dc8ab938aeb..841b66840a7 100644
--- a/apps/web/test/utils/bookingScenario/bookingScenario.ts
+++ b/packages/testing/src/lib/bookingScenario/bookingScenario.ts
@@ -1,22 +1,17 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
-import i18nMock from "../../../../../tests/libs/__mocks__/libServerI18n";
-import prismock from "../../../../../tests/libs/__mocks__/prisma";
+import i18nMock from "../__mocks__/libServerI18n";
+import prismock from "../__mocks__/prisma";
-import type Stripe from "stripe";
import { v4 as uuidv4 } from "uuid";
import { vi } from "vitest";
import "vitest-fetch-mock";
import type { z } from "zod";
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
-import { handleStripePaymentSuccess } from "@calcom/features/ee/payments/api/webhook";
-import { ProfileRepository } from "@calcom/features/profile/repositories/ProfileRepository";
import { weekdayToWeekIndex, type WeekDays } from "@calcom/lib/dayjs";
-import type { HttpError } from "@calcom/lib/http-error";
import type { IntervalLimit } from "@calcom/lib/intervalLimits/intervalLimitSchema";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
-import { distributedTracing } from "@calcom/lib/tracing/factory";
import type { BookingReference, Attendee, Booking, Membership } from "@calcom/prisma/client";
import type { Prisma } from "@calcom/prisma/client";
import type { WebhookTriggerEvents } from "@calcom/prisma/client";
@@ -641,13 +636,13 @@ export async function addBookings(bookings: InputBooking[]) {
await addBookingsToDb(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
allBookings.map((booking) => {
const bookingCreate = booking;
if (booking.references) {
bookingCreate.references = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
createMany: {
data: booking.references,
},
@@ -656,7 +651,7 @@ export async function addBookings(bookings: InputBooking[]) {
if (booking.attendees) {
bookingCreate.attendees = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
createMany: {
data: booking.attendees.map((attendee) => {
if (attendee.bookingSeat) {
@@ -678,7 +673,7 @@ export async function addBookings(bookings: InputBooking[]) {
if (booking?.user?.id) {
bookingCreate.user = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
connect: {
id: booking.user.id,
},
@@ -910,7 +905,7 @@ export async function addUsers(users: InputUser[]) {
if (user.schedules) {
newUser.schedules = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
+ // @ts-expect-error
createMany: {
data: user.schedules.map((schedule) => {
return {
@@ -928,7 +923,7 @@ export async function addUsers(users: InputUser[]) {
if (user.credentials) {
newUser.credentials = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
createMany: {
data: user.credentials,
},
@@ -939,7 +934,7 @@ export async function addUsers(users: InputUser[]) {
const addedTeams = await addTeamsToDb(user.teams.map((team) => team.team));
newUser.teams = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
createMany: {
data: user.teams.map((team, index) => {
return {
@@ -953,7 +948,7 @@ export async function addUsers(users: InputUser[]) {
if (user.selectedCalendars) {
newUser.selectedCalendars = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
createMany: {
data: user.selectedCalendars,
},
@@ -962,7 +957,7 @@ export async function addUsers(users: InputUser[]) {
if (user.destinationCalendar) {
newUser.destinationCalendar = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
create: user.destinationCalendar,
};
}
@@ -977,8 +972,6 @@ export async function addUsers(users: InputUser[]) {
prismaUsersCreate.push(newUser);
}
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
return await addUsersToDb(prismaUsersCreate);
}
@@ -1462,8 +1455,6 @@ export const TestData = {
apps: {
"google-calendar": {
...appStoreMetadata.googlecalendar,
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
keys: {
expiry_date: Infinity,
client_id: "client_id",
@@ -1473,8 +1464,6 @@ export const TestData = {
},
"office365-calendar": {
...appStoreMetadata.office365calendar,
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
keys: {
expiry_date: Infinity,
client_id: "client_id",
@@ -1483,8 +1472,6 @@ export const TestData = {
},
"google-meet": {
...appStoreMetadata.googlevideo,
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
keys: {
expiry_date: Infinity,
client_id: "client_id",
@@ -1494,8 +1481,6 @@ export const TestData = {
},
"daily-video": {
...appStoreMetadata.dailyvideo,
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
keys: {
expiry_date: Infinity,
api_key: "",
@@ -1507,8 +1492,6 @@ export const TestData = {
},
zoomvideo: {
...appStoreMetadata.zoomvideo,
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
keys: {
expiry_date: Infinity,
api_key: "",
@@ -1520,8 +1503,6 @@ export const TestData = {
},
"stripe-payment": {
...appStoreMetadata.stripepayment,
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
keys: {
expiry_date: Infinity,
api_key: "",
@@ -1654,7 +1635,7 @@ export function getScenarioData(
{
organizationId: orgId,
username: profileUsername,
- uid: ProfileRepository.generateProfileUid(),
+ uid: uuidv4(),
},
];
});
@@ -2208,6 +2189,7 @@ export function mockCrmApp(
}[] = [];
const eventsCreated: boolean[] = [];
+ // Mock the CrmServiceMap directly instead of using the old app-store index approach
vi.doMock("@calcom/app-store/crm.apps.generated", async (importOriginal) => {
const original = await importOriginal<typeof import("@calcom/app-store/crm.apps.generated")>();
@@ -2219,17 +2201,16 @@ export function mockCrmApp(
createContact() {
if (crmData?.createContacts) {
contactsCreated = crmData.createContacts;
- return Promise.resolve(crmData.createContacts);
+ return Promise.resolve(crmData?.createContacts);
}
return Promise.resolve([]);
}
getContacts(email: string) {
if (crmData?.getContacts) {
- contactsQueried = crmData.getContacts;
- return Promise.resolve(
- contactsQueried.filter((c) => c.email === email)
- );
+ contactsQueried = crmData?.getContacts;
+ const contactsOfEmail = contactsQueried.filter((contact) => contact.email === email);
+ return Promise.resolve(contactsOfEmail);
}
return Promise.resolve([]);
}
@@ -2244,28 +2225,20 @@ export function mockCrmApp(
...original,
CrmServiceMap: {
...original.CrmServiceMap,
- // ✅ IMPORTANT: no Promise here
- [metadataLookupKey]: {
+ [metadataLookupKey]: Promise.resolve({
default: MockCrmService,
- },
+ }),
},
};
});
return {
- get contactsCreated() {
- return contactsCreated;
- },
- get contactsQueried() {
- return contactsQueried;
- },
- get eventsCreated() {
- return eventsCreated;
- },
+ contactsCreated,
+ contactsQueried,
+ eventsCreated,
};
}
-
export function getBooker({
name,
email,
@@ -2282,32 +2255,6 @@ export function getBooker({
};
}
-export function getMockedStripePaymentEvent({ paymentIntentId }: { paymentIntentId: string }) {
- return {
- id: null,
- data: {
- object: {
- id: paymentIntentId,
- },
- },
- } as unknown as Stripe.Event;
-}
-
-export async function mockPaymentSuccessWebhookFromStripe({ externalId }: { externalId: string }) {
- let webhookResponse = null;
- try {
- const traceContext = distributedTracing.createTrace("test_stripe_webhook");
- await handleStripePaymentSuccess(
- getMockedStripePaymentEvent({ paymentIntentId: externalId }),
- traceContext
- );
- } catch (e) {
- log.silly("mockPaymentSuccessWebhookFromStripe:catch", JSON.stringify(e));
- webhookResponse = e as HttpError;
- }
- return { webhookResponse };
-}
-
export function getExpectedCalEventForBookingRequest({
bookingRequest,
eventType,
diff --git a/apps/web/test/utils/bookingScenario/createMockNextJsRequest.ts b/packages/testing/src/lib/bookingScenario/createMockNextJsRequest.ts
similarity index 100%
rename from apps/web/test/utils/bookingScenario/createMockNextJsRequest.ts
rename to packages/testing/src/lib/bookingScenario/createMockNextJsRequest.ts
diff --git a/apps/web/test/utils/bookingScenario/expects.ts b/packages/testing/src/lib/bookingScenario/expects.ts
similarity index 99%
rename from apps/web/test/utils/bookingScenario/expects.ts
rename to packages/testing/src/lib/bookingScenario/expects.ts
index a381cde4341..6cdc8fefb37 100644
--- a/apps/web/test/utils/bookingScenario/expects.ts
+++ b/packages/testing/src/lib/bookingScenario/expects.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../tests/libs/__mocks__/prisma";
+import prismaMock from "../__mocks__/prisma";
import type { InputEventType, getOrganizer, CalendarServiceMethodMock } from "./bookingScenario";
@@ -9,7 +9,7 @@ import { expect, vi } from "vitest";
import "vitest-fetch-mock";
import dayjs from "@calcom/dayjs";
-import type { Tracking } from "@calcom/features/bookings/lib/handleNewBooking/types";
+import type { Tracking } from "../types";
import { WEBSITE_URL } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
@@ -23,7 +23,7 @@ import { BookingStatus } from "@calcom/prisma/enums";
import type { AppsStatus } from "@calcom/types/Calendar";
import type { CalendarEvent } from "@calcom/types/Calendar";
import type { CredentialForCalendarService } from "@calcom/types/Credential";
-import type { Fixtures } from "@calcom/web/test/fixtures/fixtures";
+import type { Fixtures } from "../fixtures/fixtures";
import { DEFAULT_TIMEZONE_BOOKER } from "./getMockRequestDataForBooking";
@@ -185,7 +185,7 @@ expect.extend({
return {
pass: false,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
+ //@ts-expect-error
actual: icsObject[icsKey].uid!,
expected: expectedEmail.ics?.iCalUID,
message: () => `Expected ICS UID ${isNot ? "is" : "isn't"} present in actual`,
diff --git a/apps/web/test/utils/bookingScenario/getMockRequestDataForBooking.ts b/packages/testing/src/lib/bookingScenario/getMockRequestDataForBooking.ts
similarity index 91%
rename from apps/web/test/utils/bookingScenario/getMockRequestDataForBooking.ts
rename to packages/testing/src/lib/bookingScenario/getMockRequestDataForBooking.ts
index b112c069146..739f1fc3b56 100644
--- a/apps/web/test/utils/bookingScenario/getMockRequestDataForBooking.ts
+++ b/packages/testing/src/lib/bookingScenario/getMockRequestDataForBooking.ts
@@ -1,6 +1,6 @@
-import { getDate } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+import { getDate } from "./bookingScenario";
-import type { Tracking } from "@calcom/features/bookings/lib/handleNewBooking/types";
+import type { Tracking } from "../types";
import type { SchedulingType } from "@calcom/prisma/client";
import type { CreationSource } from "@calcom/prisma/enums";
diff --git a/apps/web/test/utils/bookingScenario/getMockRequestDataForCancelBooking.ts b/packages/testing/src/lib/bookingScenario/getMockRequestDataForCancelBooking.ts
similarity index 100%
rename from apps/web/test/utils/bookingScenario/getMockRequestDataForCancelBooking.ts
rename to packages/testing/src/lib/bookingScenario/getMockRequestDataForCancelBooking.ts
diff --git a/apps/web/test/utils/bookingScenario/getSampleUserInSession.ts b/packages/testing/src/lib/bookingScenario/getSampleUserInSession.ts
similarity index 100%
rename from apps/web/test/utils/bookingScenario/getSampleUserInSession.ts
rename to packages/testing/src/lib/bookingScenario/getSampleUserInSession.ts
diff --git a/apps/web/test/utils/bookingScenario/setupAndTeardown.ts b/packages/testing/src/lib/bookingScenario/setupAndTeardown.ts
similarity index 91%
rename from apps/web/test/utils/bookingScenario/setupAndTeardown.ts
rename to packages/testing/src/lib/bookingScenario/setupAndTeardown.ts
index 26c7011db68..a12f009b8f5 100644
--- a/apps/web/test/utils/bookingScenario/setupAndTeardown.ts
+++ b/packages/testing/src/lib/bookingScenario/setupAndTeardown.ts
@@ -1,7 +1,4 @@
-import {
- enableEmailFeature,
- mockNoTranslations,
-} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+import { enableEmailFeature, mockNoTranslations } from "./bookingScenario";
import { beforeEach, afterEach } from "vitest";
diff --git a/apps/web/test/utils/bookingScenario/test.ts b/packages/testing/src/lib/bookingScenario/test.ts
similarity index 88%
rename from apps/web/test/utils/bookingScenario/test.ts
rename to packages/testing/src/lib/bookingScenario/test.ts
index 890ce3461a6..ff2783a0b6f 100644
--- a/apps/web/test/utils/bookingScenario/test.ts
+++ b/packages/testing/src/lib/bookingScenario/test.ts
@@ -1,8 +1,8 @@
-import { createOrganization } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+import { createOrganization } from "./bookingScenario";
import { WEBSITE_URL } from "@calcom/lib/constants";
-import { test } from "@calcom/web/test/fixtures/fixtures";
-import type { Fixtures } from "@calcom/web/test/fixtures/fixtures";
+import { test } from "../fixtures/fixtures";
+import type { Fixtures } from "../fixtures/fixtures";
type OrgContext = {
org: {
diff --git a/apps/web/test/utils/bookingScenario/types.d.ts b/packages/testing/src/lib/bookingScenario/types.d.ts
similarity index 100%
rename from apps/web/test/utils/bookingScenario/types.d.ts
rename to packages/testing/src/lib/bookingScenario/types.d.ts
diff --git a/apps/web/test/fixtures/fixtures.ts b/packages/testing/src/lib/fixtures/fixtures.ts
similarity index 100%
rename from apps/web/test/fixtures/fixtures.ts
rename to packages/testing/src/lib/fixtures/fixtures.ts
diff --git a/packages/testing/src/lib/types.ts b/packages/testing/src/lib/types.ts
new file mode 100644
index 00000000000..1c92c2bd6e5
--- /dev/null
+++ b/packages/testing/src/lib/types.ts
@@ -0,0 +1,11 @@
+/**
+ * Tracking type for UTM parameters in booking requests.
+ * Cloned from @calcom/features/bookings/lib/handleNewBooking/types to avoid circular dependency.
+ */
+export type Tracking = {
+ utm_source?: string;
+ utm_medium?: string;
+ utm_campaign?: string;
+ utm_term?: string;
+ utm_content?: string;
+};
diff --git a/setupVitest.ts b/packages/testing/src/setupVitest.ts
similarity index 97%
rename from setupVitest.ts
rename to packages/testing/src/setupVitest.ts
index 5d7e1f65e79..1c2e7d8e597 100644
--- a/setupVitest.ts
+++ b/packages/testing/src/setupVitest.ts
@@ -77,7 +77,7 @@ class MockPaymentService {
selectedEventTypeTitle?: string,
eventTitle?: string
) {
- const { default: prismaMock } = await import("./tests/libs/__mocks__/prisma");
+ const { default: prismaMock } = await import("@calcom/testing/lib/__mocks__/prisma");
const externalId = "mock_payment_external_id";
const paymentCreateData = {
diff --git a/packages/testing/tsconfig.json b/packages/testing/tsconfig.json
new file mode 100644
index 00000000000..dfd82dba164
--- /dev/null
+++ b/packages/testing/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "extends": "@calcom/tsconfig/base.json",
+ "compilerOptions": {
+ "target": "es5",
+ "jsx": "preserve",
+ "resolveJsonModule": true
+ },
+ "include": ["."],
+ "exclude": ["dist", "build", "**/node_modules/**"]
+}
diff --git a/packages/trpc/server/routers/viewer/availability/schedule/getAllSchedulesByUserId.handler.test.ts b/packages/trpc/server/routers/viewer/availability/schedule/getAllSchedulesByUserId.handler.test.ts
index cba36aa890a..5faa3a34edf 100644
--- a/packages/trpc/server/routers/viewer/availability/schedule/getAllSchedulesByUserId.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/availability/schedule/getAllSchedulesByUserId.handler.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, beforeEach, vi, expect } from "vitest";
diff --git a/packages/trpc/server/routers/viewer/eventTypes/heavy/duplicate.handler.test.ts b/packages/trpc/server/routers/viewer/eventTypes/heavy/duplicate.handler.test.ts
index 8cb624797f7..60b70dc46ec 100644
--- a/packages/trpc/server/routers/viewer/eventTypes/heavy/duplicate.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/eventTypes/heavy/duplicate.handler.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
import { describe, it, expect, vi, beforeEach } from "vitest";
diff --git a/packages/trpc/server/routers/viewer/oAuth/generateAuthCode.handler.test.ts b/packages/trpc/server/routers/viewer/oAuth/generateAuthCode.handler.test.ts
index d5dabe207af..0e813793e72 100644
--- a/packages/trpc/server/routers/viewer/oAuth/generateAuthCode.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/oAuth/generateAuthCode.handler.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/trpc/server/routers/viewer/organizations/__tests__/createTeams.handler.test.ts b/packages/trpc/server/routers/viewer/organizations/__tests__/createTeams.handler.test.ts
index af4c7618909..5f39c85a649 100644
--- a/packages/trpc/server/routers/viewer/organizations/__tests__/createTeams.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/organizations/__tests__/createTeams.handler.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, beforeEach, vi } from "vitest";
diff --git a/packages/trpc/server/routers/viewer/organizations/bulkDeleteUsers.test.ts b/packages/trpc/server/routers/viewer/organizations/bulkDeleteUsers.test.ts
index 74b86b70d74..5aac6923728 100644
--- a/packages/trpc/server/routers/viewer/organizations/bulkDeleteUsers.test.ts
+++ b/packages/trpc/server/routers/viewer/organizations/bulkDeleteUsers.test.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
// TODO: Bring this test back with the correct setup (no illegal imports)
-import prismock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, it, beforeEach, vi, expect } from "vitest";
diff --git a/packages/trpc/server/routers/viewer/organizations/create.handler.test.ts b/packages/trpc/server/routers/viewer/organizations/create.handler.test.ts
index 4b3f30c9baa..7373ade39d4 100644
--- a/packages/trpc/server/routers/viewer/organizations/create.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/organizations/create.handler.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { describe, expect, it, vi, beforeEach } from "vitest";
import { UserPermissionRole } from "@calcom/prisma/enums";
diff --git a/packages/trpc/server/routers/viewer/organizations/createWithPaymentIntent.handler.test.ts b/packages/trpc/server/routers/viewer/organizations/createWithPaymentIntent.handler.test.ts
index 4f6bc5593f0..7927f8fca83 100644
--- a/packages/trpc/server/routers/viewer/organizations/createWithPaymentIntent.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/organizations/createWithPaymentIntent.handler.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { v4 as uuidv4 } from "uuid";
import { describe, expect, it, vi, beforeEach } from "vitest";
diff --git a/packages/trpc/server/routers/viewer/organizations/intentToCreateOrg.handler.test.ts b/packages/trpc/server/routers/viewer/organizations/intentToCreateOrg.handler.test.ts
index c707c6783b0..33bee5b9f29 100644
--- a/packages/trpc/server/routers/viewer/organizations/intentToCreateOrg.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/organizations/intentToCreateOrg.handler.test.ts
@@ -1,4 +1,4 @@
-import prismock from "../../../../../../tests/libs/__mocks__/prisma";
+import prismock from "@calcom/testing/lib/__mocks__/prisma";
import { intentToCreateOrgHandler } from "./intentToCreateOrg.handler";
import { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { OrganizationPaymentService } from "@calcom/features/ee/organizations/lib/OrganizationPaymentService";
diff --git a/packages/trpc/server/routers/viewer/teams/getUpgradeable.test.ts b/packages/trpc/server/routers/viewer/teams/getUpgradeable.test.ts
index 89dba252f34..c84f89207db 100644
--- a/packages/trpc/server/routers/viewer/teams/getUpgradeable.test.ts
+++ b/packages/trpc/server/routers/viewer/teams/getUpgradeable.test.ts
@@ -1,4 +1,4 @@
-import prismaMock from "../../../../../../tests/libs/__mocks__/prismaMock";
+import prismaMock from "@calcom/testing/lib/__mocks__/prismaMock";
import { describe, it, expect, beforeEach, vi } from "vitest";
diff --git a/tests/libs/__mocks__/checkRateLimitAndThrowError.ts b/packages/trpc/server/routers/viewer/teams/inviteMember/__mocks__/checkRateLimitAndThrowError.ts
similarity index 90%
rename from tests/libs/__mocks__/checkRateLimitAndThrowError.ts
rename to packages/trpc/server/routers/viewer/teams/inviteMember/__mocks__/checkRateLimitAndThrowError.ts
index 8cd783f0c73..4e08e9183ee 100644
--- a/tests/libs/__mocks__/checkRateLimitAndThrowError.ts
+++ b/packages/trpc/server/routers/viewer/teams/inviteMember/__mocks__/checkRateLimitAndThrowError.ts
@@ -14,7 +14,12 @@ const checkRateLimitAndThrowErrorMock = mockDeep<typeof checkRateLimitAndThrowEr
export const scenarios = {
fakeRateLimitPassed: () => {
// It doesn't matter what the implementation is, as long as it resolves without error
- checkRateLimitAndThrowErrorMock.checkRateLimitAndThrowError.mockResolvedValue(undefined);
+ checkRateLimitAndThrowErrorMock.checkRateLimitAndThrowError.mockResolvedValue({
+ success: true,
+ limit: 10,
+ remaining: 999,
+ reset: 0,
+ });
},
fakeRateLimitFailed: () => {
const error = new Error("FAKE_RATE_LIMIT_ERROR");
diff --git a/tests/libs/__mocks__/getTranslation.ts b/packages/trpc/server/routers/viewer/teams/inviteMember/__mocks__/getTranslation.ts
similarity index 86%
rename from tests/libs/__mocks__/getTranslation.ts
rename to packages/trpc/server/routers/viewer/teams/inviteMember/__mocks__/getTranslation.ts
index 01be0be8b3e..cd68e7d9b85 100644
--- a/tests/libs/__mocks__/getTranslation.ts
+++ b/packages/trpc/server/routers/viewer/teams/inviteMember/__mocks__/getTranslation.ts
@@ -13,8 +13,6 @@ const getTranslationMock = mockDeep<typeof getTranslation>();
export const mock = {
fakeIdentityFn: () =>
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
getTranslationMock.getTranslation.mockImplementation(async () => (key: string) => key),
};
diff --git a/packages/trpc/server/routers/viewer/teams/inviteMember/inviteMember.handler.test.ts b/packages/trpc/server/routers/viewer/teams/inviteMember/inviteMember.handler.test.ts
index dc4c2f0969f..8c8654617be 100644
--- a/packages/trpc/server/routers/viewer/teams/inviteMember/inviteMember.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/teams/inviteMember/inviteMember.handler.test.ts
@@ -3,8 +3,8 @@
*
* It mocks a lot of things that are untested and integration tests make more sense for this handler
*/
-import { scenarios as checkRateLimitAndThrowErrorScenarios } from "../../../../../../../tests/libs/__mocks__/checkRateLimitAndThrowError";
-import { mock as getTranslationMock } from "../../../../../../../tests/libs/__mocks__/getTranslation";
+import { scenarios as checkRateLimitAndThrowErrorScenarios } from "./__mocks__/checkRateLimitAndThrowError";
+import { mock as getTranslationMock } from "./__mocks__/getTranslation";
import {
inviteMemberutilsScenarios as inviteMemberUtilsScenarios,
default as inviteMemberUtilsMock,
diff --git a/vitest.config.mts b/vitest.config.mts
index 5442a0280f9..c48025adfbb 100644
--- a/vitest.config.mts
+++ b/vitest.config.mts
@@ -96,7 +96,7 @@ export default defineConfig({
globals: true,
silent: true,
environment: "jsdom",
- setupFiles: ["./setupVitest.ts"],
+ setupFiles: ["./packages/testing/src/setupVitest.ts"],
include: getTestInclude(),
exclude: getTestExclude(),
server: {
diff --git a/vitest.workspace.ts b/vitest.workspace.ts
index 5340d2725ac..13bcc2e4048 100644
--- a/vitest.workspace.ts
+++ b/vitest.workspace.ts
@@ -31,7 +31,7 @@ const workspaces = packagedEmbedTestsOnly
name: `IntegrationTests`,
include: ["packages/**/*.integration-test.ts", "apps/**/*.integration-test.ts"],
exclude: ["**/node_modules/**/*", "packages/embeds/**/*"],
- setupFiles: ["setupVitest.ts"],
+ setupFiles: ["packages/testing/src/setupVitest.ts"],
},
resolve: {
alias: {
@@ -49,7 +49,7 @@ const workspaces = packagedEmbedTestsOnly
include: ["packages/**/*.integration-test.ts", "apps/**/*.integration-test.ts"],
// TODO: Ignore the api until tests are fixed
exclude: ["**/node_modules/**/*", "packages/embeds/**/*"],
- setupFiles: ["setupVitest.ts"],
+ setupFiles: ["packages/testing/src/setupVitest.ts"],
},
resolve: {
alias: {
@@ -66,7 +66,7 @@ const workspaces = packagedEmbedTestsOnly
include: ["packages/**/*.timezone.test.ts", "apps/**/*.timezone.test.ts"],
// TODO: Ignore the api until tests are fixed
exclude: ["**/node_modules/**/*", "packages/embeds/**/*"],
- setupFiles: ["setupVitest.ts"],
+ setupFiles: ["packages/testing/src/setupVitest.ts"],
},
},
]
@@ -84,7 +84,7 @@ const workspaces = packagedEmbedTestsOnly
"apps/api/v2/**/*",
],
name: "@calcom/lib",
- setupFiles: ["setupVitest.ts"],
+ setupFiles: ["packages/testing/src/setupVitest.ts"],
},
resolve: {
alias: {
@@ -108,7 +108,7 @@ const workspaces = packagedEmbedTestsOnly
"apps/api/v2/**/*",
],
name: "@calcom/api",
- setupFiles: ["setupVitest.ts"],
+ setupFiles: ["packages/testing/src/setupVitest.ts"],
},
resolve: {
alias: {
@@ -151,7 +151,7 @@ const workspaces = packagedEmbedTestsOnly
name: "@calcom/app-store-delegation-credential",
include: ["packages/app-store/delegationCredential.test.ts"],
environment: "node",
- setupFiles: ["setupVitest.ts"],
+ setupFiles: ["packages/testing/src/setupVitest.ts"],
},
},
{
diff --git a/yarn.lock b/yarn.lock
index 1ab69242871..0ff675d6d89 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3296,6 +3296,19 @@ __metadata:
languageName: unknown
linkType: soft
+"@calcom/testing@workspace:packages/testing":
+ version: 0.0.0-use.local
+ resolution: "@calcom/testing@workspace:packages/testing"
+ dependencies:
+ "@biomejs/biome": "npm:2.3.10"
+ "@calcom/lib": "workspace:*"
+ "@calcom/prisma": "workspace:*"
+ "@calcom/tsconfig": "workspace:*"
+ prismock: "npm:1.35.3"
+ vitest: "npm:4.0.16"
+ languageName: unknown
+ linkType: soft
+
"@calcom/trpc@workspace:*, @calcom/trpc@workspace:packages/trpc":
version: 0.0.0-use.local
resolution: "@calcom/trpc@workspace:packages/trpc"