Files
calendar/apps/web/modules/test-setup.ts
T
d4bff9d6b1 feat: Cal.ai Self Serve #2 (#22995)
* feat: Cal.ai Self Serve #2

* chore: fix import and remove logs

* fix: update checkout session

* fix: type errors and test

* fix: imports

* fix: type err

* fix: type error

* fix: tests

* chore: save progress

* fix: workflow flow

* fix: workflow update bug

* tests: add unit tests for retell ai webhoo

* fix: status code

* fix: test and delete bug

* fix: add dynamic variables

* fix: type err

* chore: update unit test

* fix: type error

* chore: update default prompt

* fix: type errors

* fix: workflow permissions

* fix: workflow page

* fix: translations

* feat: add call duration

* chore: add booking uid

* fix: button positioning

* chore: update tests

* chore: improvements

* chore: some more improvements

* refactor: improvements

* refactor: code feedback

* refactor: improvements

* feat: enable credits for orgs (#23077)

* Show credits UI for orgs

* fix stripe callback url when buying credits

* give orgs 20% credits

* add test for calulating credits

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>

* fix: types

* fix: types

* chore: error

* fix: type error

* fix: type error

* chore: mock env

* feat: add idempotency key to prevent double charging

* chore: add userId and teamId

* fix: skip inbound calls

* chore: update tests

* feat: add feature flag for voice agent

* feat: finish test call and other improvements

* chore: add alert

* chore: update .env.example

* chore: improvements

* fix: update tests

* refactor: remove un necessary

* feat: add setup badge

* chore: improvements

* fix: use referene id

* chore: improvements

* fix: type error

* fix: type

* refactor: change pricing logic

* refactor: update tests

* fix: conflicts

* fix: billing link for orgs

* fix: types

* refactor: move feature flag up

* fix: alert and test call credit check

* fix: update unit tests

* fix: feedback

* refactor: improvements

* refactor: move handlers to separate files

* fix: types

* fix: missing import

* fix: type

* refactor: change general tools functions handling

* refactor: use repository

* refactor: improvements

* fix: types

* fix: type errorr

* fix: auth check

* feat: add creditFor

* fix: update defualt prompt

* fix: throw error on frontend

* fix: update unit tests

* fix: use deleteAllWorkflowReminders

* refactor: add connect phone number

* refactor: improvements

* chore: translation

* chore: update message

* chore: translation

* design improvements buy number dialog

* add translation for error message

* use translation key in error message

* refactor: improve connect phone number tab

* feat: support un saved workflow to tests

* chore: remove un used

* fix: remove un used

* fix: remove un used

* refactor: similify billing

---------

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-08-29 05:04:05 +01:00

198 lines
4.1 KiB
TypeScript

import React from "react";
import { vi, afterEach } from "vitest";
global.React = React;
afterEach(() => {
vi.resetAllMocks();
});
// Mock all modules that are used in multiple tests for modules
// We don't intend to provide the mock implementation here. They should be provided by respective tests.
// But it makes it super easy to start testing any module view without worrying about mocking the dependencies.
vi.mock("next-auth/react", () => ({
useSession: vi.fn(),
}));
vi.mock("next/navigation", () => ({
useRouter: vi.fn().mockReturnValue({
replace: vi.fn(),
}),
usePathname: vi.fn().mockReturnValue("/settings/billing"),
}));
vi.mock("@calcom/app-store/BookingPageTagManager", () => ({
default: vi.fn(),
}));
vi.mock("@calcom/app-store/locations", () => ({
DailyLocationType: "daily",
guessEventLocationType: vi.fn(),
getSuccessPageLocationMessage: vi.fn(),
}));
vi.mock("@calcom/app-store/utils", () => ({
getEventTypeAppData: vi.fn(),
}));
vi.mock("@calcom/lib/event", () => ({
getEventName: vi.fn(),
}));
vi.mock("@calcom/ee/organizations/lib/orgDomains", () => ({
getOrgFullOrigin: vi.fn(),
}));
vi.mock("@calcom/features/eventtypes/components", () => ({
EventTypeDescriptionLazy: vi.fn(),
}));
vi.mock("@calcom/embed-core/embed-iframe", () => {
return {
useIsBackgroundTransparent: vi.fn(),
useIsEmbed: vi.fn(),
useEmbedNonStylesConfig: vi.fn(),
useEmbedStyles: vi.fn(),
};
});
vi.mock("@calcom/features/bookings/components/event-meta/Price", () => {
return {};
});
vi.mock("@calcom/features/bookings/lib/SystemField", () => {
return {};
});
vi.mock("@calcom/lib/constants", () => {
return {
DEFAULT_LIGHT_BRAND_COLOR: "DEFAULT_LIGHT_BRAND_COLOR",
DEFAULT_DARK_BRAND_COLOR: "DEFAULT_DARK_BRAND_COLOR",
BOOKER_NUMBER_OF_DAYS_TO_LOAD: 1,
};
});
vi.mock("@calcom/lib/dayjs", () => {
return {};
});
vi.mock("@calcom/lib/getBrandColours", () => {
return {
default: vi.fn(),
};
});
vi.mock("@calcom/lib/hooks/useCompatSearchParams", () => {
return {
useCompatSearchParams: vi.fn(),
};
});
vi.mock("@calcom/lib/hooks/useLocale", () => {
return {
useLocale: vi.fn().mockReturnValue({
t: vi.fn().mockImplementation((text: string) => {
return text;
}),
i18n: {
language: "en",
},
}),
};
});
vi.mock("@calcom/lib/hooks/useRouterQuery", () => {
return {
useRouterQuery: vi.fn(),
};
});
vi.mock("@calcom/lib/hooks/useTheme", () => {
return {
default: vi.fn(),
};
});
vi.mock("@calcom/lib/recurringStrings", () => {
return {};
});
vi.mock("@calcom/lib/recurringStrings", () => {
return {};
});
vi.mock("@calcom/prisma/zod-utils", () => ({
BookerLayouts: {
MONTH_VIEW: "month",
},
EventTypeMetaDataSchema: {
parse: vi.fn(),
},
eventTypeMetaDataSchemaWithTypedApps: {
parse: vi.fn(),
},
bookingMetadataSchema: {
parse: vi.fn(),
},
}));
vi.mock("@calcom/trpc/react", () => ({
trpc: {
viewer: {
public: {
submitRating: {
useMutation: vi.fn(),
},
markHostAsNoShow: {
useMutation: vi.fn(),
},
},
},
},
}));
vi.mock("@calcom/ui/styles", () => ({
useCalcomTheme: vi.fn(),
}));
vi.mock("@calcom/ui/components/icon", () => ({
Icon: vi.fn(),
}));
vi.mock("@calcom/ui/components/unpublished-entity", () => ({
UnpublishedEntity: vi.fn(),
}));
vi.mock("@calcom/ui/components/avatar", () => ({
UserAvatar: vi.fn(),
}));
vi.mock("@calcom/web/components/PageWrapper", () => ({
default: vi.fn(),
}));
vi.mock("@calcom/web/components/booking/CancelBooking", () => ({}));
vi.mock("@calcom/web/components/schemas/EventReservationSchema", () => ({
default: vi.fn(),
}));
vi.mock("@calcom/web/lib/clock", () => ({
timeZone: vi.fn(),
}));
vi.mock("./bookings-single-view.getServerSideProps", () => ({}));
vi.mock("@calcom/lib/webstorage", () => ({
localStorage: {
getItem: vi.fn(),
setItem: vi.fn(),
},
}));
vi.mock("@calcom/lib/timeFormat", () => ({
detectBrowserTimeFormat: vi.fn(),
isBrowserLocale24h: vi.fn(),
getIs24hClockFromLocalStorage: vi.fn(),
}));