refactor: circular deps between app store and lib [6] (#23971)
* move delegation credential repository to features * mv credential repository to features * update imports * mv * fix * fix * fix * fix * fix * update imports * update imports * update eslint rule * fix * fix * mv getConnectedDestinationCalendars * fix import errors * mv getCalendarsEvents * remove getUsersCredentials * wip * revert eslint rule change for now * fix type checks * fix * format * cleanup * fix * fix * fix * fix * fix tests * migrate getUserAvailability * migrate * fix tests * fix type checks * fix * fix * migrate crmManager * update imports * migrate raqbUtils to appstore * migrate getLuckyUser to features * migrate findTeamMembersMatchingAttributeLogic to appstore * update imports * fix * fix * fix test * fix unit tests * fix * fix * add eslint config
This commit is contained in:
1 parent
445b307972
commit
bb68cd73ef
114 files changed
+263
-245
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
|
||||
import { getRoutedUsersWithContactOwnerAndFixedUsers } from "./getRoutedUsers";
|
||||
|
||||
vi.mock("@calcom/prisma", () => {
|
||||
return {
|
||||
default: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe("getRoutedUsersWithContactOwnerAndFixedUsers", () => {
|
||||
const users = [
|
||||
{ id: 1, email: "[email protected]", isFixed: false },
|
||||
{ id: 2, email: "[email protected]", isFixed: true },
|
||||
{ id: 3, email: "[email protected]", isFixed: false },
|
||||
{ id: 4, email: "[email protected]", isFixed: false },
|
||||
];
|
||||
|
||||
const usersWithoutFixedHosts = users.map((user) => ({ ...user, isFixed: false }));
|
||||
|
||||
it("should return all users when routedTeamMemberIds is null", () => {
|
||||
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
||||
routedTeamMemberIds: null,
|
||||
users,
|
||||
contactOwnerEmail: "[email protected]",
|
||||
});
|
||||
expect(result).toEqual(users);
|
||||
});
|
||||
|
||||
it("should return all users when routedTeamMemberIds is empty - We don't want to enter a scenario where we have no team members to be booked", () => {
|
||||
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
||||
routedTeamMemberIds: [],
|
||||
users,
|
||||
contactOwnerEmail: "[email protected]",
|
||||
});
|
||||
expect(result).toEqual(users);
|
||||
});
|
||||
|
||||
it("should filter users based on routedTeamMemberIds, isFixed, and contactOwnerEmail", () => {
|
||||
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
||||
routedTeamMemberIds: [1, 3],
|
||||
users,
|
||||
contactOwnerEmail: "[email protected]",
|
||||
});
|
||||
expect(result).toEqual([
|
||||
{ id: 1, email: "[email protected]", isFixed: false },
|
||||
{ id: 2, email: "[email protected]", isFixed: true },
|
||||
{ id: 3, email: "[email protected]", isFixed: false },
|
||||
{ id: 4, email: "[email protected]", isFixed: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it("should return an empty array when neither fixed, nor routedTeamMemberIds, nor contactOwnerEmail match", () => {
|
||||
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
||||
routedTeamMemberIds: [5],
|
||||
users: usersWithoutFixedHosts,
|
||||
contactOwnerEmail: "[email protected]",
|
||||
});
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it("should return fixed hosts even if routedTeamMemberIds and contactOwnerEmail are invalid ", () => {
|
||||
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
||||
routedTeamMemberIds: [5],
|
||||
users,
|
||||
contactOwnerEmail: "[email protected]",
|
||||
});
|
||||
expect(result).toEqual([{ id: 2, email: "[email protected]", isFixed: true }]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user