* refactor: extract getEventTypeByViewer for private user dashboard event types * refactor: extract getEventTypesPublic for public event types to book * refactor: group event-types lib functions in single folder * refactor: rename getEventTypeByViewer to getEventTypesByViewer * feat: add event type helpers from lib to platform libraries * feat: v2 endpoint for private event types * driveby:fix: fixed date in docs instead of being re-generated * feature: endpoint to fetch public endpoints * fix: getting private event types * tests: fetch private event types * tests: fetch private event types * feat: hooks for public and private events * fix: yarn test * tests: IMO better mocking * refactor: track dynamic prop in react query * fix: distinct query key for public events * fix: username in query key and example app demo * fix: swagger for endpoint get public event input --------- Co-authored-by: Morgan Vernay <morgan@cal.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
92 lines
1.8 KiB
TypeScript
92 lines
1.8 KiB
TypeScript
import matchers from "@testing-library/jest-dom/matchers";
|
|
import { cleanup } from "@testing-library/react";
|
|
import { afterEach, expect, vi } from "vitest";
|
|
|
|
vi.mock("next-auth/react", () => ({
|
|
useSession() {
|
|
return {};
|
|
},
|
|
}));
|
|
|
|
vi.mock("@calcom/features/ee/organizations/hooks", () => ({
|
|
useOrgBrandingValues() {
|
|
return {};
|
|
},
|
|
}));
|
|
|
|
vi.mock("@calcom/features/ee/organizations/context/provider", () => ({
|
|
useOrgBranding() {
|
|
return {};
|
|
},
|
|
}));
|
|
|
|
vi.mock("@calcom/trpc/react", () => ({
|
|
trpc: {},
|
|
}));
|
|
|
|
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/monorepo", () => ({
|
|
useIsPlatform: () => {
|
|
return false;
|
|
},
|
|
}));
|
|
|
|
vi.mock("@calcom/lib/event-types/getEventTypesByViewer", () => ({}));
|
|
vi.mock("@calcom/lib/event-types/getEventTypesPublic", () => ({}));
|
|
|
|
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();
|
|
});
|