Skip to content

Scheduling infrastructure for absolutely everyone.

refactor: Clean up the /tests in the root (#26525)

Benny Joo6d2491b394fa
diff --git a/tests/libs/__mocks__/reminderScheduler.ts b/tests/libs/__mocks__/reminderScheduler.ts
deleted file mode 100644
index 0881b17a689..00000000000
--- a/tests/libs/__mocks__/reminderScheduler.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { beforeEach, vi } from "vitest";
-import { mockReset, mockDeep } from "vitest-mock-extended";
-
-import type * as reminderScheduler from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";
-
-vi.mock("@calcom/features/ee/workflows/lib/reminders/reminderScheduler", () => reminderSchedulerMock);
-
-beforeEach(() => {
- mockReset(reminderSchedulerMock);
-});
-
-const reminderSchedulerMock = mockDeep<typeof reminderScheduler>();
-export default reminderSchedulerMock;
diff --git a/tests/libs/__mocks__/stripe.ts b/tests/libs/__mocks__/stripe.ts
deleted file mode 100644
index 5a662cc3f73..00000000000
--- a/tests/libs/__mocks__/stripe.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type Stripe from "stripe";
-import { vi } from "vitest";
-
-import { mockStripeSubscription } from "../mockData";
-
-interface MockStripeProps {
- subscriptions: {
- cancel: () => Promise<Stripe.Subscription>;
- update: () => Promise<Stripe.Subscription>;
- retrieve: () => Promise<Stripe.Subscription>;
- };
-}
-
-vi.mock("stripe", () => {
- return vi.fn(() => {
- return {
- subscriptions: {
- cancel: () => Promise.resolve(mockStripeSubscription),
- update: () => Promise.resolve(mockStripeSubscription),
- retrieve: () => Promise.resolve(mockStripeSubscription),
- },
- } as MockStripeProps;
- });
-});
diff --git a/tests/libs/__mocks__/videoClient.ts b/tests/libs/__mocks__/videoClient.ts
deleted file mode 100644
index 13e2d7a8b7a..00000000000
--- a/tests/libs/__mocks__/videoClient.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { beforeEach, vi } from "vitest";
-import { mockReset, mockDeep } from "vitest-mock-extended";
-
-import type * as videoClient from "@calcom/features/conferencing/lib/videoClient";
-
-vi.mock("@calcom/features/conferencing/lib/videoClient", () => videoClientMock);
-
-beforeEach(() => {
- mockReset(videoClientMock);
-});
-
-const videoClientMock = mockDeep<typeof videoClient>();
-export default videoClientMock;
diff --git a/tests/libs/mockData.ts b/tests/libs/mockData.ts
deleted file mode 100644
index cd166a7641e..00000000000
--- a/tests/libs/mockData.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import type Stripe from "stripe";
-
-export const mockStripeCustomer: Stripe.Customer = {
- id: "cus_xxx",
- object: "customer",
- address: null,
- balance: -4972,
- created: 1689812247,
- currency: "cad",
- default_source: null,
- delinquent: false,
- description: null,
- discount: null,
- email: "[email protected]",
- invoice_prefix: "xxx",
- invoice_settings: {
- custom_fields: null,
- default_payment_method: null,
- footer: null,
- rendering_options: null,
- },
- livemode: false,
- metadata: {},
- name: null,
- next_invoice_sequence: 17,
- phone: null,
- preferred_locales: [],
- shipping: null,
- tax_exempt: "none",
- test_clock: null,
-};
-
-export const mockEnv = {
- DATABASE_URL: "xxx",
- NODE_ENV: "xxx",
- NEXTAUTH_SECRET: "xxx",
- NEXTAUTH_URL: "xxx",
- REDDIT_CLIENT_ID: "xxx",
- REDDIT_CLIENT_SECRET: "xxx",
- BUNNY_PASSWORD: "xxx",
- STRIPE_TEST_KEY: "xxx",
- STRIPE_LIVE_KEY: "xxx",
- STRIPE_WEBHOOK_SECRET: "xxx",
- NEXT_URL: "xxx",
- OPEN_AI_KEY: "xxx",
- OPEN_AI_ORG: "xxx",
- SENDGRID_API_KEY: "xxx",
- IBM_API_KEY: "xxx",
- IBM_URL: "xxx",
- NEXT_PUBLIC_NODE_ENV: "xxx",
- SENTRY_DSN: "xxx",
- NEXT_PUBLIC_SENTRY_DSN: "xxx",
-};
-
-export const mockStripeSubscription: Stripe.Subscription & { plan: Stripe.Plan } = {
- id: "sub_xxxxxxxxxxxxxxxxxxxxxxxx",
- object: "subscription",
- application: null,
- application_fee_percent: null,
- automatic_tax: { enabled: false },
- billing_cycle_anchor: 1718226165,
- billing_thresholds: null,
- cancel_at: 1749762165,
- cancel_at_period_end: true,
- canceled_at: 1718227398,
- collection_method: "charge_automatically",
- created: 1718226165,
- currency: "usd",
- current_period_end: 1749762165,
- current_period_start: 1718226165,
- customer: "cus_xxxxxxxxxxxxxx",
- days_until_due: null,
- default_payment_method: "pm_xxxxxxxxxxxxxxxxxxxxxxxx",
- default_source: null,
- default_tax_rates: [],
- description: null,
- discount: null,
- ended_at: 1749762165,
- items: {
- object: "list",
- data: [],
- has_more: false,
- url: "/v1/subscription_items?subscription=sub_xxxxxxxxxxxxxxxxxxxxxxxx",
- },
- latest_invoice: "in_xxxxxxxxxxxxxxxxxxxxxxxx",
- livemode: false,
- metadata: {},
- next_pending_invoice_item_invoice: null,
- pause_collection: null,
- payment_settings: {
- payment_method_options: {
- acss_debit: null,
- bancontact: null,
- card: { request_three_d_secure: "automatic" },
- customer_balance: null,
- konbini: null,
- us_bank_account: null,
- },
- payment_method_types: null,
- save_default_payment_method: "off",
- },
- pending_invoice_item_interval: null,
- pending_setup_intent: null,
- pending_update: null,
- plan: {
- id: "price_xxxxxxxxxxxxxxxxxxxxxxxx",
- object: "plan",
- active: true,
- aggregate_usage: null,
- amount: 14400,
- amount_decimal: "14400",
- billing_scheme: "per_unit",
- created: 1718225939,
- currency: "usd",
- interval: "year",
- interval_count: 1,
- livemode: false,
- metadata: {},
- nickname: null,
- product: "prod_xxxxxxxxxxxxxx",
- tiers_mode: null,
- transform_usage: null,
- trial_period_days: null,
- usage_type: "licensed",
- },
- schedule: null,
- start_date: 1718226165,
- status: "canceled",
- test_clock: "clock_xxxxxxxxxxxxxxxxxxxxxxxx",
- transfer_data: null,
- trial_end: null,
- trial_start: null,
-};
diff --git a/tests/libs/mockTRPCContext.ts b/tests/libs/mockTRPCContext.ts
deleted file mode 100644
index e9c2359510e..00000000000
--- a/tests/libs/mockTRPCContext.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import type { NextApiRequest, NextApiResponse } from "next";
-
-import { UserPermissionRole } from "@calcom/prisma/enums";
-import type { GetSessionFn } from "@calcom/trpc/server/createContext";
-import { createContext } from "@calcom/trpc/server/createContext";
-import type { UserProfile } from "@calcom/types/UserProfile";
-
-const sessionGetter: GetSessionFn = () =>
- Promise.resolve({
- user: {
- name: "",
- email: "",
- image: "",
- id: 1,
- uuid: "test-uuid-mock-context",
- username: "" /* Not used in this context */,
- role: UserPermissionRole.USER,
- profile: {
- id: null,
- organizationId: null,
- organization: null,
- username: "",
- upId: "",
- } satisfies UserProfile,
- },
- hasValidLicense: true /* To comply with TS signature */,
- expires: "" /* Not used in this context */,
- upId: "",
- });
-
-export async function mockTRPCContext() {
- const req: NextApiRequest = { url: "/api/clients", headers: { "accept-language": "en" } } as NextApiRequest;
- const res: NextApiResponse = {} as NextApiResponse;
- const ctx = await createContext({ req, res }, sessionGetter);
- return ctx;
-}