forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not consider salesforce ownership when making rerouting decis…
…ion (calcom#18034)
- Loading branch information
1 parent
8d05656
commit 6ce9def
Showing
5 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { isRerouting, shouldIgnoreContactOwner } from "./utils"; | ||
|
||
describe("isRerouting", () => { | ||
it("should return true when both rescheduleUid and routedTeamMemberIds are present", () => { | ||
const result = isRerouting({ | ||
rescheduleUid: "123", | ||
routedTeamMemberIds: [1, 2], | ||
}); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it("should return false when rescheduleUid is null", () => { | ||
const result = isRerouting({ | ||
rescheduleUid: null, | ||
routedTeamMemberIds: [1, 2], | ||
}); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
it("should return false when routedTeamMemberIds is null", () => { | ||
const result = isRerouting({ | ||
rescheduleUid: "123", | ||
routedTeamMemberIds: null, | ||
}); | ||
expect(result).toBe(false); | ||
}); | ||
}); | ||
|
||
describe("shouldIgnoreContactOwner", () => { | ||
it("should return true when skipContactOwner is true", () => { | ||
const result = shouldIgnoreContactOwner({ | ||
skipContactOwner: true, | ||
rescheduleUid: null, | ||
routedTeamMemberIds: null, | ||
}); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it("should return true when rerouting", () => { | ||
const result = shouldIgnoreContactOwner({ | ||
skipContactOwner: false, | ||
rescheduleUid: "123", | ||
routedTeamMemberIds: [1, 2], | ||
}); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it("should return false when skipContactOwner is false and not rerouting", () => { | ||
const result = shouldIgnoreContactOwner({ | ||
skipContactOwner: false, | ||
rescheduleUid: null, | ||
routedTeamMemberIds: null, | ||
}); | ||
expect(result).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* It returns true only if there is actually some team members to route to at the moment. | ||
* But I think we should also consider the case where no routedTeamMemberIds is provided or it is null which is when we want to consider all the assigned members of the team event for rerouting. | ||
* So, it could be better to just read cal.rerouting query param instead of routedTeamMemberIds. | ||
*/ | ||
export function isRerouting({ | ||
rescheduleUid, | ||
routedTeamMemberIds, | ||
}: { | ||
rescheduleUid: string | null; | ||
routedTeamMemberIds: number[] | null; | ||
}) { | ||
return !!rescheduleUid && !!routedTeamMemberIds; | ||
} | ||
|
||
export function shouldIgnoreContactOwner({ | ||
skipContactOwner, | ||
rescheduleUid, | ||
routedTeamMemberIds, | ||
}: { | ||
skipContactOwner: boolean | null; | ||
rescheduleUid: string | null; | ||
routedTeamMemberIds: number[] | null; | ||
}) { | ||
// During rerouting, we don't want to consider salesforce ownership as it could potentially choose a member that isn't part of routedTeamMemberIds and thus ending up with no available timeslots. | ||
return skipContactOwner || isRerouting({ rescheduleUid, routedTeamMemberIds }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters