* Partial push of new filters * Let's always return the passed host array when a filter doesn't need to be applied * fix: isFixed typing in same round robin host check * Add main bulk of rewritten logic for routed fairness support * Remove console.log * Add getAttributeWithEnabledWeights to AttributeRepository * Add OOO entry repository * Use getOrderedListOfLuckyUsers in lead threshold filtering * Shortfall already includes weight * test against minShortfall * first attempt to fix fallbacks * Added testcase updates * Partially fix filterHosts test * Some test updates * Removed email field from normalization * fix no available users found error * fix unit test * remove fallback from same host reschedule return * fixes and improvements for findQualifiedHosts * include fallback logic in handleNewBooking * use fallback in handleNewBooking * fix for contact owner in handleNewBooking * WIP - comment * pass routingFormResponseId * fix type error * pass routingFormResponse * fixes in treshold logic * remove reason * merge qualified and fallback availabilities * fix type error * add and fix tests * clean up test file * fix filterHostsBySameRoundRobinHost tests * fix findQualifiedHosts.test.ts * fix getRoutedUsers.test.ts * fix tests * fix isRerouting check * fix start time for two weeks check * fix fallback hosts * fix test * fallback hosts should also include qualified hosts * fix type error * fix typos * add contact owner to fallbacks * fix typo * fix qualifiedRRUsers * set fixed users when no hosts * add tets + code clean up * add test for reschedule with same host * fix typo * add more tests for findQualifiedHosts * remove skip from test * add comment * remove unused code * fix fallback users in loadAndValidateUsers * improve naming for fallback * rename missed fallback variable * fix reschedule with same rr host in handleNewBooking * fixes for fallback slots * add more tests + small fixes for contact owner * fix tests and type errors * add logs for fallback * add type:json to logger * Fix small merge issue * fix end time if two weeks are cut off * add more tests for contact owner availability check * add new logic for two weeks fallback * fix reschedule same RR host test --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
65 lines
2.4 KiB
TypeScript
65 lines
2.4 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
|
|
import { getRoutedUsersWithContactOwnerAndFixedUsers } from "./getRoutedUsers";
|
|
|
|
describe("getRoutedUsersWithContactOwnerAndFixedUsers", () => {
|
|
const users = [
|
|
{ id: 1, email: "user1@example.com", isFixed: false },
|
|
{ id: 2, email: "user2@example.com", isFixed: true },
|
|
{ id: 3, email: "user3@example.com", isFixed: false },
|
|
{ id: 4, email: "owner@example.com", 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: "owner@example.com",
|
|
});
|
|
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: "owner@example.com",
|
|
});
|
|
expect(result).toEqual(users);
|
|
});
|
|
|
|
it("should filter users based on routedTeamMemberIds, isFixed, and contactOwnerEmail", () => {
|
|
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
|
routedTeamMemberIds: [1, 3],
|
|
users,
|
|
contactOwnerEmail: "owner@example.com",
|
|
});
|
|
expect(result).toEqual([
|
|
{ id: 1, email: "user1@example.com", isFixed: false },
|
|
{ id: 2, email: "user2@example.com", isFixed: true },
|
|
{ id: 3, email: "user3@example.com", isFixed: false },
|
|
{ id: 4, email: "owner@example.com", isFixed: false },
|
|
]);
|
|
});
|
|
|
|
it("should return an empty array when neither fixed, nor routedTeamMemberIds, nor contactOwnerEmail match", () => {
|
|
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
|
routedTeamMemberIds: [5],
|
|
users: usersWithoutFixedHosts,
|
|
contactOwnerEmail: "nonexistent@example.com",
|
|
});
|
|
expect(result).toEqual([]);
|
|
});
|
|
|
|
it("should return fixed hosts even if routedTeamMemberIds and contactOwnerEmail are invalid ", () => {
|
|
const result = getRoutedUsersWithContactOwnerAndFixedUsers({
|
|
routedTeamMemberIds: [5],
|
|
users,
|
|
contactOwnerEmail: "nonexistent@example.com",
|
|
});
|
|
expect(result).toEqual([{ id: 2, email: "user2@example.com", isFixed: true }]);
|
|
});
|
|
});
|