* init * fix type * fix a re-render infinite loop because of missing readOnly (╯°□°)╯︵ ┻━┻) * further fixes * improvement * fix expiry datetime check * remove unnecessary prismaMock def * revert * fix test * add test ids * remove unit tests in favor of e2e * e2e test update * fix e2e * fix e2e * remove unnecessary change * abstract into injectable object * further improvements * fix label not selecting radio * fix type * code improvement * DI implementation * fix type * fix quick copy * code improvement and a few fixes * further improvements and NITS * further into DI * select * improve link list sorting * prep for easier conflict resolution * add back translations * using useCopy instead * improvement * add index to update salt and have different hash generation * fix private link description * fix increment regression in expiry logic * fixes * address feedback * use extractHostTimezone in event type listing * remove unused function * remove translationBundler * -_- * address feedback * further changes * address more feedback * NIT * address improvement suggestions * use extractHostTimezone * remove console log * pre update * code improvement * further fixes * cleanup * -_-
130 lines
3.5 KiB
TypeScript
130 lines
3.5 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,
|
|
scheduleId: null,
|
|
user: { timeZone: "America/New_York" },
|
|
},
|
|
],
|
|
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,
|
|
scheduleId: null,
|
|
user: { timeZone: "America/New_York" },
|
|
},
|
|
],
|
|
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: [
|
|
{
|
|
userId: 101,
|
|
isFixed: false,
|
|
priority: 2,
|
|
weight: 100,
|
|
scheduleId: null,
|
|
user: { timeZone: "America/New_York" },
|
|
},
|
|
],
|
|
isManagedEventType: true,
|
|
})
|
|
).toBe(false);
|
|
});
|
|
});
|