* Initial commit * routingForm to Booking a particular team member working * Happy path working * Fixes * Fix router query params forwarding * Add basicConfig within app * Tests * More tests * Update packages/app-store/routing-forms/components/SingleForm.tsx Co-authored-by: Omar López <[email protected]> * WIP * Fix lint issues * Fix tests -TS and add new logic * Add getEventTypeRedirectUrl tests * Remove booking title changes code * More changes * Add tests for getRoutedUsers * More tests * Update testUtils.ts --------- Co-authored-by: Omar López <[email protected]> Co-authored-by: Keith Williams <[email protected]>
91 lines
3.2 KiB
TypeScript
91 lines
3.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import type { GetAvailabilityUser } from "@calcom/core/getUserAvailability";
|
|
|
|
import { getUsersWithCredentialsConsideringContactOwner } from "./util";
|
|
|
|
describe("getUsersWithCredentialsConsideringContactOwner", () => {
|
|
const createMockUser = (email: string): GetAvailabilityUser => ({
|
|
id: Math.random(),
|
|
email,
|
|
name: email.split("@")[0],
|
|
username: email.split("@")[0],
|
|
timeZone: "UTC",
|
|
weekStart: "Monday",
|
|
defaultScheduleId: null,
|
|
bufferTime: 0,
|
|
locale: "en",
|
|
});
|
|
|
|
it("should return all hosts when contact owner does not exist", () => {
|
|
const hosts = [
|
|
{ isFixed: true, user: createMockUser("[email protected]") },
|
|
{ isFixed: false, user: createMockUser("[email protected]") },
|
|
];
|
|
const result = getUsersWithCredentialsConsideringContactOwner({
|
|
contactOwnerEmail: "[email protected]",
|
|
hosts,
|
|
});
|
|
expect(result).toHaveLength(2);
|
|
expect(result.map((u) => u.email)).toEqual(["[email protected]", "[email protected]"]);
|
|
});
|
|
|
|
it("should return all hosts when contact owner is a fixed host", () => {
|
|
const hosts = [
|
|
{ isFixed: true, user: createMockUser("[email protected]") },
|
|
{ isFixed: false, user: createMockUser("[email protected]") },
|
|
];
|
|
const result = getUsersWithCredentialsConsideringContactOwner({
|
|
contactOwnerEmail: "[email protected]",
|
|
hosts,
|
|
});
|
|
expect(result).toHaveLength(2);
|
|
expect(result.map((u) => u.email)).toEqual(["[email protected]", "[email protected]"]);
|
|
});
|
|
|
|
it("should return contact owner and fixed hosts when contact owner is not fixed", () => {
|
|
const hosts = [
|
|
{ isFixed: true, user: createMockUser("[email protected]") },
|
|
{ isFixed: false, user: createMockUser("[email protected]") },
|
|
{ isFixed: false, user: createMockUser("[email protected]") },
|
|
];
|
|
const result = getUsersWithCredentialsConsideringContactOwner({
|
|
contactOwnerEmail: "[email protected]",
|
|
hosts,
|
|
});
|
|
expect(result).toHaveLength(2);
|
|
expect(result.map((u) => u.email)).toEqual(["[email protected]", "[email protected]"]);
|
|
});
|
|
|
|
it("should return all hosts when contactOwnerEmail is null", () => {
|
|
const hosts = [
|
|
{ isFixed: true, user: createMockUser("[email protected]") },
|
|
{ isFixed: false, user: createMockUser("[email protected]") },
|
|
];
|
|
const result = getUsersWithCredentialsConsideringContactOwner({
|
|
contactOwnerEmail: null,
|
|
hosts,
|
|
});
|
|
expect(result).toHaveLength(2);
|
|
expect(result.map((u) => u.email)).toEqual(["[email protected]", "[email protected]"]);
|
|
});
|
|
|
|
it("should return only fixed hosts when there's no contact owner", () => {
|
|
const hosts = [
|
|
{ isFixed: true, user: createMockUser("[email protected]") },
|
|
{ isFixed: false, user: createMockUser("[email protected]") },
|
|
{ isFixed: true, user: createMockUser("[email protected]") },
|
|
];
|
|
const result = getUsersWithCredentialsConsideringContactOwner({
|
|
contactOwnerEmail: null,
|
|
hosts,
|
|
});
|
|
expect(result).toHaveLength(3);
|
|
expect(result.map((u) => u.email)).toEqual([
|
|
"[email protected]",
|
|
"[email protected]",
|
|
"[email protected]",
|
|
]);
|
|
});
|
|
});
|