Files
calendar/apps/web/test/lib/CheckForEmptyAssignment.test.ts
T
a48d190af3 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 <74371312+Amit91848@users.noreply.github.com>
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2024-10-15 17:36:00 +01:00

107 lines
3.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { checkForEmptyAssignment } from "@calcom/lib/event-types/utils/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, scheduleId: null },
],
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, scheduleId: null },
],
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);
});
});