refactor: remove @calcom/web imports from @calcom/features and add @calcom/testing package (#26480)
* fix: remove @calcom/web imports from packages/features to eliminate circular dependency - Migrate UserTableUser and MemberPermissions types to packages/features/users/types/user-table.ts - Migrate useGeo hook to packages/features/geo/GeoContext.tsx - Migrate buildLegacyRequest to packages/lib/buildLegacyCtx.ts - Migrate Calendar component to packages/features/calendars/weeklyview/components/ - Move test utilities (bookingScenario, fixtures) to packages/features/test/ - Update all imports in packages/features to use new locations - Add re-exports in apps/web for backward compatibility Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: delete original implementation files and fix type issues - Delete original calendar component files in apps/web (keep only re-export stubs) - Migrate OutOfOfficeInSlots to packages/features/bookings/components - Convert apps/web OutOfOfficeInSlots to re-export stub - Fix className vs class issue in Calendar.tsx - Fix @calcom/trpc import violation in user-table.ts by using structural type Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing isGroup and contains fields to UserTableUser attributes type Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: update customRole type to match actual Prisma Role model Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix build * fix * fix * cleanup weeklyview * fix * refactor to mv MemberPermissions to types package * add types dependency to features * fix * fix * fix * fix * fix * fix * rename * rename * migrate * migrate * migrate * fix * fix * fix * refactor: move test utilities from packages/features/test to tests/libs - Move bookingScenario utilities to tests/libs/bookingScenario - Move fixtures to tests/libs/fixtures - Update all imports in packages/features test files to use new location - Update all imports in apps/web test files to use new location - Eliminates duplication of test utilities between packages/features and apps/web Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: correct relative import paths for tests/libs in test files Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * refactor: replace test utility implementations with re-exports to tests/libs Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: fix test import paths and move signup handler tests to apps/web Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: move buildLegacyCtx to packages/lib and restore handlers to packages/features - Move buildLegacyCtx from apps/web/lib to packages/lib to break circular dependency - Update apps/web/lib/buildLegacyCtx.ts to re-export from @calcom/lib - Restore signup handlers and tests to packages/features/auth/signup/handlers - Update handler imports to use @calcom/lib/buildLegacyCtx instead of @calcom/web/lib/buildLegacyCtx Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: update recurring-event.test.ts imports to use tests/libs path Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * refactor: delete test re-export files and update imports to use tests/libs directly Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: update remaining test imports to use tests/libs directly Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: update handleRecurringEventBooking calls to match function signature (1 arg) Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * remove * migrate tests * migrate tests * refactor: update test mock imports by removing and using async for mock creators. * fix type errors * fix: add type assertion for MockUser in p2002.test-suite.ts Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: restore locale import in compareReminderBodyToTemplate.test.ts using relative path Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * feat: create @calcom/testing package and migrate tests from /tests directory - Created new @calcom/testing package in /packages/testing - Moved all files from /tests to /packages/testing - Updated all imports across the codebase to use @calcom/testing alias - Removed /tests directory at root level This allows other packages like @calcom/features and @calcom/web to import testing utilities using the @calcom/testing alias instead of relative paths. Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix * fix * fix: add missing useBookings export to @calcom/atoms package Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing useCalendarsBusyTimes and useConnectedCalendars exports to @calcom/atoms Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * chore: add @calcom/testing as explicit devDependency to packages that use it Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * refactor: move setupVitest.ts into @calcom/testing package Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix * chore: add biome rules to restrict @calcom/testing imports Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix * rename libs to lib * rename libs to lib * add rule * add rule * refactor: remove @calcom/features imports from @calcom/testing - Move mockPaymentSuccessWebhookFromStripe to fresh-booking.test.ts - Replace ProfileRepository.generateProfileUid() with uuidv4() - Clone Tracking type into @calcom/testing/src/lib/types.ts - Update imports in expects.ts and getMockRequestDataForBooking.ts - Move source files into src/ folder - Move CalendarManager mock to @calcom/features Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add explicit exports for nested paths in @calcom/testing Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * improve * improve * fix * fix * fix type checks * fix type checks * fix type checks * fix tests --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
04e447058c
commit
f5d345b133
209 files changed
+593
-522
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["*"],
|
||||
"@prisma/client/*": ["@calcom/prisma/client/*"]
|
||||
"@prisma/client/*": ["@calcom/prisma/client/*"],
|
||||
"@calcom/testing/*": ["../../../packages/testing/src/*"]
|
||||
},
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
|
||||
+1
-1
@@ -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";
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+31
-32
@@ -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 },
|
||||
+4
-3
@@ -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"] });
|
||||
|
||||
+24
-25
@@ -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, () => {
|
||||
+4
-4
@@ -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);
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
+5
-5
@@ -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,
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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";
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -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() {
|
||||
+2
-2
@@ -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();
|
||||
+4
-4
@@ -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();
|
||||
+5
-5
@@ -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,
|
||||
+1
-1
@@ -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();
|
||||
File renamed without changes.
File renamed without changes.
@@ -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: {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
+1
-1
@@ -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";
|
||||
|
||||
File renamed without changes.
@@ -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",
|
||||
|
||||
+15
-15
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
Timezones,
|
||||
TestData,
|
||||
mockCalendar,
|
||||
} from "../../utils/bookingScenario/bookingScenario";
|
||||
} from "@calcom/testing/lib/bookingScenario/bookingScenario";
|
||||
|
||||
import { describe, test } from "vitest";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getDate } from "../../utils/bookingScenario/bookingScenario";
|
||||
import { getDate } from "@calcom/testing/lib/bookingScenario/bookingScenario";
|
||||
|
||||
import { vi } from "vitest";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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/*"]
|
||||
},
|
||||
|
||||
+40
@@ -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."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"zod": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@calcom/testing": "workspace:*",
|
||||
"@calcom/types": "workspace:*"
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"react-dom": "^18.0.0 || ^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@calcom/testing": "workspace:*",
|
||||
"@calcom/tsconfig": "workspace:*",
|
||||
"@calcom/types": "workspace:*"
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
+1
-1
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
+4
-4
@@ -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";
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Loaded 100 of 209 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user