feat: #15416 Expand round robin availability beyond default schedule (#15618)

* add feature to change host schedule

* update for type-check:ci

* Update SingleForm.tsx for linterr

* update as per design review

* update for rerendering

* migration files

* On Delete set null for schedule

if schedule is deleted, no need to delete the host

* updated schema

* added testcases

* checking permissions before

* updated for comments

* update for initial value

* updated and cleanup

* set initial value

* update after merge

* updated nit style

* update for console warning and added comments

* nit/chore

* chore

* update for typechecks

* update for scheduleId param after merge

* update after merge or new changes in metadata.config

* update after weights functionality

* updated description text and column name as per review suggestion

* resolved merge conflicts

* fix typecheck due to changes in getScheduleSchema

* update after merge having refactor

* update refactored EventTypeWebWrapper after merge

* updated props

* updated trpc err code and added log

* update due to refactor in EventAvailabilityTab

* perf: Optimise TS type + select only the data that's needed for a specific function

---------

Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-10-15 17:36:00 +01:00
1 parent c21f0caecf
commit a48d190af3
27 files changed
+600 -67

No files matched your search

@@ -8,7 +8,9 @@ describe("Tests to Check if Event Types have empty Assignment", () => {
checkForEmptyAssignment({
assignedUsers: [],
assignAllTeamMembers: false,
hosts: [{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0 }],
hosts: [
{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0, scheduleId: null },
],
isManagedEventType: true,
})
).toBe(true);
@@ -61,7 +63,9 @@ describe("Tests to Check if Event Types have empty Assignment", () => {
checkForEmptyAssignment({
assignedUsers: [],
assignAllTeamMembers: false,
hosts: [{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0 }],
hosts: [
{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0, scheduleId: null },
],
isManagedEventType: false,
})
).toBe(false);
+137
View File
@@ -1896,4 +1896,141 @@ describe("getSchedule", () => {
);
});
});
describe("Round robin event", async () => {
test("correctly get slots for event with round robin hosts choosen schedule (non-default)", async () => {
vi.setSystemTime("2024-05-21T00:00:13Z");
const plus1DateString = "2024-05-22";
const plus2DateString = "2024-05-23";
// An event with no common schedule and hosts choosen schedule (non-default schedule)
await createBookingScenario({
eventTypes: [
{
id: 1,
slotInterval: 60,
length: 60,
hosts: [
{
userId: 101,
isFixed: false,
scheduleId: 2,
},
{
userId: 102,
isFixed: false,
scheduleId: 3,
},
],
schedulingType: "ROUND_ROBIN",
schedule: null,
},
],
users: [
{
...TestData.users.example,
email: "[email protected]",
id: 101,
schedules: [TestData.schedules.IstMorningShift, TestData.schedules.IstEveningShift],
defaultScheduleId: 1,
},
{
...TestData.users.example,
email: "[email protected]",
id: 102,
schedules: [TestData.schedules.IstEveningShift, TestData.schedules.IstMorningShift],
defaultScheduleId: 4,
},
],
bookings: [],
});
const scheduleWithHostChoosenSch = await getSchedule({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
teamMemberEmail: "[email protected]",
},
});
// expect only slots of IstEveningShift , as this is the choosen schedule for hosts
expect(scheduleWithHostChoosenSch).toHaveTimeSlots(
[`11:30:00.000Z`, `12:30:00.000Z`, `13:30:00.000Z`, `14:30:00.000Z`, `15:30:00.000Z`],
{
dateString: plus2DateString,
}
);
});
test("correctly get slots for event with commom schedule", async () => {
vi.setSystemTime("2024-05-21T00:00:13Z");
const plus1DateString = "2024-05-22";
const plus2DateString = "2024-05-23";
// An event with common schedule
await createBookingScenario({
eventTypes: [
{
id: 1,
slotInterval: 60,
length: 60,
hosts: [
{
userId: 101,
isFixed: false,
},
{
userId: 102,
isFixed: false,
},
],
schedule: TestData.schedules.IstEveningShift,
schedulingType: "ROUND_ROBIN",
},
],
users: [
{
...TestData.users.example,
email: "[email protected]",
id: 101,
schedules: [TestData.schedules.IstMorningShift],
defaultScheduleId: 1,
},
{
...TestData.users.example,
email: "[email protected]",
id: 102,
schedules: [TestData.schedules.IstMidShift],
defaultScheduleId: 2,
},
],
bookings: [],
});
const scheduleWithEventCommonSch = await getSchedule({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
teamMemberEmail: "[email protected]",
},
});
// expect only slots of IstEveningShift , as this is the common schedule of event
expect(scheduleWithEventCommonSch).toHaveTimeSlots(
[`11:30:00.000Z`, `12:30:00.000Z`, `13:30:00.000Z`, `14:30:00.000Z`, `15:30:00.000Z`],
{
dateString: plus2DateString,
}
);
});
});
});