* WIP * add frontend * backend to update weight * UI improvements * WIP weight algorithm * enable weights switch + algorithm improvements * fix weightDescription * clean up code * remove OOOEntryHost from schema.prisma * implement logic (not yet tested) * add tests for weight algorithm * add test with weight adjustment * finish unit tests * fix type error * fix type error * add migration * fix type error * fix event type update handler * fix failing test * UI fixes for saving hosts * make sure weightAdjustment is not lost on host changes * fix weightadjustment for new hosts * add weightAdjustment to availableUsers * fix type errors * fix default value for weight * make weight and weightAdjustment optional * fix type errors from schema changes * type fix * clean up code * improve comments * remove comment * clean up code * add tests & weight adjustment improvments * better variable naming * fixes for weight adjustments * make weightAdjustments proportional to weights * fix previous host weight adjustments * improved tests for weight adjustments * save weight and priority + sort hosts correctly * fix type error * code clean up * remove console.log * use BookingRepository to fetch bookings of users * use BookingRepository to fetch bookings in getLuckyUser * fix type errors * fix weightAdjustment if changed from fixed to rr host * disable weights when 'assign all' is enabled * typo * allow 0 weight * set min (and max) for weight and priority * use useWatch * code clean up * fix type error * only count accepted bookings for RR * fix type error * improve data fetching of bookings * only filter bookings of availableUsers * code clean up form feedback * fix tests * don't count no show bookings * code clean up * choose user with highest weight * use one reduce instead of two * use reduce instead of filter and map * don't show weights toggle when 'assign all' is enabled * design fixes * fix type errors * fix: type check * Update packages/features/eventtypes/components/AddMembersWithSwitch.tsx --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
103 lines
3.0 KiB
TypeScript
103 lines
3.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { checkForEmptyAssignment } from "../../lib/checkForEmptyAssignment";
|
|
|
|
describe("Tests to Check if Event Types have empty Assignment", () => {
|
|
it("should return true if managed event type has no assigned users", () => {
|
|
expect(
|
|
checkForEmptyAssignment({
|
|
assignedUsers: [],
|
|
assignAllTeamMembers: false,
|
|
hosts: [{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0 }],
|
|
isManagedEventType: true,
|
|
})
|
|
).toBe(true);
|
|
});
|
|
it("should return true if non-managed event type has no hosts assigned", () => {
|
|
expect(
|
|
checkForEmptyAssignment({
|
|
assignedUsers: [
|
|
{
|
|
created: true,
|
|
owner: {
|
|
id: 101,
|
|
avatar: "avatar.svg",
|
|
email: "firstuser@cal.com",
|
|
membership: "OWNER",
|
|
name: "First user",
|
|
username: "firstuser",
|
|
profile: {
|
|
username: "firstuser",
|
|
upId: "usr-101",
|
|
id: null,
|
|
organization: null,
|
|
organizationId: null,
|
|
},
|
|
avatarUrl: null,
|
|
nonProfileUsername: null,
|
|
},
|
|
slug: "managedevent",
|
|
hidden: false,
|
|
},
|
|
],
|
|
assignAllTeamMembers: false,
|
|
hosts: [],
|
|
isManagedEventType: false,
|
|
})
|
|
).toBe(true);
|
|
});
|
|
it("should return false if assignAllTeamMembers is selected", () => {
|
|
expect(
|
|
checkForEmptyAssignment({
|
|
assignedUsers: [],
|
|
assignAllTeamMembers: true,
|
|
hosts: [],
|
|
isManagedEventType: false,
|
|
})
|
|
).toBe(false);
|
|
});
|
|
it("should return false if non-managed event type has hosts assigned", () => {
|
|
expect(
|
|
checkForEmptyAssignment({
|
|
assignedUsers: [],
|
|
assignAllTeamMembers: false,
|
|
hosts: [{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0 }],
|
|
isManagedEventType: false,
|
|
})
|
|
).toBe(false);
|
|
});
|
|
it("should return false if managed event type has assigned users", () => {
|
|
expect(
|
|
checkForEmptyAssignment({
|
|
assignedUsers: [
|
|
{
|
|
created: true,
|
|
owner: {
|
|
id: 101,
|
|
avatar: "avatar.svg",
|
|
email: "firstuser@cal.com",
|
|
membership: "OWNER",
|
|
name: "First user",
|
|
username: "firstuser",
|
|
profile: {
|
|
username: "firstuser",
|
|
upId: "usr-101",
|
|
id: null,
|
|
organization: null,
|
|
organizationId: null,
|
|
},
|
|
avatarUrl: null,
|
|
nonProfileUsername: null,
|
|
},
|
|
slug: "managedevent",
|
|
hidden: false,
|
|
},
|
|
],
|
|
assignAllTeamMembers: false,
|
|
hosts: [],
|
|
isManagedEventType: true,
|
|
})
|
|
).toBe(false);
|
|
});
|
|
});
|