fix: Re-instate new slot logic now it's A/B tested in production (#19605)

* fix: Re-instate new slot logic now it's well tested

* Fixup getAggregatedAvailability

* Changes to code-owners to reflect removed/moved code

* Move more files around.

* Fix failed type

---------

Co-authored-by: Omar López <zomars@me.com>
This commit is contained in:
Alex van Andel
2025-03-02 23:32:31 +00:00
committed by GitHub
co-authored by Omar López
parent 4bab8c2c32
commit 1cfd94d293
13 changed files with 21 additions and 881 deletions
@@ -1,123 +0,0 @@
import { expect, it, beforeAll, vi } from "vitest";
import { getAggregateWorkingHours } from "@calcom/core/getAggregateWorkingHours";
beforeAll(() => {
vi.setSystemTime(new Date("2021-06-20T11:59:59Z"));
});
const HAWAII_AND_NEWYORK_TEAM = [
{
timeZone: "America/Detroit", // GMT -4 per 22th of Aug, 2022
workingHours: [{ userId: 1, days: [1, 2, 3, 4, 5], startTime: 780, endTime: 1260 }],
busy: [],
dateOverrides: [],
datesOutOfOffice: {},
},
{
timeZone: "Pacific/Honolulu", // GMT -10 per 22th of Aug, 2022
workingHours: [
{ userId: 1, days: [3, 4, 5], startTime: 0, endTime: 360 },
{ userId: 2, days: [6], startTime: 0, endTime: 180 },
{ userId: 3, days: [2, 3, 4], startTime: 780, endTime: 1439 },
{ userId: 4, days: [5], startTime: 780, endTime: 1439 },
],
busy: [],
dateOverrides: [],
datesOutOfOffice: {},
},
];
/* TODO: Make this test more "professional" */
it("Sydney and Shiraz can live in harmony 🙏", async () => {
expect(getAggregateWorkingHours(HAWAII_AND_NEWYORK_TEAM, "COLLECTIVE")).toMatchInlineSnapshot(`
[
{
"days": [
3,
4,
5,
],
"endTime": 360,
"startTime": 780,
},
{
"days": [
6,
],
"endTime": 180,
"startTime": 0,
"userId": 2,
},
{
"days": [
2,
3,
4,
],
"endTime": 1260,
"startTime": 780,
},
{
"days": [
5,
],
"endTime": 1260,
"startTime": 780,
},
]
`);
expect(getAggregateWorkingHours(HAWAII_AND_NEWYORK_TEAM, "ROUND_ROBIN")).toMatchInlineSnapshot(`
[
{
"days": [
1,
2,
3,
4,
5,
],
"endTime": 1260,
"startTime": 780,
"userId": 1,
},
{
"days": [
3,
4,
5,
],
"endTime": 360,
"startTime": 0,
"userId": 1,
},
{
"days": [
6,
],
"endTime": 180,
"startTime": 0,
"userId": 2,
},
{
"days": [
2,
3,
4,
],
"endTime": 1439,
"startTime": 780,
"userId": 3,
},
{
"days": [
5,
],
"endTime": 1439,
"startTime": 780,
"userId": 4,
},
]
`);
});