Files
calendar/packages/ui/components/test-setup.ts
T
4cdb8f3bae feat: make calcom UI dumb again (#19658)
* remove create button for teams from calcom ui

* migrate timezone select to features

* remove trpc from phone and storybook provider

* new-yarn.lock

* fix imports + test file for select

* fix platform timezone select to use Raw timezone select

* fix timezone type import

* use correct select in timezone-select.tsx - needs trpc version

* fix lock and remove test-utils

* fix log file

* Updated yarn.lock

* Fixed types

* Fixed tests

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-03-05 11:58:52 -03:00

91 lines
1.9 KiB
TypeScript

import matchers from "@testing-library/jest-dom/matchers";
import { cleanup } from "@testing-library/react";
import React from "react";
import { afterEach, expect, vi } from "vitest";
// For next.js webapp compponent that use "preserve" for jsx in tsconfig.json
global.React = React;
vi.mock("@calcom/features/ee/organizations/hooks", () => ({
useOrgBrandingValues() {
return {};
},
}));
vi.mock("@calcom/features/ee/organizations/context/provider", () => ({
useOrgBranding() {
return {};
},
}));
vi.mock("next/navigation", async () => ({
...((await vi.importActual("next/navigation")) as object),
useRouter() {
return {
route: "/",
pathname: "",
query: {},
asPath: "",
push: vi.fn(),
};
},
useSearchParams() {
return new URLSearchParams();
},
}));
vi.mock("@calcom/lib/OgImages", async () => {
return {};
});
vi.mock("@calcom/lib/hooks/useLocale", () => ({
useLocale: () => {
return {
t: (str: string) => str,
isLocaleReady: true,
i18n: {
language: "en",
defaultLocale: "en",
locales: ["en"],
exists: () => false,
},
};
},
}));
vi.mock("@calcom/atoms/hooks/useIsPlatform", () => ({
useIsPlatform: () => {
return false;
},
}));
vi.mock("@calcom/lib/event-types/getEventTypesByViewer", () => ({}));
vi.mock("@calcom/lib/event-types/getEventTypesPublic", () => ({}));
vi.mock("@calcom/lib", () => ({
classNames: (...args: string[]) => {
return args.filter(Boolean).join(" ");
},
}));
expect.extend({
tabToBeDisabled(received) {
const isDisabled = received.classList.contains("pointer-events-none");
return {
pass: isDisabled,
message: () => `Expected tab to be disabled`,
};
},
});
global.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
expect.extend(matchers);
afterEach(() => {
cleanup();
});