From f5d345b133f4325c20446854f88085fa7516ecf4 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Thu, 8 Jan 2026 16:59:11 +0900 Subject: [PATCH] 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 * 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 * fix: add missing isGroup and contains fields to UserTableUser attributes type Co-Authored-By: benny@cal.com * fix: update customRole type to match actual Prisma Role model Co-Authored-By: benny@cal.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 * fix: correct relative import paths for tests/libs in test files Co-Authored-By: benny@cal.com * refactor: replace test utility implementations with re-exports to tests/libs Co-Authored-By: benny@cal.com * fix: fix test import paths and move signup handler tests to apps/web Co-Authored-By: benny@cal.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 * fix: update recurring-event.test.ts imports to use tests/libs path Co-Authored-By: benny@cal.com * refactor: delete test re-export files and update imports to use tests/libs directly Co-Authored-By: benny@cal.com * fix: update remaining test imports to use tests/libs directly Co-Authored-By: benny@cal.com * fix: update handleRecurringEventBooking calls to match function signature (1 arg) Co-Authored-By: benny@cal.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 * fix: restore locale import in compareReminderBodyToTemplate.test.ts using relative path Co-Authored-By: benny@cal.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 * fix * fix * fix: add missing useBookings export to @calcom/atoms package Co-Authored-By: benny@cal.com * fix: add missing useCalendarsBusyTimes and useConnectedCalendars exports to @calcom/atoms Co-Authored-By: benny@cal.com * chore: add @calcom/testing as explicit devDependency to packages that use it Co-Authored-By: benny@cal.com * refactor: move setupVitest.ts into @calcom/testing package Co-Authored-By: benny@cal.com * fix * chore: add biome rules to restrict @calcom/testing imports Co-Authored-By: benny@cal.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 * fix: add explicit exports for nested paths in @calcom/testing Co-Authored-By: benny@cal.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> --- apps/api/v1/package.json | 1 + apps/api/v1/pages/api/slots/_get.test.ts | 2 +- apps/api/v1/test/lib/attendees/_post.test.ts | 2 +- .../v1/test/lib/bookings/[id]/_delete.test.ts | 2 +- .../v1/test/lib/bookings/[id]/_patch.test.ts | 2 +- .../lib/bookings/[id]/recordings/_get.test.ts | 2 +- .../transcripts/[recordingId]/_get.test.ts | 2 +- .../bookings/[id]/transcripts/_get.test.ts | 2 +- apps/api/v1/test/lib/bookings/_get.test.ts | 2 +- apps/api/v1/test/lib/bookings/_post.test.ts | 2 +- .../test/lib/event-types/[id]/_delete.test.ts | 2 +- .../v1/test/lib/event-types/[id]/_get.test.ts | 2 +- .../api/v1/test/lib/event-types/_post.test.ts | 2 +- .../test/lib/selected-calendars/_post.test.ts | 2 +- apps/api/v1/tsconfig.json | 3 +- .../admin/playground/weekly-calendar/page.tsx | 2 +- .../auth/oauth/token/__tests__/route.test.ts | 2 +- .../handlers/calcomSignupHandler.test.ts | 63 ++++++------ .../signup/handlers/calcomSignupHandler.ts | 7 +- .../handlers}/selfHostedHandler.test.ts | 49 +++++----- .../auth/signup/handlers/selfHostedHandler.ts | 8 +- apps/web/app/api/auth/signup/route.ts | 4 +- .../cron/credentials/__tests__/cron.test.ts | 2 +- .../selected-calendars/__tests__/cron.test.ts | 2 +- .../__tests__/queued-response.test.ts | 2 +- .../getTeamMemberEmailFromCrm.test.ts | 2 +- apps/web/lib/app-providers-app-dir.tsx | 4 +- .../tests/recorded-daily-video.test.ts | 4 +- .../troubleshoot/troubleshoot-view.tsx | 2 +- .../components/BookingCalendarView.tsx | 2 +- .../bookings/components/LargeCalendar.tsx | 2 +- .../components}/LargeCalendar.tsx | 10 +- .../modules/ee/posthog}/PostHogPageView.tsx | 0 .../modules/ee/posthog}/pageViewDynamic.tsx | 0 .../web/modules/ee}/posthog/provider.tsx | 0 .../modules/ee}/posthog/providerDynamic.tsx | 0 .../teams/components/EditMemberSheet.test.tsx | 2 +- .../ee/teams/components/EditMemberSheet.tsx | 2 +- .../ee/teams/components/MemberList.tsx | 2 +- .../ee/teams/views/team-members-view.tsx | 2 +- apps/web/modules/members/members-view.tsx | 2 +- .../onboarding-calendar-browser-view.tsx | 2 +- .../AvailabilitySchedulesContainer.tsx | 0 .../components/CalendarToggleContainer.tsx | 0 .../components/ConnectedAppsContainer.tsx | 0 .../components/EventScheduleItem.tsx | 2 +- .../components/EventTypeSelect.tsx | 4 +- .../components/LargeCalendar.tsx | 8 +- .../components}/Troubleshooter.tsx | 10 +- .../components/TroubleshooterHeader.tsx | 2 +- .../TroubleshooterListItemContainer.tsx | 0 .../components/TroubleshooterSidebar.tsx | 0 .../components/UserTable/UserListTable.tsx | 5 +- .../users/components/UserTable/types.ts | 31 +----- .../users/lib/UserListTableUtils.test.ts} | 2 +- .../modules}/users/lib/UserListTableUtils.ts | 0 apps/web/package.json | 1 + .../pages/api/book}/recurring-event.test.ts | 30 +++--- .../test/handlers/requestReschedule.test.ts | 10 +- apps/web/test/lib/confirm.handler.test.ts | 2 +- apps/web/test/lib/getSchedule.test.ts | 4 +- .../lib/getSchedule/calendarEvents.test.ts | 2 +- .../getSchedule/delegation-credential.test.ts | 4 +- .../getSchedule/futureLimit.timezone.test.ts | 4 +- .../getSchedule/restrictionSchedule.test.ts | 4 +- .../lib/getSchedule/selectedSlots.test.ts | 2 +- .../test/lib/getSchedule/setupAndTeardown.ts | 2 +- apps/web/test/lib/getSchedule/utils.ts | 2 +- .../test/lib/handleChildrenEventTypes.test.ts | 2 +- apps/web/tsconfig.json | 1 + biome.json | 40 ++++++++ .../_utils/getDefaultLocations.test.ts | 4 +- .../_utils/oauth/OAuthManager.test.ts | 2 +- .../app-store/delegationCredential.test.ts | 2 +- .../__tests__/CalendarService.auth.test.ts | 2 +- .../googlecalendar/lib/__tests__/utils.ts | 2 +- .../app-store/hubspot/lib/CrmService.test.ts | 2 +- .../lib/VideoApiAdapter.test.ts | 2 +- packages/app-store/package.json | 1 + .../salesforce/lib/CrmService.test.ts | 2 +- packages/app-store/tsconfig.json | 7 +- packages/emails/lib/generateIcsString.test.ts | 2 +- packages/emails/lib/getICalUID.test.ts | 2 +- packages/emails/package.json | 1 + .../attributes/lib/getAttributes.test.ts | 2 +- .../handlers/__tests__/p2002.test-suite.ts | 2 +- .../getAllCredentials.test.ts | 2 +- .../lib/getBookingResponsesSchema.test.ts | 2 +- .../bookings/lib/getLuckyUser.test.ts | 4 +- .../test/handleCancelBooking.test.ts | 8 +- .../global-booking-limits.test.ts | 8 +- .../test/booking-flags.test.ts | 10 +- .../test/booking-limits.test.ts | 12 +-- .../test/booking-validations.test.ts | 10 +- .../test/complex-schedules.test.ts | 10 +- .../test/date-overrides.test.ts | 10 +- .../test/delegation-credential.test.ts | 10 +- .../test/dynamic-group-booking.test.ts | 10 +- .../test/email-verification-booking.test.ts | 8 +- .../test/fresh-booking.test.ts | 46 +++++++-- .../test/managed-event-type-booking.test.ts | 4 +- .../test/post-booking-handling.test.ts | 10 +- .../handleNewBooking/test/reschedule.test.ts | 12 +-- .../test/round-robin-no-hosts.test.ts | 8 +- .../test/spam-booking.integration-test.ts | 8 +- ...ve-reschedule-destination-calendar.test.ts | 10 +- .../collective-scheduling.test.ts | 10 +- .../test/team-bookings/round-robin.test.ts | 8 +- .../test/workflow-notifications.test.ts | 10 +- .../lib/handleSeats/test/handleSeats.test.ts | 12 +-- ...fiedHostsWithDelegationCredentials.test.ts | 2 +- .../lib/payment/processPaymentRefund.test.ts | 2 +- .../InstantBookingCreateService.test.ts | 4 +- .../service/RecurringBookingService.test.ts | 10 +- .../lib}/__mocks__/CalendarManager.ts | 2 +- .../calendars/lib/getCalendarsEvents.test.ts | 2 +- .../features/calendars/weeklyview/index.tsx | 1 - .../credentials/deleteCredential.test.ts | 2 +- .../repositories/CreditsRepository.test.ts | 2 +- .../features/crmManager/crmManager.test.ts | 2 +- .../__tests__/filterSegments/create.test.ts | 2 +- .../__tests__/filterSegments/delete.test.ts | 2 +- .../__tests__/filterSegments/get.test.ts | 2 +- .../__tests__/filterSegments/update.test.ts | 2 +- .../DelegationCredentialRepository.test.ts | 2 +- .../service/teams/TeamBillingService.test.ts | 2 +- .../teams/internal-team-billing.test.ts | 2 +- .../common/server/LicenseKeyService.test.ts | 2 +- .../ee/dsync/lib/assignValueToUser.test.ts | 2 +- .../ee/dsync/lib/handleUserEvents.test.ts | 2 +- ...BillingEnabledOrgOnboardingService.test.ts | 2 +- .../SelfHostedOnboardingService.test.ts | 2 +- .../OrganizationRepository.test.ts | 2 +- .../roundRobinDeleteEvents.test.ts | 8 +- .../roundRobinManualReassignment.test.ts | 10 +- .../roundRobinReassignment.test.ts | 10 +- .../features/ee/teams/lib/payments.test.ts | 2 +- .../teams/repositories/TeamRepository.test.ts | 2 +- .../ee/teams/services/teamService.test.ts | 2 +- .../lib/reminders/reminderScheduler.test.ts | 2 +- .../lib/service/WorkflowService.test.ts | 2 +- .../compareReminderBodyToTemplate.test.ts | 39 +++++--- .../ee/workflows/lib/test/workflows.test.ts | 10 +- .../repositories/WorkflowRepository.test.ts | 2 +- .../lib/getEventTypeById.integration-test.ts | 4 +- ...eck-if-user-has-feature.controller.test.ts | 2 +- ...check-if-user-has-feature.use-case.test.ts | 2 +- .../insights/server/__tests__/events.test.ts | 2 +- packages/features/package.json | 1 + .../pbac/lib/team-member-permissions.ts | 11 ++- .../repositories/ProfileRepository.test.ts | 2 +- .../repositories/ScheduleRepository.test.ts | 2 +- .../handleNotificationWhenNoSlots.test.ts | 4 +- .../crm/__tests__/createCRMEvent.test.ts | 2 +- .../tasker/tasks/scanWorkflowBody.test.ts | 2 +- ...triggerFormSubmittedNoEventWebhook.test.ts | 2 +- ...riggerFormSubmittedNoEventWorkflow.test.ts | 2 +- .../triggerNoShow/triggerGuestNoShow.test.ts | 6 +- .../triggerNoShow/triggerHostNoShow.test.ts | 6 +- .../users/repositories/UserRepository.test.ts | 2 +- packages/features/watchlist/lib/testUtils.ts | 2 +- .../webhooks/lib/test/webhooks.test.ts | 6 +- .../repository/HolidayRepository.test.ts | 2 +- .../repository/selectedCalendar.test.ts | 2 +- packages/lib/server/username.test.ts | 2 +- .../calendar-view/CalendarViewComponent.tsx | 2 +- .../EventTypeCalendarViewComponent.tsx | 2 +- packages/platform/atoms/package.json | 3 + packages/testing/package.json | 27 ++++++ .../testing}/performance/README.md | 0 .../testing}/performance/load/booking.js | 0 .../testing}/performance/smoke/booking.js | 0 .../testing}/performance/spike/booking.js | 0 .../testing}/performance/stress/booking.js | 0 .../testing}/performance/utils/config.js | 0 .../testing}/performance/utils/helpers.js | 0 .../testing}/scripts/run-k6-local.sh | 0 .../src/lib}/__mocks__/libServerI18n.ts | 0 .../testing/src/lib}/__mocks__/prisma.ts | 4 - .../testing/src/lib}/__mocks__/prismaMock.ts | 2 +- .../bookingScenario/MockPaymentService.ts | 4 +- .../lib}/bookingScenario/bookingScenario.ts | 97 +++++-------------- .../createMockNextJsRequest.ts | 0 .../src/lib}/bookingScenario/expects.ts | 8 +- .../getMockRequestDataForBooking.ts | 4 +- .../getMockRequestDataForCancelBooking.ts | 0 .../bookingScenario/getSampleUserInSession.ts | 0 .../lib}/bookingScenario/setupAndTeardown.ts | 5 +- .../testing/src/lib}/bookingScenario/test.ts | 6 +- .../src/lib}/bookingScenario/types.d.ts | 0 .../testing/src/lib}/fixtures/fixtures.ts | 0 packages/testing/src/lib/types.ts | 11 +++ .../testing/src/setupVitest.ts | 2 +- packages/testing/tsconfig.json | 10 ++ .../getAllSchedulesByUserId.handler.test.ts | 2 +- .../heavy/duplicate.handler.test.ts | 2 +- .../oAuth/generateAuthCode.handler.test.ts | 2 +- .../__tests__/createTeams.handler.test.ts | 2 +- .../organizations/bulkDeleteUsers.test.ts | 2 +- .../organizations/create.handler.test.ts | 2 +- .../createWithPaymentIntent.handler.test.ts | 2 +- .../intentToCreateOrg.handler.test.ts | 2 +- .../viewer/teams/getUpgradeable.test.ts | 2 +- .../__mocks__/checkRateLimitAndThrowError.ts | 7 +- .../inviteMember}/__mocks__/getTranslation.ts | 2 - .../inviteMember/inviteMember.handler.test.ts | 4 +- vitest.config.mts | 2 +- vitest.workspace.ts | 12 +-- yarn.lock | 13 +++ 209 files changed, 593 insertions(+), 522 deletions(-) rename packages/features/auth/signup/handlers/__tests__/calcomHandler.test.ts => apps/web/app/api/auth/signup/handlers/calcomSignupHandler.test.ts (64%) rename packages/features/auth/signup/handlers/calcomHandler.ts => apps/web/app/api/auth/signup/handlers/calcomSignupHandler.ts (97%) rename {packages/features/auth/signup/handlers/__tests__ => apps/web/app/api/auth/signup/handlers}/selfHostedHandler.test.ts (56%) rename {packages/features => apps/web/app/api}/auth/signup/handlers/selfHostedHandler.ts (96%) rename {packages/features/calendar-view => apps/web/modules/calendar-view/components}/LargeCalendar.tsx (92%) rename {packages/features/ee/event-tracking/lib/posthog/web => apps/web/modules/ee/posthog}/PostHogPageView.tsx (100%) rename {packages/features/ee/event-tracking/lib/posthog/web => apps/web/modules/ee/posthog}/pageViewDynamic.tsx (100%) rename {packages/features/ee/event-tracking/lib => apps/web/modules/ee}/posthog/provider.tsx (100%) rename {packages/features/ee/event-tracking/lib => apps/web/modules/ee}/posthog/providerDynamic.tsx (100%) rename {packages/features => apps/web/modules}/troubleshooter/components/AvailabilitySchedulesContainer.tsx (100%) rename {packages/features => apps/web/modules}/troubleshooter/components/CalendarToggleContainer.tsx (100%) rename {packages/features => apps/web/modules}/troubleshooter/components/ConnectedAppsContainer.tsx (100%) rename {packages/features => apps/web/modules}/troubleshooter/components/EventScheduleItem.tsx (94%) rename {packages/features => apps/web/modules}/troubleshooter/components/EventTypeSelect.tsx (94%) rename {packages/features => apps/web/modules}/troubleshooter/components/LargeCalendar.tsx (92%) rename {packages/features/troubleshooter => apps/web/modules/troubleshooter/components}/Troubleshooter.tsx (86%) rename {packages/features => apps/web/modules}/troubleshooter/components/TroubleshooterHeader.tsx (97%) rename {packages/features => apps/web/modules}/troubleshooter/components/TroubleshooterListItemContainer.tsx (100%) rename {packages/features => apps/web/modules}/troubleshooter/components/TroubleshooterSidebar.tsx (100%) rename apps/web/{test/lib/generateCsv.test.ts => modules/users/lib/UserListTableUtils.test.ts} (99%) rename {packages/features => apps/web/modules}/users/lib/UserListTableUtils.ts (100%) rename {packages/features/bookings/lib/handleNewBooking/test => apps/web/pages/api/book}/recurring-event.test.ts (98%) rename {tests/libs => packages/features/calendars/lib}/__mocks__/CalendarManager.ts (79%) delete mode 100644 packages/features/calendars/weeklyview/index.tsx create mode 100644 packages/testing/package.json rename {tests => packages/testing}/performance/README.md (100%) rename {tests => packages/testing}/performance/load/booking.js (100%) rename {tests => packages/testing}/performance/smoke/booking.js (100%) rename {tests => packages/testing}/performance/spike/booking.js (100%) rename {tests => packages/testing}/performance/stress/booking.js (100%) rename {tests => packages/testing}/performance/utils/config.js (100%) rename {tests => packages/testing}/performance/utils/helpers.js (100%) rename {tests => packages/testing}/scripts/run-k6-local.sh (100%) rename {tests/libs => packages/testing/src/lib}/__mocks__/libServerI18n.ts (100%) rename {tests/libs => packages/testing/src/lib}/__mocks__/prisma.ts (95%) rename {tests/libs => packages/testing/src/lib}/__mocks__/prismaMock.ts (82%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/MockPaymentService.ts (97%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/bookingScenario.ts (96%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/createMockNextJsRequest.ts (100%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/expects.ts (99%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/getMockRequestDataForBooking.ts (91%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/getMockRequestDataForCancelBooking.ts (100%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/getSampleUserInSession.ts (100%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/setupAndTeardown.ts (91%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/test.ts (88%) rename {apps/web/test/utils => packages/testing/src/lib}/bookingScenario/types.d.ts (100%) rename {apps/web/test => packages/testing/src/lib}/fixtures/fixtures.ts (100%) create mode 100644 packages/testing/src/lib/types.ts rename setupVitest.ts => packages/testing/src/setupVitest.ts (97%) create mode 100644 packages/testing/tsconfig.json rename {tests/libs => packages/trpc/server/routers/viewer/teams/inviteMember}/__mocks__/checkRateLimitAndThrowError.ts (90%) rename {tests/libs => packages/trpc/server/routers/viewer/teams/inviteMember}/__mocks__/getTranslation.ts (86%) diff --git a/apps/api/v1/package.json b/apps/api/v1/package.json index 42de9c995a..5972bbee32 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 ed5b50b347..e7ed5bd126 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 b0b5773ad0..2467c80638 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 53c1239572..5e66eb52c4 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 1799226e18..1179859139 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 05a2a18070..cf18112f70 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 3a9eebba24..7eab2398e5 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 b4b8bbc901..e632b59d9e 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 f9585cee88..8ffbec5974 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 c415a6cd2c..4d46a65ac4 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 2e891b0973..fa0a180c88 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 e1307b9722..2cf49027f3 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 4b467fe04f..ca13d5b4b9 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 45d65084d1..597221baa4 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 e1f5e1e943..b787a2b8bf 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 2a2ac73062..8e868da77e 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 b7ad93001c..3edd45fff1 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 a8ba326548..32277a136c 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; - -const { - createNextServerMock, - createNextHeadersMock, -} = (await vi.hoisted( - async () => await import("./mocks/next.mocks") -)) as Awaited; - -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; +} 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, status: UsernameStatus) => Promise; -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): Promise { - if (!capturedHandler) throw new Error("Handler not captured"); - return capturedHandler(body as Record, { +function callHandler(body: SignupBody): Promise { + if (!mockCapturedHandler) throw new Error("Handler not captured"); + return mockCapturedHandler(body as unknown as Record, { 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 3d9d1a33a6..7aac999fe3 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 7fcb740bec..cfd74f3697 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; - -const { createNextServerMock } = (await vi.hoisted( - async () => await import("./mocks/next.mocks") -)) as Awaited; - -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; +} 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): ReturnType { - return handler(body as Record); +function callHandler(body: SignupBody): ReturnType { + return handler(body as unknown as Record); } 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 e5252e52cf..bc238eb330 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) { 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 db31e4ab95..33cbd26b12 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 2bad734ab8..d887233878 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 37037d4b1e..5f1a794179 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 ec51b25d24..8434e08478 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 303f7928a2..62a441cf87 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 e26329f39c..239fb54bca 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 24528075ca..2bdc07a976 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 c1207f2262..9ec58a3a24 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 1bea45ffcc..b733bfebb6 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 9f22ba5717..0e2b07aa08 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 544f38c91c..664b555cd4 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 0a7cbb653e..dec9e6d05d 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 d8be9d9ffc..5b6aea0fb5 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 e3494f48c7..9f38735f5e 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 6cb88bf86c..a9de10ce53 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 9dbc5ee8d5..d2cab5684e 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 32fdafe0d7..614d8a8c67 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 45aa1d8c1b..de2d292d6d 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 a7000a249e..f41a064ab7 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 9e3002fe1d..30b09151f0 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 3c96fd2a45..aea5687d71 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 b899447160..1326b698f8 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 e8dff1dd2a..3412157b7f 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 e37c028d1c..4d3d17196c 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 0d712299c8..115ad49c61 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 e55ac7aca1..e1872c3d04 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 4ead5d4050..8f662c116d 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 66c62db57b..5e3f838816 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 eca68e13eb..d5de99fc58 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 d6c8ebcb7f..e3534ee17d 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 7958d7999f..1422776306 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 04ec01ce1c..b6fe73a634 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 c59a4fa9ed..f3bf7daec5 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 975c588449..458923fd7a 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 a9b0381d00..c854cee547 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 c28a3767d2..c7c22b825a 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 ccf2505561..d8a74d9e69 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 79db3cd9cf..8b4200380b 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 3e7d673a63..ee947350bc 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 5bb3280913..1e0634944c 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 456083f9f0..bf5a33b579 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 9870808fcb..ba6253f899 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 256caced3f..7e9f5b6068 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 31af2e8eed..61764f2372 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 5e85dafb13..4d52c1bfd6 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 0f5c099e0f..ed019a7e65 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 2b969b9113..865e2e54f5 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 d380a194a0..95c0a63100 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 3d3d9f807c..b0f26a0b7b 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 cacd085f24..17bd028211 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 43d0fe5387..d7b9887bc4 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 b8c518b9f3..8f8117b9fe 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 64af5b257c..a9d5e82aed 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 22f2adffee..c35c073524 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 76ea04e24e..1a112eaf07 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 0b8b9f155a..e8ccf58b09 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 22a767d5d1..106dfb9d3e 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 8ab4935f52..020bf78335 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 dabcdc8b5d..18f76fd7f9 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 3cac0a282b..e9a898716b 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 302c63b419..7868bebd5f 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 ddf2019ee9..214fd30c7b 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 507ec19fdb..df37f9c031 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 9122e5b347..ccf83703f6 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 4b0dc1a33f..1711928762 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 b3e522a413..bd0c6b3d30 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 df22c09df0..c6ddec8a2d 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 46b6f0e60b..65a57620f0 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 2f0b2877a5..e59736f670 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 59214bf260..46a3773b9c 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 f75b8f9850..ba86ad9ff7 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 07e1710c18..c70b6d6aae 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 e729a5228f..cd3cc0ae77 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 aa2e8ea5f4..e699aae7a6 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 1a309971ac..2134a18bb8 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 6328739d1c..d834a380fc 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 0c9de8d828..9e52b9f368 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 1467227853..20b9ad9768 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 e10ab3c451..28efb97b51 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 2d067dc12c..b8a0f53f57 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 ce59e666a7..1fe17dd5bd 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 45827697d8..73574053e6 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 9453f3e320..32506333d4 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 ecfdc6d4a2..e73ca9094a 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 c480fb9e14..bb47d25bbe 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 76930d546e..0000000000 --- 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 1702a17f86..8c0b10e71a 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 53c3fd296f..356ea4aa38 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 9ba35daafd..fc01e2b9cf 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 6f197f607e..8332bf013c 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 8b9e464136..fffa248534 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 6b4d42fc22..eda9a8793a 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 8cc3743aee..22e6d9bb62 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 53a4f1bf97..9a99d85aef 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 59e54d6174..6e6605697e 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 28501f2502..dac7e034bd 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 9390128bb0..4aa27c083c 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 955daf9833..4c871a52ef 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 944d8a1b06..9742cceab3 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 d1e878627b..b9ddaba3af 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 fef7ede407..284dd45d5f 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 1fbef952d5..a1b18bc7ce 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 f86fdbfc97..c0142e296b 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 02d5ff60b9..192c6b2c32 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 49dc590fb0..d717da191c 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 6250774312..b98990ae5b 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 9d56ec29f1..659d43add2 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 cfa1c7c6df..cb3ad49863 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 fbd3c98b02..f3d82c98f2 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 8227470e07..ec4ecda51f 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 641cddfb9a..74ca692ff6 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 = { + 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 593aea91a8..6fd4feb6e1 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 50154c15c7..05228bc504 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 6d7a158678..337f7158a1 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 225667dd83..3ee3454fed 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 78feb312f5..a7b8765693 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 076278615c..168b9a13a7 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 2cd6240b47..540a333066 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 11baf62bd1..473642b9ab 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 08417cdd43..723c68fdb2 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 495bc03a71..6a2db4fb4b 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 1a753e417d..d2c6d86b44 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 e3689dc4aa..59e639ce54 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 c26508b782..5a2d20d9d5 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 7ff9dbb10f..8761f28799 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 aa52506256..2f2949d6ee 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 12443c869e..4bfadc83fa 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 2cd9dc845f..d677f263e3 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 10c26ae85b..8b28134126 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 ed2d6b173a..b377a163d4 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 ae3d407504..f2fba10b6e 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 db23afe8d0..d44cb2750d 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 e356e4dd07..8690d579dc 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 480dd3ef0c..c857a1a266 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 75f23773ae..946c40b177 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 7e3e921d6e..816ef0b367 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 14e8d1af19..ee7096ad49 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 0000000000..8e27dc9042 --- /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 6978f8af46..d21bb372bf 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 16f9f9868c..1a4233003c 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 4ae9633afa..96ba63316e 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 dc8ab938ae..841b66840a 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(); @@ -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 a381cde434..6cdc8fefb3 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 b112c06914..739f1fc3b5 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 26c7011db6..a12f009b8f 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 890ce3461a..ff2783a0b6 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 0000000000..1c92c2bd6e --- /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 5d7e1f65e7..1c2e7d8e59 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 0000000000..dfd82dba16 --- /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 cba36aa890..5faa3a34ed 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 8cb624797f..60b70dc46e 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 d5dabe207a..0e813793e7 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 af4c761890..5f39c85a64 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 74b86b70d7..5aac692372 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 4b3f30c9ba..7373ade39d 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 4f6bc5593f..7927f8fca8 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 c707c6783b..33bee5b9f2 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 89dba252f3..c84f89207d 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 8cd783f0c7..4e08e9183e 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 { // 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 01be0be8b3..cd68e7d9b8 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(); 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 dc4c2f0969..8c8654617b 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 5442a0280f..c48025adfb 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 5340d2725a..13bcc2e404 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 1ab6924287..0ff675d6d8 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"