From f54a3d1d0cf48c236365ecc36a51ffe77d3de352 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Wed, 7 Jan 2026 23:23:19 +0530 Subject: [PATCH] test: all flaky unit tests (#26558) --- .../payments/handlePaymentSuccess.test.ts | 7 +++++++ .../features/bookings/lib/EventManager.test.ts | 18 ++++++++++++++++++ .../features/crmManager/crmManager.test.ts | 17 ++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/app-store/_utils/payments/handlePaymentSuccess.test.ts b/packages/app-store/_utils/payments/handlePaymentSuccess.test.ts index 6ca01b54f7..3faf859321 100644 --- a/packages/app-store/_utils/payments/handlePaymentSuccess.test.ts +++ b/packages/app-store/_utils/payments/handlePaymentSuccess.test.ts @@ -74,6 +74,13 @@ vi.mock("@calcom/lib/logger", () => ({ })), }, })); +// Mock routing-forms modules to prevent async import issues during test teardown +vi.mock("@calcom/features/routing-forms/lib/findFieldValueByIdentifier", () => ({ + findFieldValueByIdentifier: vi.fn(), +})); +vi.mock("@calcom/app-store/routing-forms/lib/findFieldValueByIdentifier", () => ({ + findFieldValueByIdentifier: vi.fn(), +})); import { getBooking } from "@calcom/features/bookings/lib/payment/getBooking"; import getWebhooks from "@calcom/features/webhooks/lib/getWebhooks"; diff --git a/packages/features/bookings/lib/EventManager.test.ts b/packages/features/bookings/lib/EventManager.test.ts index a45fc81a17..46f83d2b1d 100644 --- a/packages/features/bookings/lib/EventManager.test.ts +++ b/packages/features/bookings/lib/EventManager.test.ts @@ -2,6 +2,24 @@ import { prisma } from "@calcom/prisma/__mocks__/prisma"; import { describe, expect, it, vi, beforeEach } from "vitest"; +vi.mock("@calcom/features/watchlist/lib/utils/normalization", () => ({ + normalizeEmail: vi.fn(), + extractDomainFromEmail: vi.fn(), + normalizeDomain: vi.fn(), +})); +vi.mock("@calcom/features/watchlist/lib/service/GlobalBlockingService", () => ({ + GlobalBlockingService: vi.fn(), +})); +vi.mock("@calcom/features/watchlist/lib/freeEmailDomainCheck/checkIfFreeEmailDomain", () => ({ + checkIfFreeEmailDomain: vi.fn(), +})); +vi.mock("@calcom/features/watchlist/operations/check-if-users-are-blocked.controller", () => ({ + checkIfUsersAreBlocked: vi.fn(), +})); +vi.mock("@calcom/features/watchlist/lib/telemetry", () => ({ + sentrySpan: vi.fn(), +})); + import { CredentialRepository } from "@calcom/features/credentials/repositories/CredentialRepository"; import { symmetricDecrypt } from "@calcom/lib/crypto"; import type { DestinationCalendar } from "@calcom/prisma/client"; diff --git a/packages/features/crmManager/crmManager.test.ts b/packages/features/crmManager/crmManager.test.ts index 7e143fafff..9ba35daafd 100644 --- a/packages/features/crmManager/crmManager.test.ts +++ b/packages/features/crmManager/crmManager.test.ts @@ -1,7 +1,22 @@ import { mockCrmApp } from "@calcom/web/test/utils/bookingScenario/bookingScenario"; import type { TFunction } from "i18next"; -import { describe, expect, test, vi } from "vitest"; +import { describe, expect, test, vi, afterEach } from "vitest"; + +vi.mock("@calcom/app-store/salesforce/lib/graphql/SalesforceGraphQLClient", () => ({ + SalesforceGraphQLClient: vi.fn(), +})); +vi.mock("@calcom/app-store/salesforce/lib/CrmService", () => ({ + default: vi.fn(), +})); +vi.mock("@urql/core", () => ({ + Client: vi.fn(), + cacheExchange: vi.fn(), + fetchExchange: vi.fn(), +})); +vi.mock("@urql/exchange-retry", () => ({ + retryExchange: vi.fn(), +})); import { getCrm } from "@calcom/app-store/_utils/getCrm";