diff --git a/schema.graphql b/schema.graphql index cc2896ead0..1d22153836 100644 --- a/schema.graphql +++ b/schema.graphql @@ -5,6 +5,7 @@ directive @role(requires: UserType) on FIELD_DEFINITION type ActionItem { _id: ID! actionItemCategory: ActionItemCategory + allotedHours: Float assignee: User assigner: User assignmentDate: Date! @@ -29,16 +30,24 @@ type ActionItemCategory { updatedAt: Date! } +input ActionItemCategoryWhereInput { + is_disabled: Boolean + name_contains: String +} + input ActionItemWhereInput { actionItemCategory_id: ID + assigneeName: String + categoryName: String event_id: ID - is_active: Boolean is_completed: Boolean } enum ActionItemsOrderByInput { createdAt_ASC createdAt_DESC + dueDate_ASC + dueDate_DESC } type Address { @@ -269,6 +278,7 @@ interface ConnectionPageInfo { scalar CountryCode input CreateActionItemInput { + allotedHours: Float assigneeId: ID! dueDate: Date eventId: ID @@ -1080,7 +1090,7 @@ type Mutation { checkIn(data: CheckInCheckOutInput!): CheckIn! checkOut(data: CheckInCheckOutInput!): CheckOut! createActionItem(actionItemCategoryId: ID!, data: CreateActionItemInput!): ActionItem! - createActionItemCategory(name: String!, organizationId: ID!): ActionItemCategory! + createActionItemCategory(isDisabled: Boolean!, name: String!, organizationId: ID!): ActionItemCategory! createAdmin(data: UserAndOrganizationInput!): CreateAdminPayload! createAdvertisement(input: CreateAdvertisementInput!): CreateAdvertisementPayload createAgendaCategory(input: CreateAgendaCategoryInput!): AgendaCategory! @@ -1476,9 +1486,9 @@ type PostsConnection { } type Query { - actionItemCategoriesByOrganization(organizationId: ID!): [ActionItemCategory] + actionItemCategoriesByOrganization(orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemCategoryWhereInput): [ActionItemCategory] actionItemsByEvent(eventId: ID!): [ActionItem] - actionItemsByOrganization(orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemWhereInput): [ActionItem] + actionItemsByOrganization(eventId: ID, orderBy: ActionItemsOrderByInput, organizationId: ID!, where: ActionItemWhereInput): [ActionItem] adminPlugin(orgId: ID!): [Plugin] advertisementsConnection(after: String, before: String, first: PositiveInt, last: PositiveInt): AdvertisementsConnection agendaCategory(id: ID!): AgendaCategory! @@ -1661,6 +1671,7 @@ input UpdateActionItemCategoryInput { } input UpdateActionItemInput { + allotedHours: Float assigneeId: ID completionDate: Date dueDate: Date diff --git a/src/models/ActionItem.ts b/src/models/ActionItem.ts index ac9d191012..fe99964a0a 100644 --- a/src/models/ActionItem.ts +++ b/src/models/ActionItem.ts @@ -4,56 +4,63 @@ import type { InterfaceUser } from "./User"; import type { InterfaceEvent } from "./Event"; import type { InterfaceActionItemCategory } from "./ActionItemCategory"; import { MILLISECONDS_IN_A_WEEK } from "../constants"; +import type { InterfaceOrganization } from "./Organization"; /** * Interface representing a database document for ActionItem in MongoDB. */ export interface InterfaceActionItem { _id: Types.ObjectId; - assigneeId: PopulatedDoc; - assignerId: PopulatedDoc; - actionItemCategoryId: PopulatedDoc; + assignee: PopulatedDoc; + assigner: PopulatedDoc; + actionItemCategory: PopulatedDoc< + InterfaceActionItemCategory & Document + > | null; preCompletionNotes: string; postCompletionNotes: string; assignmentDate: Date; dueDate: Date; completionDate: Date; isCompleted: boolean; - eventId: PopulatedDoc; - creatorId: PopulatedDoc; + allotedHours: number | null; + organization: PopulatedDoc; + event: PopulatedDoc; + creator: PopulatedDoc; createdAt: Date; updatedAt: Date; } /** * Defines the schema for the ActionItem document. - * @param assigneeId - User to whom the ActionItem is assigned. - * @param assignerId - User who assigned the ActionItem. - * @param actionItemCategoryId - ActionItemCategory to which the ActionItem belongs. + * @param assignee - User to whom the ActionItem is assigned. + * @param assigner - User who assigned the ActionItem. + * @param actionItemCategory - ActionItemCategory to which the ActionItem belongs. * @param preCompletionNotes - Notes recorded before completion. * @param postCompletionNotes - Notes recorded after completion. * @param assignmentDate - Date when the ActionItem was assigned. * @param dueDate - Due date for the ActionItem. * @param completionDate - Date when the ActionItem was completed. * @param isCompleted - Flag indicating if the ActionItem is completed. - * @param eventId - Optional: Event to which the ActionItem is related. - * @param creatorId - User who created the ActionItem. + * @param allotedHours - Optional: Number of hours alloted for the ActionItem. + * @param event - Optional: Event to which the ActionItem is related. + * @param organization - Organization to which the ActionItem belongs. + * @param creator - User who created the ActionItem. * @param createdAt - Timestamp when the ActionItem was created. * @param updatedAt - Timestamp when the ActionItem was last updated. */ const actionItemSchema = new Schema( { - assigneeId: { + assignee: { type: Schema.Types.ObjectId, ref: "User", required: true, }, - assignerId: { + assigner: { type: Schema.Types.ObjectId, ref: "User", required: true, }, - actionItemCategoryId: { + actionItemCategory: { type: Schema.Types.ObjectId, ref: "ActionItemCategory", required: true, @@ -84,11 +91,19 @@ const actionItemSchema = new Schema( required: true, default: false, }, - eventId: { + allotedHours: { + type: Number, + }, + organization: { + type: Schema.Types.ObjectId, + ref: "Organization", + required: true, + }, + event: { type: Schema.Types.ObjectId, ref: "Event", }, - creatorId: { + creator: { type: Schema.Types.ObjectId, ref: "User", required: true, diff --git a/src/resolvers/ActionItem/actionItemCategory.ts b/src/resolvers/ActionItem/actionItemCategory.ts deleted file mode 100644 index 47683a0203..0000000000 --- a/src/resolvers/ActionItem/actionItemCategory.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { ActionItemResolvers } from "../../types/generatedGraphQLTypes"; -import { ActionItemCategory } from "../../models"; - -/** - * Resolver function to fetch the category of an action item. - * @param parent - The parent object containing the action item data. - * @returns The category of the action item found in the database. - */ -export const actionItemCategory: ActionItemResolvers["actionItemCategory"] = - async (parent) => { - return ActionItemCategory.findOne({ - _id: parent.actionItemCategoryId, - }).lean(); - }; diff --git a/src/resolvers/ActionItem/assignee.ts b/src/resolvers/ActionItem/assignee.ts deleted file mode 100644 index 22c4c9a560..0000000000 --- a/src/resolvers/ActionItem/assignee.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { ActionItemResolvers } from "../../types/generatedGraphQLTypes"; -import { User } from "../../models"; - -/** - * Resolver function for the `assignee` field of an `ActionItem`. - * - * This function fetches the user who is assigned to a specific action item. - * - * @param parent - The parent object representing the action item. It contains information about the action item, including the ID of the user assigned to it. - * @returns A promise that resolves to the user document found in the database. This document represents the user assigned to the action item. - * - * @example - * If the action item with an ID of `123` is assigned to a user with an ID of `456`, this resolver will find the user with the ID `456` in the database and return their information. - * - * @see User - The User model used to interact with the users collection in the database. - * @see ActionItemResolvers - The type definition for the resolvers of the ActionItem fields. - */ -export const assignee: ActionItemResolvers["assignee"] = async (parent) => { - return User.findOne({ - _id: parent.assigneeId, - }).lean(); -}; diff --git a/src/resolvers/ActionItem/assigner.ts b/src/resolvers/ActionItem/assigner.ts deleted file mode 100644 index 7b763a06d4..0000000000 --- a/src/resolvers/ActionItem/assigner.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { ActionItemResolvers } from "../../types/generatedGraphQLTypes"; -import { User } from "../../models"; - -/** - * Resolver function for the `assigner` field of an `ActionItem`. - * - * This function fetches the user who is the assigner of a given action item. - * It uses the `assignerId` field from the parent `ActionItem` object to find the corresponding user in the database. - * The user details are then returned in a plain JavaScript object format. - * - * @param parent - The parent `ActionItem` object. This contains the `assignerId` field, which is used to find the user. - * @returns A promise that resolves to the user object found in the database, or `null` if no user is found. - * - */ -export const assigner: ActionItemResolvers["assigner"] = async (parent) => { - return User.findOne({ - _id: parent.assignerId, - }).lean(); -}; diff --git a/src/resolvers/ActionItem/creator.ts b/src/resolvers/ActionItem/creator.ts deleted file mode 100644 index f286ba0d93..0000000000 --- a/src/resolvers/ActionItem/creator.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { ActionItemResolvers } from "../../types/generatedGraphQLTypes"; -import { User } from "../../models"; - -/** - * Resolver function for the `creator` field of an `ActionItem`. - * - * This function fetches the user who is the creator of a given action item. - * It uses the `creatorId` field from the parent `ActionItem` object to find the corresponding user in the database. - * The user details are then returned in a plain JavaScript object format. - * - * @param parent - The parent `ActionItem` object. This contains the `creatorId` field, which is used to find the user. - * @returns A promise that resolves to the user object found in the database, or `null` if no user is found. - * - * @example - * ```typescript - * const actionItem = { - * creatorId: "60d0fe4f5311236168a109cb" - * }; - * const user = await creator(actionItem); - * console.log(user); - * // Output might be: { _id: "60d0fe4f5311236168a109cb", name: "Jane Doe", email: "jane.doe@example.com" } - * ``` - */ -export const creator: ActionItemResolvers["creator"] = async (parent) => { - return User.findOne({ - _id: parent.creatorId, - }).lean(); -}; diff --git a/src/resolvers/ActionItem/event.ts b/src/resolvers/ActionItem/event.ts deleted file mode 100644 index b4584d964f..0000000000 --- a/src/resolvers/ActionItem/event.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { ActionItemResolvers } from "../../types/generatedGraphQLTypes"; -import { Event } from "../../models"; - -/** - * Resolver function for the `event` field of an `ActionItem`. - * - * This function retrieves the event associated with a specific action item. - * - * @param parent - The parent object representing the action item. It contains information about the action item, including the ID of the associated event. - * @returns A promise that resolves to the event document found in the database. This document represents the event associated with the action item. - * - * @example - * Here's how you might use this resolver in your GraphQL schema: - * - * ```graphql - * type ActionItem { - * event: Event - * # other fields... - * } - * ``` - * - * @example - * If the action item with an ID of `123` is associated with an event with an ID of `789`, this resolver will find the event with the ID `789` in the database and return its information. - * - * @see Event - The Event model used to interact with the events collection in the database. - * @see ActionItemResolvers - The type definition for the resolvers of the ActionItem fields. - */ -export const event: ActionItemResolvers["event"] = async (parent) => { - return Event.findOne({ - _id: parent.eventId, - }).lean(); -}; diff --git a/src/resolvers/ActionItem/index.ts b/src/resolvers/ActionItem/index.ts deleted file mode 100644 index dc5979e0d9..0000000000 --- a/src/resolvers/ActionItem/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { ActionItemResolvers } from "../../types/generatedGraphQLTypes"; -import { assignee } from "./assignee"; -import { assigner } from "./assigner"; -import { actionItemCategory } from "./actionItemCategory"; -import { event } from "./event"; -import { creator } from "./creator"; - -export const ActionItem: ActionItemResolvers = { - assignee, - assigner, - actionItemCategory, - event, - creator, -}; diff --git a/src/resolvers/ActionItemCategory/index.ts b/src/resolvers/ActionItemCategory/index.ts index 94bdba820f..9e63b3ee1b 100644 --- a/src/resolvers/ActionItemCategory/index.ts +++ b/src/resolvers/ActionItemCategory/index.ts @@ -1,8 +1,6 @@ import type { ActionItemCategoryResolvers } from "../../types/generatedGraphQLTypes"; -import { organization } from "./organization"; import { creator } from "./creator"; export const ActionItemCategory: ActionItemCategoryResolvers = { - organization, creator, }; diff --git a/src/resolvers/ActionItemCategory/organization.ts b/src/resolvers/ActionItemCategory/organization.ts deleted file mode 100644 index 5c800a5ada..0000000000 --- a/src/resolvers/ActionItemCategory/organization.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { ActionItemCategoryResolvers } from "../../types/generatedGraphQLTypes"; -import { Organization } from "../../models"; - -/** - * Resolver function for the `organization` field of an `ActionItemCategory`. - * - * This function fetches the organization associated with a given action item category. - * It uses the `organizationId` field from the parent `ActionItemCategory` object to find the corresponding organization in the database. - * The organization details are then returned in a plain JavaScript object format. - * - * @param parent - The parent `ActionItemCategory` object. This contains the `organizationId` field, which is used to find the organization. - * @returns A promise that resolves to the organization object found in the database, or `null` if no organization is found. - * - * @example - * ```typescript - * const actionItemCategory = { - * organizationId: "60d0fe4f5311236168a109cc" - * }; - * const organization = await organization(actionItemCategory); - * console.log(organization); - * // Output might be: { _id: "60d0fe4f5311236168a109cc", name: "Tech Corp", address: "123 Tech Lane" } - * ``` - */ -export const organization: ActionItemCategoryResolvers["organization"] = async ( - parent, -) => { - return Organization.findOne({ - _id: parent.organizationId, - }).lean(); -}; diff --git a/src/resolvers/Mutation/createActionItem.ts b/src/resolvers/Mutation/createActionItem.ts index 8491873e63..c38357a282 100644 --- a/src/resolvers/Mutation/createActionItem.ts +++ b/src/resolvers/Mutation/createActionItem.ts @@ -217,13 +217,15 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( // Creates and returns the new action item. const createActionItem = await ActionItem.create({ - assigneeId: args.data.assigneeId, - assignerId: context.userId, - actionItemCategoryId: args.actionItemCategoryId, + assignee: args.data.assigneeId, + assigner: context.userId, + actionItemCategory: args.actionItemCategoryId, preCompletionNotes: args.data.preCompletionNotes, + allotedHours: args.data.allotedHours, dueDate: args.data.dueDate, - eventId: args.data.eventId, - creatorId: context.userId, + event: args.data.eventId, + organization: actionItemCategory.organizationId, + creator: context.userId, }); return createActionItem.toObject(); diff --git a/src/resolvers/Mutation/createActionItemCategory.ts b/src/resolvers/Mutation/createActionItemCategory.ts index 711f22449e..43168d6ac3 100644 --- a/src/resolvers/Mutation/createActionItemCategory.ts +++ b/src/resolvers/Mutation/createActionItemCategory.ts @@ -111,6 +111,7 @@ export const createActionItemCategory: MutationResolvers["createActionItemCatego // Creates new actionItemCategory. const createdActionItemCategory = await ActionItemCategory.create({ name: args.name, + isDisabled: args.isDisabled, organizationId: args.organizationId, creatorId: context.userId, }); diff --git a/src/resolvers/Mutation/removeActionItem.ts b/src/resolvers/Mutation/removeActionItem.ts index 30879154dd..d68d8eae11 100644 --- a/src/resolvers/Mutation/removeActionItem.ts +++ b/src/resolvers/Mutation/removeActionItem.ts @@ -82,7 +82,7 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async ( const actionItem = await ActionItem.findOne({ _id: args.id, }) - .populate("actionItemCategoryId") + .populate("actionItemCategory") .lean(); // Checks if the actionItem exists @@ -96,24 +96,24 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async ( const currentUserIsOrgAdmin = currentUserAppProfile.adminFor.some( (ogranizationId) => - ogranizationId === actionItem.actionItemCategoryId.organizationId || + ogranizationId === actionItem.organization || new mongoose.Types.ObjectId(ogranizationId?.toString()).equals( - actionItem.actionItemCategoryId.organizationId, + actionItem.organization, ), ); let currentUserIsEventAdmin = false; - if (actionItem.eventId) { + if (actionItem.event) { let currEvent: InterfaceEvent | null; - const eventFoundInCache = await findEventsInCache([actionItem.eventId]); + const eventFoundInCache = await findEventsInCache([actionItem.event]); currEvent = eventFoundInCache[0]; if (eventFoundInCache[0] === null) { currEvent = await Event.findOne({ - _id: actionItem.eventId, + _id: actionItem.event, }).lean(); if (currEvent !== null) { diff --git a/src/resolvers/Mutation/removeOrganization.ts b/src/resolvers/Mutation/removeOrganization.ts index fc2def62ca..cbe4e298cc 100644 --- a/src/resolvers/Mutation/removeOrganization.ts +++ b/src/resolvers/Mutation/removeOrganization.ts @@ -185,7 +185,7 @@ export const removeOrganization: MutationResolvers["removeOrganization"] = // Remove all ActionItem documents whose actionItemCategory is in the actionItemCategories array await ActionItem.deleteMany({ - actionItemCategoryId: { $in: actionItemCategoriesIds }, + actionItemCategory: { $in: actionItemCategoriesIds }, }); //Remove all the funds specific to organization await Fund.deleteMany({ diff --git a/src/resolvers/Mutation/updateActionItem.ts b/src/resolvers/Mutation/updateActionItem.ts index b00f741b78..265a40104c 100644 --- a/src/resolvers/Mutation/updateActionItem.ts +++ b/src/resolvers/Mutation/updateActionItem.ts @@ -40,6 +40,7 @@ type UpdateActionItemInputType = { preCompletionNotes: string; postCompletionNotes: string; dueDate: Date; + allotedHours: number; completionDate: Date; isCompleted: boolean; }; @@ -93,7 +94,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( const actionItem = await ActionItem.findOne({ _id: args.id, }) - .populate("actionItemCategoryId") + .populate("actionItemCategory") .lean(); // Checks if the actionItem exists @@ -109,7 +110,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( if (args.data.assigneeId) { sameAssignedUser = new mongoose.Types.ObjectId( - actionItem.assigneeId.toString(), + actionItem.assignee.toString(), ).equals(args.data.assigneeId); if (!sameAssignedUser) { @@ -127,7 +128,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( } let userIsOrganizationMember = false; - const currorganizationId = actionItem.actionItemCategoryId.organizationId; + const currorganizationId = actionItem.actionItemCategory.organizationId; userIsOrganizationMember = newAssignedUser.joinedOrganizations.some( (organizationId) => organizationId === currorganizationId || @@ -149,24 +150,24 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( const currentUserIsOrgAdmin = currentUserAppProfile.adminFor.some( (ogranizationId) => - ogranizationId === actionItem.actionItemCategoryId.organizationId || + ogranizationId === actionItem.organization || new mongoose.Types.ObjectId(ogranizationId?.toString()).equals( - actionItem.actionItemCategoryId.organizationId, + actionItem.organization, ), ); let currentUserIsEventAdmin = false; - if (actionItem.eventId) { + if (actionItem.event) { let currEvent: InterfaceEvent | null; - const eventFoundInCache = await findEventsInCache([actionItem.eventId]); + const eventFoundInCache = await findEventsInCache([actionItem.event]); currEvent = eventFoundInCache[0]; if (eventFoundInCache[0] === null) { currEvent = await Event.findOne({ - _id: actionItem.eventId, + _id: actionItem.event, }).lean(); if (currEvent !== null) { @@ -209,7 +210,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( : new Date(); const updatedAssigner = sameAssignedUser - ? actionItem.assignerId + ? actionItem.assigner : context.userId; const updatedActionItem = await ActionItem.findOneAndUpdate( @@ -218,8 +219,9 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( }, { ...(args.data as UpdateActionItemInputType), + assignee: args.data.assigneeId || actionItem.assignee, assignmentDate: updatedAssignmentDate, - assignerId: updatedAssigner, + assigner: updatedAssigner, }, { new: true, diff --git a/src/resolvers/Query/actionItemCategoriesByOrganization.ts b/src/resolvers/Query/actionItemCategoriesByOrganization.ts index ffb8c85e48..24e892207d 100644 --- a/src/resolvers/Query/actionItemCategoriesByOrganization.ts +++ b/src/resolvers/Query/actionItemCategoriesByOrganization.ts @@ -1,16 +1,23 @@ import type { QueryResolvers } from "../../types/generatedGraphQLTypes"; import { ActionItemCategory } from "../../models"; +import { getWhere } from "./helperFunctions/getWhere"; +import { getSort } from "./helperFunctions/getSort"; /** * This query will fetch all categories for the organization from database. * @param _parent- - * @param args - An object that contains `organizationId` which is the _id of the Organization. + * @param args - An object that contains `organizationId` which is the _id of the Organization and `orderBy` which is the sorting order & where which is the filter. * @returns A `categories` object that holds all categories for the Organization. */ export const actionItemCategoriesByOrganization: QueryResolvers["actionItemCategoriesByOrganization"] = async (_parent, args) => { + const sort = getSort(args.orderBy); + const where = getWhere(args.where); const categories = await ActionItemCategory.find({ organizationId: args.organizationId, - }).lean(); + ...where, + }) + .sort(sort) + .lean(); return categories; }; diff --git a/src/resolvers/Query/actionItemsByEvent.ts b/src/resolvers/Query/actionItemsByEvent.ts index 08944db8b2..1c58845720 100644 --- a/src/resolvers/Query/actionItemsByEvent.ts +++ b/src/resolvers/Query/actionItemsByEvent.ts @@ -11,7 +11,7 @@ export const actionItemsByEvent: QueryResolvers["actionItemsByEvent"] = async ( args, ) => { const actionItems = await ActionItem.find({ - eventId: args.eventId, + event: args.eventId, }).lean(); return actionItems; diff --git a/src/resolvers/Query/actionItemsByOrganization.ts b/src/resolvers/Query/actionItemsByOrganization.ts index 696f3cdfda..828cf58005 100644 --- a/src/resolvers/Query/actionItemsByOrganization.ts +++ b/src/resolvers/Query/actionItemsByOrganization.ts @@ -1,6 +1,10 @@ import type { QueryResolvers } from "../../types/generatedGraphQLTypes"; -import type { InterfaceActionItem } from "../../models"; -import { ActionItem, ActionItemCategory } from "../../models"; +import type { + InterfaceActionItem, + InterfaceActionItemCategory, + InterfaceUser, +} from "../../models"; +import { ActionItem } from "../../models"; import { getWhere } from "./helperFunctions/getWhere"; import { getSort } from "./helperFunctions/getSort"; /** @@ -11,23 +15,43 @@ import { getSort } from "./helperFunctions/getSort"; */ export const actionItemsByOrganization: QueryResolvers["actionItemsByOrganization"] = async (_parent, args) => { - const where = getWhere(args.where); const sort = getSort(args.orderBy); - - // Get the ids of all ActionItemCategories associated with the organization - const actionItemCategories = await ActionItemCategory.find({ - organizationId: args.organizationId, - }); - const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id, - ); + const where = getWhere(args.where); const actionItems = await ActionItem.find({ - actionItemCategoryId: { $in: actionItemCategoriesIds }, + organization: args.organizationId, + event: args.eventId, ...where, }) + .populate("creator") + .populate("assignee") + .populate("assigner") + .populate("actionItemCategory") + .populate("organization") + .populate("event") .sort(sort) .lean(); - return actionItems; + let filteredActionItems: InterfaceActionItem[] = actionItems; + + // Filter the action items based on category name + if (args.where?.categoryName) { + filteredActionItems = filteredActionItems.filter((item) => { + const tempItem = item as InterfaceActionItem; + const category = + tempItem.actionItemCategory as InterfaceActionItemCategory; + return category.name.includes(args?.where?.categoryName as string); + }); + } + + // Filter the action items based on assignee name + if (args.where?.assigneeName) { + filteredActionItems = filteredActionItems.filter((item) => { + const tempItem = item as InterfaceActionItem; + const assignee = tempItem.assignee as InterfaceUser; + return assignee.firstName.includes(args?.where?.assigneeName as string); + }); + } + + return filteredActionItems; }; diff --git a/src/resolvers/Query/helperFunctions/getSort.ts b/src/resolvers/Query/helperFunctions/getSort.ts index 6ebaeeac7c..d3f68a704c 100644 --- a/src/resolvers/Query/helperFunctions/getSort.ts +++ b/src/resolvers/Query/helperFunctions/getSort.ts @@ -9,6 +9,7 @@ import type { PledgeOrderByInput, CampaignOrderByInput, FundOrderByInput, + ActionItemsOrderByInput, } from "../../../types/generatedGraphQLTypes"; export const getSort = ( @@ -22,6 +23,7 @@ export const getSort = ( | FundOrderByInput | CampaignOrderByInput | PledgeOrderByInput + | ActionItemsOrderByInput > | undefined, ): @@ -320,6 +322,19 @@ export const getSort = ( commentCount: -1, }; break; + + case "dueDate_ASC": + sortPayload = { + dueDate: 1, + }; + break; + + case "dueDate_DESC": + sortPayload = { + dueDate: -1, + }; + break; + default: break; } diff --git a/src/resolvers/Query/helperFunctions/getWhere.ts b/src/resolvers/Query/helperFunctions/getWhere.ts index 0a4de7cbf8..e2288ee6cb 100644 --- a/src/resolvers/Query/helperFunctions/getWhere.ts +++ b/src/resolvers/Query/helperFunctions/getWhere.ts @@ -12,6 +12,7 @@ import type { VenueWhereInput, CampaignWhereInput, PledgeWhereInput, + ActionItemCategoryWhereInput, } from "../../../types/generatedGraphQLTypes"; /** @@ -38,6 +39,7 @@ export const getWhere = ( UserWhereInput & DonationWhereInput & ActionItemWhereInput & + ActionItemCategoryWhereInput & CampaignWhereInput & FundWhereInput & PledgeWhereInput & @@ -200,19 +202,11 @@ export const getWhere = ( }; } - // Return action items that are active - if (where.is_active) { - wherePayload = { - ...wherePayload, - isCompleted: false, - }; - } - // Return action items that are completed - if (where.is_completed) { + if (where.is_completed !== undefined) { wherePayload = { ...wherePayload, - isCompleted: true, + isCompleted: where.is_completed, }; } @@ -348,7 +342,7 @@ export const getWhere = ( }; } - // Returns organizations with name containing provided string + // Returns objects with name containing provided string if (where.name_contains) { wherePayload = { ...wherePayload, @@ -356,7 +350,7 @@ export const getWhere = ( }; } - // Returns organizations with name starts with that provided string + // Returns objects where name starts with provided string if (where.name_starts_with) { const regexp = new RegExp("^" + where.name_starts_with); wherePayload = { @@ -746,24 +740,7 @@ export const getWhere = ( }; } - if (where.name_starts_with) { - const regexp = new RegExp("^" + where.name_starts_with); - wherePayload = { - ...wherePayload, - name: regexp, - }; - } - - if (where.name_contains) { - wherePayload = { - ...wherePayload, - name: { - $regex: where.name_contains, - $options: "i", - }, - }; - } - + // Returns objects with provided fundId condition if (where.fundId) { wherePayload = { ...wherePayload, @@ -771,6 +748,7 @@ export const getWhere = ( }; } + // Returns object with provided organizationId condition if (where.organizationId) { wherePayload = { ...wherePayload, @@ -778,6 +756,7 @@ export const getWhere = ( }; } + // Returns object with provided campaignId condition if (where.campaignId) { wherePayload = { ...wherePayload, @@ -785,6 +764,7 @@ export const getWhere = ( }; } + // Returns objects where volunteerId is present in volunteers list if (where.volunteerId) { wherePayload = { ...wherePayload, @@ -794,5 +774,13 @@ export const getWhere = ( }; } + // Returns object with provided is_disabled condition + if (where.is_disabled !== undefined) { + wherePayload = { + ...wherePayload, + isDisabled: where.is_disabled, + }; + } + return wherePayload; }; diff --git a/src/resolvers/index.ts b/src/resolvers/index.ts index 01f58e313a..38873057ba 100644 --- a/src/resolvers/index.ts +++ b/src/resolvers/index.ts @@ -12,7 +12,6 @@ import { } from "graphql-scalars"; import GraphQLUpload from "graphql-upload/GraphQLUpload.mjs"; import type { Resolvers } from "../types/generatedGraphQLTypes"; -import { ActionItem } from "./ActionItem"; import { ActionItemCategory } from "./ActionItemCategory"; import { AgendaItem } from "./AgendaItem"; import { AgendaSection } from "./AgendaSection"; @@ -44,7 +43,6 @@ import { Advertisement } from "./Advertisement"; import { currentUserExists } from "./middleware/currentUserExists"; const resolvers: Resolvers = { - ActionItem, ActionItemCategory, AgendaItem, AgendaSection, diff --git a/src/typeDefs/enums.ts b/src/typeDefs/enums.ts index a07f8c8741..b3e0a8b4c2 100644 --- a/src/typeDefs/enums.ts +++ b/src/typeDefs/enums.ts @@ -5,6 +5,8 @@ export const enums = gql` enum ActionItemsOrderByInput { createdAt_ASC createdAt_DESC + dueDate_ASC + dueDate_DESC } enum EventOrderByInput { diff --git a/src/typeDefs/inputs.ts b/src/typeDefs/inputs.ts index 48c5527444..65cca30e4d 100644 --- a/src/typeDefs/inputs.ts +++ b/src/typeDefs/inputs.ts @@ -42,6 +42,7 @@ export const inputs = gql` input CreateActionItemInput { assigneeId: ID! preCompletionNotes: String + allotedHours: Float dueDate: Date eventId: ID } @@ -74,10 +75,16 @@ export const inputs = gql` input ActionItemWhereInput { actionItemCategory_id: ID event_id: ID - is_active: Boolean + categoryName: String + assigneeName: String is_completed: Boolean } + input ActionItemCategoryWhereInput { + name_contains: String + is_disabled: Boolean + } + input CreateAgendaCategoryInput { name: String! description: String @@ -423,6 +430,7 @@ export const inputs = gql` postCompletionNotes: String dueDate: Date completionDate: Date + allotedHours: Float isCompleted: Boolean } diff --git a/src/typeDefs/mutations.ts b/src/typeDefs/mutations.ts index c133e8ba9d..c7eccf09e5 100644 --- a/src/typeDefs/mutations.ts +++ b/src/typeDefs/mutations.ts @@ -76,6 +76,7 @@ export const mutations = gql` createActionItemCategory( name: String! + isDisabled: Boolean! organizationId: ID! ): ActionItemCategory! @auth diff --git a/src/typeDefs/queries.ts b/src/typeDefs/queries.ts index f1a51bca0a..4db8616859 100644 --- a/src/typeDefs/queries.ts +++ b/src/typeDefs/queries.ts @@ -11,12 +11,15 @@ export const queries = gql` actionItemsByOrganization( organizationId: ID! + eventId: ID where: ActionItemWhereInput orderBy: ActionItemsOrderByInput ): [ActionItem] actionItemCategoriesByOrganization( organizationId: ID! + where: ActionItemCategoryWhereInput + orderBy: ActionItemsOrderByInput ): [ActionItemCategory] agendaItemByEvent(relatedEventId: ID!): [AgendaItem] diff --git a/src/typeDefs/types.ts b/src/typeDefs/types.ts index acf506b7d8..84f62be68f 100644 --- a/src/typeDefs/types.ts +++ b/src/typeDefs/types.ts @@ -75,6 +75,7 @@ export const types = gql` actionItemCategory: ActionItemCategory preCompletionNotes: String postCompletionNotes: String + allotedHours: Float assignmentDate: Date! dueDate: Date! completionDate: Date! diff --git a/src/types/generatedGraphQLTypes.ts b/src/types/generatedGraphQLTypes.ts index 29213da5c6..354ed4ff6f 100644 --- a/src/types/generatedGraphQLTypes.ts +++ b/src/types/generatedGraphQLTypes.ts @@ -72,6 +72,7 @@ export type ActionItem = { __typename?: 'ActionItem'; _id: Scalars['ID']['output']; actionItemCategory?: Maybe; + allotedHours?: Maybe; assignee?: Maybe; assigner?: Maybe; assignmentDate: Scalars['Date']['output']; @@ -97,16 +98,24 @@ export type ActionItemCategory = { updatedAt: Scalars['Date']['output']; }; +export type ActionItemCategoryWhereInput = { + is_disabled?: InputMaybe; + name_contains?: InputMaybe; +}; + export type ActionItemWhereInput = { actionItemCategory_id?: InputMaybe; + assigneeName?: InputMaybe; + categoryName?: InputMaybe; event_id?: InputMaybe; - is_active?: InputMaybe; is_completed?: InputMaybe; }; export type ActionItemsOrderByInput = | 'createdAt_ASC' - | 'createdAt_DESC'; + | 'createdAt_DESC' + | 'dueDate_ASC' + | 'dueDate_DESC'; export type Address = { __typename?: 'Address'; @@ -343,6 +352,7 @@ export type ConnectionPageInfo = { }; export type CreateActionItemInput = { + allotedHours?: InputMaybe; assigneeId: Scalars['ID']['input']; dueDate?: InputMaybe; eventId?: InputMaybe; @@ -1389,6 +1399,7 @@ export type MutationCreateActionItemArgs = { export type MutationCreateActionItemCategoryArgs = { + isDisabled: Scalars['Boolean']['input']; name: Scalars['String']['input']; organizationId: Scalars['ID']['input']; }; @@ -2333,7 +2344,9 @@ export type Query = { export type QueryActionItemCategoriesByOrganizationArgs = { + orderBy?: InputMaybe; organizationId: Scalars['ID']['input']; + where?: InputMaybe; }; @@ -2343,6 +2356,7 @@ export type QueryActionItemsByEventArgs = { export type QueryActionItemsByOrganizationArgs = { + eventId?: InputMaybe; orderBy?: InputMaybe; organizationId: Scalars['ID']['input']; where?: InputMaybe; @@ -2779,6 +2793,7 @@ export type UpdateActionItemCategoryInput = { }; export type UpdateActionItemInput = { + allotedHours?: InputMaybe; assigneeId?: InputMaybe; completionDate?: InputMaybe; dueDate?: InputMaybe; @@ -3298,6 +3313,7 @@ export type ResolversInterfaceTypes<_RefType extends Record> = export type ResolversTypes = { ActionItem: ResolverTypeWrapper; ActionItemCategory: ResolverTypeWrapper; + ActionItemCategoryWhereInput: ActionItemCategoryWhereInput; ActionItemWhereInput: ActionItemWhereInput; ActionItemsOrderByInput: ActionItemsOrderByInput; Address: ResolverTypeWrapper
; @@ -3514,6 +3530,7 @@ export type ResolversTypes = { export type ResolversParentTypes = { ActionItem: InterfaceActionItemModel; ActionItemCategory: InterfaceActionItemCategoryModel; + ActionItemCategoryWhereInput: ActionItemCategoryWhereInput; ActionItemWhereInput: ActionItemWhereInput; Address: Address; AddressInput: AddressInput; @@ -3714,6 +3731,7 @@ export type RoleDirectiveResolver = { _id?: Resolver; actionItemCategory?: Resolver, ParentType, ContextType>; + allotedHours?: Resolver, ParentType, ContextType>; assignee?: Resolver, ParentType, ContextType>; assigner?: Resolver, ParentType, ContextType>; assignmentDate?: Resolver; @@ -4319,7 +4337,7 @@ export type MutationResolvers>; checkOut?: Resolver>; createActionItem?: Resolver>; - createActionItemCategory?: Resolver>; + createActionItemCategory?: Resolver>; createAdmin?: Resolver>; createAdvertisement?: Resolver, ParentType, ContextType, RequireFields>; createAgendaCategory?: Resolver>; diff --git a/tests/helpers/actionItem.ts b/tests/helpers/actionItem.ts index 6fe3c3a395..86eab57629 100644 --- a/tests/helpers/actionItem.ts +++ b/tests/helpers/actionItem.ts @@ -33,10 +33,11 @@ export const createTestActionItem = async (): Promise< }); const testActionItem = await ActionItem.create({ - creatorId: testUser?._id, - assigneeId: randomUser?._id, - assignerId: testUser?._id, - actionItemCategoryId: testCategory?._id, + creator: testUser?._id, + assignee: randomUser?._id, + assigner: testUser?._id, + actionItemCategory: testCategory?._id, + organization: testOrganization?._id, }); return [testUser, testOrganization, testCategory, testActionItem, randomUser]; @@ -46,25 +47,28 @@ interface InterfaceCreateNewTestAction { currUserId: string; assignedUserId: string; actionItemCategoryId: string; + organizationId: string; } export const createNewTestActionItem = async ({ currUserId, assignedUserId, actionItemCategoryId, + organizationId, }: InterfaceCreateNewTestAction): Promise => { const newTestActionItem = await ActionItem.create({ - creatorId: currUserId, - assigneeId: assignedUserId, - assignerId: currUserId, - actionItemCategoryId: actionItemCategoryId, + creator: currUserId, + assignee: assignedUserId, + assigner: currUserId, + actionItemCategory: actionItemCategoryId, + organization: organizationId, }); return newTestActionItem; }; export const createTestActionItems = async (): Promise< - [TestUserType, TestEventType, TestOrganizationType] + [TestUserType, TestUserType, TestEventType, TestOrganizationType] > => { const randomUser = await createTestUser(); const [testUser, testOrganization, testCategory] = await createTestCategory(); @@ -76,26 +80,29 @@ export const createTestActionItems = async (): Promise< }); const testActionItem1 = await ActionItem.create({ - creatorId: testUser?._id, - assigneeId: randomUser?._id, - assignerId: testUser?._id, - actionItemCategoryId: testCategory?._id, + creator: testUser?._id, + assignee: randomUser?._id, + assigner: testUser?._id, + actionItemCategory: testCategory?._id, + organization: testOrganization?._id, isCompleted: true, }); const testActionItem2 = await ActionItem.create({ - creatorId: testUser?._id, - assigneeId: randomUser?._id, - assignerId: testUser?._id, - actionItemCategoryId: testCategory?._id, + creator: testUser?._id, + assignee: randomUser?._id, + assigner: testUser?._id, + actionItemCategory: testCategory?._id, + organization: testOrganization?._id, isCompleted: false, }); await ActionItem.create({ - creatorId: testUser?._id, - assigneeId: randomUser?._id, - assignerId: testUser?._id, - actionItemCategoryId: testCategory2?._id, + creator: testUser?._id, + assignee: randomUser?._id, + assigner: testUser?._id, + actionItemCategory: testCategory2?._id, + organization: testOrganization?._id, isCompleted: true, }); @@ -118,7 +125,7 @@ export const createTestActionItems = async (): Promise< _id: testActionItem1?._id, }, { - eventId: testEvent?._id, + event: testEvent?._id, }, ); @@ -127,9 +134,9 @@ export const createTestActionItems = async (): Promise< _id: testActionItem2?._id, }, { - eventId: testEvent?._id, + event: testEvent?._id, }, ); - return [testUser, testEvent, testOrganization]; + return [testUser, randomUser, testEvent, testOrganization]; }; diff --git a/tests/resolvers/ActionItem/assignee.spec.ts b/tests/resolvers/ActionItem/assignee.spec.ts deleted file mode 100644 index d910b54919..0000000000 --- a/tests/resolvers/ActionItem/assignee.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import "dotenv/config"; -import { assignee as assigneeResolver } from "../../../src/resolvers/ActionItem/assignee"; -import { connect, disconnect } from "../../helpers/db"; -import type mongoose from "mongoose"; -import { beforeAll, afterAll, describe, it, expect } from "vitest"; -import { User } from "../../../src/models"; -import type { TestUserType } from "../../helpers/userAndOrg"; -import type { TestActionItemType } from "../../helpers/actionItem"; -import { createTestActionItem } from "../../helpers/actionItem"; - -let MONGOOSE_INSTANCE: typeof mongoose; -let randomTestUser: TestUserType; -let testActionItem: TestActionItemType; - -beforeAll(async () => { - MONGOOSE_INSTANCE = await connect(); - [, , , testActionItem, randomTestUser] = await createTestActionItem(); -}); - -afterAll(async () => { - await disconnect(MONGOOSE_INSTANCE); -}); - -describe("resolvers -> ActionItem -> assignee", () => { - it(`returns the assignee for parent action item`, async () => { - const parent = testActionItem?.toObject(); - - const assignedToPayload = await assigneeResolver?.(parent, {}, {}); - - const assignedToObject = await User.findOne({ - _id: randomTestUser?._id, - }).lean(); - - expect(assignedToPayload).toEqual(assignedToObject); - }); -}); diff --git a/tests/resolvers/ActionItem/assigner.spec.ts b/tests/resolvers/ActionItem/assigner.spec.ts deleted file mode 100644 index e27fee41cb..0000000000 --- a/tests/resolvers/ActionItem/assigner.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import "dotenv/config"; -import { assigner as assignerResolver } from "../../../src/resolvers/ActionItem/assigner"; -import { connect, disconnect } from "../../helpers/db"; -import type mongoose from "mongoose"; -import { beforeAll, afterAll, describe, it, expect } from "vitest"; -import { User } from "../../../src/models"; -import type { TestUserType } from "../../helpers/userAndOrg"; -import type { TestActionItemType } from "../../helpers/actionItem"; -import { createTestActionItem } from "../../helpers/actionItem"; - -let MONGOOSE_INSTANCE: typeof mongoose; -let testUser: TestUserType; -let testActionItem: TestActionItemType; - -beforeAll(async () => { - MONGOOSE_INSTANCE = await connect(); - [testUser, , , testActionItem] = await createTestActionItem(); -}); - -afterAll(async () => { - await disconnect(MONGOOSE_INSTANCE); -}); - -describe("resolvers -> ActionItem -> assigner", () => { - it(`returns the assigner for parent action item`, async () => { - const parent = testActionItem?.toObject(); - - const assignedByPayload = await assignerResolver?.(parent, {}, {}); - - const assignedByObject = await User.findOne({ - _id: testUser?._id, - }).lean(); - - expect(assignedByPayload).toEqual(assignedByObject); - }); -}); diff --git a/tests/resolvers/ActionItem/category.spec.ts b/tests/resolvers/ActionItem/category.spec.ts deleted file mode 100644 index e7b87bdb94..0000000000 --- a/tests/resolvers/ActionItem/category.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -import "dotenv/config"; -import { actionItemCategory as actionItemCategoryResolver } from "../../../src/resolvers/ActionItem/actionItemCategory"; -import { connect, disconnect } from "../../helpers/db"; -import type mongoose from "mongoose"; -import { beforeAll, afterAll, describe, it, expect } from "vitest"; -import { ActionItemCategory } from "../../../src/models"; -import type { TestActionItemType } from "../../helpers/actionItem"; -import { createTestActionItem } from "../../helpers/actionItem"; -import type { TestActionItemCategoryType } from "../../helpers/actionItemCategory"; - -let MONGOOSE_INSTANCE: typeof mongoose; -let testActionItem: TestActionItemType; -let testCategory: TestActionItemCategoryType; - -beforeAll(async () => { - MONGOOSE_INSTANCE = await connect(); - [, , testCategory, testActionItem] = await createTestActionItem(); -}); - -afterAll(async () => { - await disconnect(MONGOOSE_INSTANCE); -}); - -describe("resolvers -> ActionItem -> actionItemCategory", () => { - it(`returns the actionItemCategory for parent action item`, async () => { - const parent = testActionItem?.toObject(); - - const actionItemCategoryPayload = await actionItemCategoryResolver?.( - parent, - {}, - {}, - ); - - const actionItemCategoryObject = await ActionItemCategory.findOne({ - _id: testCategory?._id, - }).lean(); - - expect(actionItemCategoryPayload).toEqual(actionItemCategoryObject); - }); -}); diff --git a/tests/resolvers/ActionItem/creator.spec.ts b/tests/resolvers/ActionItem/creator.spec.ts deleted file mode 100644 index 91a19580bf..0000000000 --- a/tests/resolvers/ActionItem/creator.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import "dotenv/config"; -import { creator as creatorResolver } from "../../../src/resolvers/ActionItem/creator"; -import { connect, disconnect } from "../../helpers/db"; -import type mongoose from "mongoose"; -import { beforeAll, afterAll, describe, it, expect } from "vitest"; -import { User } from "../../../src/models"; -import type { TestUserType } from "../../helpers/userAndOrg"; -import type { TestActionItemType } from "../../helpers/actionItem"; -import { createTestActionItem } from "../../helpers/actionItem"; - -let MONGOOSE_INSTANCE: typeof mongoose; -let testUser: TestUserType; -let testActionItem: TestActionItemType; - -beforeAll(async () => { - MONGOOSE_INSTANCE = await connect(); - [testUser, , , testActionItem] = await createTestActionItem(); -}); - -afterAll(async () => { - await disconnect(MONGOOSE_INSTANCE); -}); - -describe("resolvers -> ActionItem -> creator", () => { - it(`returns the creator for parent action item`, async () => { - const parent = testActionItem?.toObject(); - - const createdByPayload = await creatorResolver?.(parent, {}, {}); - - const createdByObject = await User.findOne({ - _id: testUser?._id, - }).lean(); - - expect(createdByPayload).toEqual(createdByObject); - }); -}); diff --git a/tests/resolvers/ActionItem/event.spec.ts b/tests/resolvers/ActionItem/event.spec.ts deleted file mode 100644 index 1dabeb7508..0000000000 --- a/tests/resolvers/ActionItem/event.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -import "dotenv/config"; -import { event as eventResolver } from "../../../src/resolvers/ActionItem/event"; -import { connect, disconnect } from "../../helpers/db"; -import type mongoose from "mongoose"; -import { beforeAll, afterAll, describe, it, expect } from "vitest"; -import type { InterfaceActionItem } from "../../../src/models"; -import { ActionItem, Event } from "../../../src/models"; -import type { - TestOrganizationType, - TestUserType, -} from "../../helpers/userAndOrg"; -import type { TestActionItemType } from "../../helpers/actionItem"; -import { createTestActionItem } from "../../helpers/actionItem"; -import { nanoid } from "nanoid"; - -let MONGOOSE_INSTANCE: typeof mongoose; -let testUser: TestUserType; -let testOrganization: TestOrganizationType; -let testActionItem: TestActionItemType; - -beforeAll(async () => { - MONGOOSE_INSTANCE = await connect(); - [testUser, testOrganization, , testActionItem] = await createTestActionItem(); -}); - -afterAll(async () => { - await disconnect(MONGOOSE_INSTANCE); -}); - -describe("resolvers -> ActionItem -> event", () => { - it(`returns the event for parent action item`, async () => { - const testEvent = await Event.create({ - title: `title${nanoid().toLowerCase()}`, - description: `description${nanoid().toLowerCase()}`, - allDay: true, - startDate: new Date(), - recurring: true, - isPublic: true, - isRegisterable: true, - creatorId: testUser?._id, - admins: [testUser?._id], - organization: testOrganization?._id, - }); - - const updatedTestActionItem = await ActionItem.findOneAndUpdate( - { - _id: testActionItem?._id, - }, - { - eventId: testEvent?._id, - }, - { - new: true, - }, - ); - - const parent = updatedTestActionItem?.toObject(); - - const eventByPayload = await eventResolver?.( - parent as InterfaceActionItem, - {}, - {}, - ); - - expect(eventByPayload?._id).toEqual(updatedTestActionItem?.eventId); - }); -}); diff --git a/tests/resolvers/ActionItemCategory/organization.spec.ts b/tests/resolvers/ActionItemCategory/organization.spec.ts deleted file mode 100644 index 2c1a06e0d2..0000000000 --- a/tests/resolvers/ActionItemCategory/organization.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import "dotenv/config"; -import { organization as organizationResolver } from "../../../src/resolvers/ActionItemCategory/organization"; -import { connect, disconnect } from "../../helpers/db"; -import type mongoose from "mongoose"; -import { beforeAll, afterAll, describe, it, expect } from "vitest"; -import { Organization } from "../../../src/models"; -import { type TestOrganizationType } from "../../helpers/userAndOrg"; -import type { TestActionItemCategoryType } from "../../helpers/actionItemCategory"; -import { createTestCategory } from "../../helpers/actionItemCategory"; - -let MONGOOSE_INSTANCE: typeof mongoose; -let testOrganization: TestOrganizationType; -let testCategory: TestActionItemCategoryType; - -beforeAll(async () => { - MONGOOSE_INSTANCE = await connect(); - [, testOrganization, testCategory] = await createTestCategory(); -}); - -afterAll(async () => { - await disconnect(MONGOOSE_INSTANCE); -}); - -describe("resolvers -> ActionItemCategory -> org", () => { - it(`returns the organization object for parent actionItemCategory`, async () => { - const parent = testCategory?.toObject(); - - const orgPayload = await organizationResolver?.(parent, {}, {}); - - const orgObject = await Organization.findOne({ - _id: testOrganization?._id, - }).lean(); - - expect(orgPayload).toEqual(orgObject); - }); -}); diff --git a/tests/resolvers/Event/actionItems.spec.ts b/tests/resolvers/Event/actionItems.spec.ts index a984e00f05..716f511d96 100644 --- a/tests/resolvers/Event/actionItems.spec.ts +++ b/tests/resolvers/Event/actionItems.spec.ts @@ -12,7 +12,7 @@ let testEvent: TestEventType; beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); - [, testEvent] = await createTestActionItems(); + [, , testEvent] = await createTestActionItems(); }); afterAll(async () => { diff --git a/tests/resolvers/Mutation/createActionItem.spec.ts b/tests/resolvers/Mutation/createActionItem.spec.ts index e7bd663681..e1093a4975 100644 --- a/tests/resolvers/Mutation/createActionItem.spec.ts +++ b/tests/resolvers/Mutation/createActionItem.spec.ts @@ -259,7 +259,7 @@ describe("resolvers -> Mutation -> createActionItem", () => { expect(createActionItemPayload).toEqual( expect.objectContaining({ - actionItemCategoryId: testCategory?._id, + actionItemCategory: testCategory?._id, }), ); }); @@ -284,7 +284,7 @@ describe("resolvers -> Mutation -> createActionItem", () => { expect(createActionItemPayload).toEqual( expect.objectContaining({ - actionItemCategoryId: testCategory?._id, + actionItemCategory: testCategory?._id, }), ); }); @@ -313,7 +313,7 @@ describe("resolvers -> Mutation -> createActionItem", () => { expect(createActionItemPayload).toEqual( expect.objectContaining({ - actionItemCategoryId: testCategory?._id, + actionItemCategory: testCategory?._id, }), ); }); diff --git a/tests/resolvers/Mutation/createActionItemCategory.spec.ts b/tests/resolvers/Mutation/createActionItemCategory.spec.ts index ba3620dcaa..7c55f65a5b 100644 --- a/tests/resolvers/Mutation/createActionItemCategory.spec.ts +++ b/tests/resolvers/Mutation/createActionItemCategory.spec.ts @@ -47,31 +47,28 @@ describe("resolvers -> Mutation -> createCategory", () => { it(`throws NotFoundError if no user exists with _id === context.userId`, async () => { try { const args: MutationCreateActionItemCategoryArgs = { + isDisabled: false, organizationId: testOrganization?._id, name: "Default", }; - const context = { userId: new Types.ObjectId().toString(), }; - await createActionItemCategoryResolver?.({}, args, context); } catch (error: unknown) { expect((error as Error).message).toEqual(USER_NOT_FOUND_ERROR.MESSAGE); } }); - it(`throws NotFoundError if no organization exists with _id === args.organizationId`, async () => { try { const args: MutationCreateActionItemCategoryArgs = { + isDisabled: false, organizationId: new Types.ObjectId().toString(), name: "Default", }; - const context = { userId: testUser?.id, }; - await createActionItemCategoryResolver?.({}, args, context); } catch (error: unknown) { expect((error as Error).message).toEqual( @@ -79,18 +76,16 @@ describe("resolvers -> Mutation -> createCategory", () => { ); } }); - it(`throws NotAuthorizedError if the user is not a superadmin or the admin of the organization`, async () => { try { const args: MutationCreateActionItemCategoryArgs = { + isDisabled: false, organizationId: testOrganization?._id, name: "Default", }; - const context = { userId: randomUser?.id, }; - await createActionItemCategoryResolver?.({}, args, context); } catch (error: unknown) { expect((error as Error).message).toEqual( @@ -98,23 +93,20 @@ describe("resolvers -> Mutation -> createCategory", () => { ); } }); - it(`creates the actionItemCategory and returns it as an admin`, async () => { const args: MutationCreateActionItemCategoryArgs = { + isDisabled: false, organizationId: testOrganization?._id, name: "Default", }; - const context = { userId: testUser?._id, }; - const createCategoryPayload = await createActionItemCategoryResolver?.( {}, args, context, ); - expect(createCategoryPayload).toEqual( expect.objectContaining({ organizationId: testOrganization?._id, @@ -122,7 +114,6 @@ describe("resolvers -> Mutation -> createCategory", () => { }), ); }); - it(`creates the actionItemCategory and returns it as superAdmin`, async () => { const superAdminTestUser = await AppUserProfile.findOneAndUpdate( { @@ -135,22 +126,19 @@ describe("resolvers -> Mutation -> createCategory", () => { new: true, }, ); - const args: MutationCreateActionItemCategoryArgs = { + isDisabled: false, organizationId: testOrganization?._id, name: "Default2", }; - const context = { userId: superAdminTestUser?.userId, }; - const createCategoryPayload = await createActionItemCategoryResolver?.( {}, args, context, ); - expect(createCategoryPayload).toEqual( expect.objectContaining({ organizationId: testOrganization?._id, @@ -158,18 +146,16 @@ describe("resolvers -> Mutation -> createCategory", () => { }), ); }); - it(`throws ConflictError when the actionItemCategory with given name already exists for the current organization`, async () => { try { const args: MutationCreateActionItemCategoryArgs = { + isDisabled: false, organizationId: testOrganization?._id, name: "Default2", }; - const context = { userId: randomUser?._id, }; - await createActionItemCategoryResolver?.({}, args, context); } catch (error: unknown) { expect((error as Error).message).toEqual( diff --git a/tests/resolvers/Mutation/removeActionItem.spec.ts b/tests/resolvers/Mutation/removeActionItem.spec.ts index 732aba274f..8498afca9f 100644 --- a/tests/resolvers/Mutation/removeActionItem.spec.ts +++ b/tests/resolvers/Mutation/removeActionItem.spec.ts @@ -142,7 +142,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { // console.log(removedActionItemPayload); expect(removedActionItemPayload).toEqual( expect.objectContaining({ - assigneeId: assignedTestUser?._id, + assignee: assignedTestUser?._id, }), ); }); @@ -152,6 +152,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { currUserId: testUser?._id, assignedUserId: randomUser?._id, actionItemCategoryId: testCategory?._id, + organizationId: testOrganization?._id, }); const superAdminTestUser = await AppUserProfile.findOneAndUpdate( @@ -182,7 +183,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { expect(removedActionItemPayload).toEqual( expect.objectContaining({ - assigneeId: randomUser?._id, + assignee: randomUser?._id, }), ); }); @@ -192,6 +193,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { currUserId: testUser?._id, assignedUserId: randomUser?._id, actionItemCategoryId: testCategory?._id, + organizationId: testOrganization?._id, }); const updatedTestActionItem = await ActionItem.findOneAndUpdate( @@ -199,7 +201,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { _id: newTestActionItem?._id, }, { - eventId: new Types.ObjectId().toString(), + event: new Types.ObjectId().toString(), }, { new: true, @@ -226,6 +228,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { currUserId: testUser?._id, assignedUserId: randomUser?._id, actionItemCategoryId: testCategory?._id, + organizationId: testOrganization?._id, }); const updatedTestActionItem = await ActionItem.findOneAndUpdate( @@ -233,7 +236,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { _id: newTestActionItem?._id, }, { - eventId: testEvent?._id, + event: testEvent?._id, }, { new: true, @@ -256,10 +259,11 @@ describe("resolvers -> Mutation -> removeActionItem", () => { expect(removedActionItemPayload).toEqual( expect.objectContaining({ - assigneeId: randomUser?._id, + assignee: randomUser?._id, }), ); }); + it("throws an error if user does not have appUserProfile", async () => { await AppUserProfile.deleteOne({ userId: testUser?._id, diff --git a/tests/resolvers/Mutation/removeEvent.spec.ts b/tests/resolvers/Mutation/removeEvent.spec.ts index 1e79768240..9c88f9caee 100644 --- a/tests/resolvers/Mutation/removeEvent.spec.ts +++ b/tests/resolvers/Mutation/removeEvent.spec.ts @@ -116,11 +116,7 @@ describe("resolvers -> Mutation -> removeEvent", () => { await removeEventResolver?.({}, args, context); } catch (error: unknown) { expect(spy).toBeCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); - if (error instanceof Error) { - EVENT_NOT_FOUND_ERROR.MESSAGE; - } else { - fail(`Expected NotDoundError, but got ${error}`); - } + expect((error as Error).message).toEqual(EVENT_NOT_FOUND_ERROR.MESSAGE); } }); @@ -169,11 +165,9 @@ describe("resolvers -> Mutation -> removeEvent", () => { await removeEventResolver?.({}, args, context); } catch (error: unknown) { expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); - if (error instanceof Error) { - USER_NOT_AUTHORIZED_ERROR.MESSAGE; - } else { - fail(`Expected UnauthorizedError, but got ${error}`); - } + expect((error as Error).message).toEqual( + USER_NOT_AUTHORIZED_ERROR.MESSAGE, + ); } }); @@ -240,7 +234,7 @@ describe("resolvers -> Mutation -> removeEvent", () => { }); it(`removes the events and all action items assiciated with it`, async () => { - [newTestUser, newTestEvent] = await createTestActionItems(); + [newTestUser, , newTestEvent] = await createTestActionItems(); const args: MutationRemoveEventArgs = { id: newTestEvent?.id, diff --git a/tests/resolvers/Mutation/removeOrganization.spec.ts b/tests/resolvers/Mutation/removeOrganization.spec.ts index b89438cdc3..f2dfad353c 100644 --- a/tests/resolvers/Mutation/removeOrganization.spec.ts +++ b/tests/resolvers/Mutation/removeOrganization.spec.ts @@ -143,10 +143,11 @@ beforeAll(async () => { }); testActionItem = await ActionItem.create({ - creatorId: testUsers[0]?._id, - assigneeId: testUsers[1]?._id, - assignerId: testUsers[0]?._id, - actionItemCategoryId: testCategory?._id, + creator: testUsers[0]?._id, + assignee: testUsers[1]?._id, + assigner: testUsers[0]?._id, + actionItemCategory: testCategory?._id, + organization: testOrganization?._id, }); await Organization.updateOne( diff --git a/tests/resolvers/Mutation/updateActionItem.spec.ts b/tests/resolvers/Mutation/updateActionItem.spec.ts index fa0d6a77fc..b7406cd6fa 100644 --- a/tests/resolvers/Mutation/updateActionItem.spec.ts +++ b/tests/resolvers/Mutation/updateActionItem.spec.ts @@ -191,8 +191,8 @@ describe("resolvers -> Mutation -> updateActionItem", () => { expect(updatedActionItemPayload).toEqual( expect.objectContaining({ - assigneeId: assignedTestUser?._id, - actionItemCategoryId: testCategory?._id, + assignee: assignedTestUser?._id, + actionItemCategory: testCategory?._id, }), ); }); @@ -229,8 +229,8 @@ describe("resolvers -> Mutation -> updateActionItem", () => { expect(updatedActionItemPayload).toEqual( expect.objectContaining({ - assigneeId: testUser?._id, - actionItemCategoryId: testCategory?._id, + assignee: testUser?._id, + actionItemCategory: testCategory?._id, }), ); }); @@ -241,7 +241,7 @@ describe("resolvers -> Mutation -> updateActionItem", () => { _id: testActionItem?._id, }, { - eventId: new Types.ObjectId().toString(), + event: new Types.ObjectId().toString(), }, { new: true, @@ -281,7 +281,7 @@ describe("resolvers -> Mutation -> updateActionItem", () => { _id: testActionItem?._id, }, { - eventId: testEvent?._id, + event: testEvent?._id, }, { new: true, @@ -290,7 +290,7 @@ describe("resolvers -> Mutation -> updateActionItem", () => { const args: MutationUpdateActionItemArgs = { data: { - assigneeId: testUser?._id, + isCompleted: true, }, id: updatedTestActionItem?._id.toString() ?? "", }; @@ -307,8 +307,8 @@ describe("resolvers -> Mutation -> updateActionItem", () => { expect(updatedActionItemPayload).toEqual( expect.objectContaining({ - actionItemCategoryId: testCategory?._id, - assigneeId: testUser?._id, + actionItemCategory: testCategory?._id, + isCompleted: true, }), ); }); diff --git a/tests/resolvers/Query/actionItemsByEvent.spec.ts b/tests/resolvers/Query/actionItemsByEvent.spec.ts index 9f5dc830e6..7ea397345b 100644 --- a/tests/resolvers/Query/actionItemsByEvent.spec.ts +++ b/tests/resolvers/Query/actionItemsByEvent.spec.ts @@ -13,7 +13,7 @@ let testEvent: TestEventType; beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); - [, testEvent] = await createTestActionItems(); + [, , testEvent] = await createTestActionItems(); }); afterAll(async () => { @@ -33,7 +33,7 @@ describe("resolvers -> Query -> actionItemsByEvent", () => { ); const actionItemsByEventInfo = await ActionItem.find({ - eventId: testEvent?._id, + event: testEvent?._id, }).lean(); expect(actionItemsByEventPayload).toEqual(actionItemsByEventInfo); diff --git a/tests/resolvers/Query/actionItemsByOrganization.spec.ts b/tests/resolvers/Query/actionItemsByOrganization.spec.ts index 9d450d8ad1..8437ad5cdd 100644 --- a/tests/resolvers/Query/actionItemsByOrganization.spec.ts +++ b/tests/resolvers/Query/actionItemsByOrganization.spec.ts @@ -1,4 +1,5 @@ import "dotenv/config"; +import type { InterfaceActionItem } from "../../../src/models"; import { ActionItem, ActionItemCategory } from "../../../src/models"; import { connect, disconnect } from "../../helpers/db"; import type { @@ -10,16 +11,21 @@ import { actionItemsByOrganization as actionItemsByOrganizationResolver } from " import { beforeAll, afterAll, describe, it, expect } from "vitest"; import type mongoose from "mongoose"; import { createTestActionItems } from "../../helpers/actionItem"; -import type { TestOrganizationType } from "../../helpers/userAndOrg"; +import type { + TestOrganizationType, + TestUserType, +} from "../../helpers/userAndOrg"; import type { TestEventType } from "../../helpers/events"; let MONGOOSE_INSTANCE: typeof mongoose; let testOrganization: TestOrganizationType; let testEvent: TestEventType; +let testAssigneeUser: TestUserType; beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); - [, testEvent, testOrganization] = await createTestActionItems(); + [, testAssigneeUser, testEvent, testOrganization] = + await createTestActionItems(); }); afterAll(async () => { @@ -27,30 +33,59 @@ afterAll(async () => { }); describe("resolvers -> Query -> actionItemsByOrganization", () => { - it(`returns list of all action items associated with an organization in ascending order`, async () => { + it(`returns list of all action items associated with an organization in ascending order where eventId is not null`, async () => { const orderBy: ActionItemsOrderByInput = "createdAt_ASC"; const args: QueryActionItemsByOrganizationArgs = { organizationId: testOrganization?._id, + eventId: testEvent?._id, orderBy, }; const actionItemsByOrganizationPayload = - await actionItemsByOrganizationResolver?.({}, args, {}); + (await actionItemsByOrganizationResolver?.( + {}, + args, + {}, + )) as InterfaceActionItem[]; - const actionItemCategories = await ActionItemCategory.find({ - organizationId: args.organizationId, - }); - const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id, + const actionItemsByOrganizationInfo = await ActionItem.find({ + organization: args.organizationId, + event: args.eventId, + }).lean(); + + expect(actionItemsByOrganizationPayload[0]).toEqual( + expect.objectContaining({ + _id: actionItemsByOrganizationInfo[0]._id, + }), ); + }); + + it(`returns list of all action items associated with an organization in ascending order where eventId is null`, async () => { + const orderBy: ActionItemsOrderByInput = "createdAt_ASC"; + + const args: QueryActionItemsByOrganizationArgs = { + organizationId: testOrganization?._id, + eventId: null, + orderBy, + }; + + const actionItemsByOrganizationPayload = + (await actionItemsByOrganizationResolver?.( + {}, + args, + {}, + )) as InterfaceActionItem[]; const actionItemsByOrganizationInfo = await ActionItem.find({ - actionItemCategoryId: { $in: actionItemCategoriesIds }, + organization: args.organizationId, + event: args.eventId, }).lean(); - expect(actionItemsByOrganizationPayload).toEqual( - actionItemsByOrganizationInfo, + expect(actionItemsByOrganizationPayload[0]).toEqual( + expect.objectContaining({ + _id: actionItemsByOrganizationInfo[0]._id, + }), ); }); @@ -59,27 +94,26 @@ describe("resolvers -> Query -> actionItemsByOrganization", () => { const args: QueryActionItemsByOrganizationArgs = { organizationId: testOrganization?._id, + eventId: null, orderBy, }; const actionItemsByOrganizationPayload = - await actionItemsByOrganizationResolver?.({}, args, {}); - - actionItemsByOrganizationPayload?.reverse(); - - const actionItemCategories = await ActionItemCategory.find({ - organizationId: args.organizationId, - }); - const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id, - ); + (await actionItemsByOrganizationResolver?.( + {}, + args, + {}, + )) as InterfaceActionItem[]; const actionItemsByOrganizationInfo = await ActionItem.find({ - actionItemCategoryId: { $in: actionItemCategoriesIds }, + organization: args.organizationId, + event: args.eventId, }).lean(); - expect(actionItemsByOrganizationPayload).toEqual( - actionItemsByOrganizationInfo, + expect(actionItemsByOrganizationPayload[0]).toEqual( + expect.objectContaining({ + _id: actionItemsByOrganizationInfo[0]._id, + }), ); }); @@ -116,31 +150,31 @@ describe("resolvers -> Query -> actionItemsByOrganization", () => { }); it(`returns list of all action items associated with an organization that are active`, async () => { const where: ActionItemWhereInput = { - is_active: true, + is_completed: false, }; const args: QueryActionItemsByOrganizationArgs = { organizationId: testOrganization?._id, + eventId: testEvent?._id, where, }; const actionItemsByOrganizationPayload = - await actionItemsByOrganizationResolver?.({}, args, {}); - - const actionItemCategories = await ActionItemCategory.find({ - organizationId: args.organizationId, - }); - const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id, - ); + (await actionItemsByOrganizationResolver?.( + {}, + args, + {}, + )) as InterfaceActionItem[]; const actionItemsByOrganizationInfo = await ActionItem.find({ - actionItemCategoryId: { $in: actionItemCategoriesIds }, - isCompleted: false, + organization: args.organizationId, + event: args.eventId, }).lean(); - expect(actionItemsByOrganizationPayload).toEqual( - actionItemsByOrganizationInfo, + expect(actionItemsByOrganizationPayload[0]).toEqual( + expect.objectContaining({ + _id: actionItemsByOrganizationInfo[1]._id, + }), ); }); @@ -151,91 +185,86 @@ describe("resolvers -> Query -> actionItemsByOrganization", () => { const args: QueryActionItemsByOrganizationArgs = { organizationId: testOrganization?._id, + eventId: testEvent?._id, where, }; const actionItemsByOrganizationPayload = - await actionItemsByOrganizationResolver?.({}, args, {}); - - const actionItemCategories = await ActionItemCategory.find({ - organizationId: args.organizationId, - }); - const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id, - ); + (await actionItemsByOrganizationResolver?.( + {}, + args, + {}, + )) as InterfaceActionItem[]; const actionItemsByOrganizationInfo = await ActionItem.find({ - actionItemCategoryId: { $in: actionItemCategoriesIds }, - isCompleted: true, + organization: args.organizationId, + event: args.eventId, }).lean(); - expect(actionItemsByOrganizationPayload).toEqual( - actionItemsByOrganizationInfo, + expect(actionItemsByOrganizationPayload[0]).toEqual( + expect.objectContaining({ + _id: actionItemsByOrganizationInfo[0]._id, + }), ); }); - it(`returns list of all action items associated with an organization and belonging to an event`, async () => { + it(`returns list of all action items matching categoryName Filter`, async () => { const where: ActionItemWhereInput = { - event_id: testEvent?._id, + categoryName: "Default", }; const args: QueryActionItemsByOrganizationArgs = { organizationId: testOrganization?._id, + eventId: testEvent?._id, where, }; const actionItemsByOrganizationPayload = - await actionItemsByOrganizationResolver?.({}, args, {}); - - const actionItemCategories = await ActionItemCategory.find({ - organizationId: args.organizationId, - }); - const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id, - ); + (await actionItemsByOrganizationResolver?.( + {}, + args, + {}, + )) as InterfaceActionItem[]; const actionItemsByOrganizationInfo = await ActionItem.find({ - actionItemCategoryId: { $in: actionItemCategoriesIds }, - eventId: testEvent?._id, + organization: args.organizationId, + event: args.eventId, }).lean(); - expect(actionItemsByOrganizationPayload).toEqual( - actionItemsByOrganizationInfo, + expect(actionItemsByOrganizationPayload[0].actionItemCategory).toEqual( + expect.objectContaining({ + _id: actionItemsByOrganizationInfo[0].actionItemCategory, + }), ); }); - it(`returns list of all action items associated with an organization and belonging to an event and a specific category and are completed`, async () => { - const actionItemCategories = await ActionItemCategory.find({ - organizationId: testOrganization?._id, - }); - const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id, - ); - - const actionItemCategoryId = actionItemCategoriesIds[0]; - + it(`returns list of all action items matching assigneeName Filter`, async () => { const where: ActionItemWhereInput = { - actionItemCategory_id: actionItemCategoryId.toString(), - event_id: testEvent?._id, - is_completed: true, + assigneeName: testAssigneeUser?.firstName, }; const args: QueryActionItemsByOrganizationArgs = { organizationId: testOrganization?._id, + eventId: testEvent?._id, where, }; const actionItemsByOrganizationPayload = - await actionItemsByOrganizationResolver?.({}, args, {}); + (await actionItemsByOrganizationResolver?.( + {}, + args, + {}, + )) as InterfaceActionItem[]; const actionItemsByOrganizationInfo = await ActionItem.find({ - actionItemCategoryId, - eventId: testEvent?._id, - isCompleted: true, + organization: args.organizationId, + event: args.eventId, }).lean(); - expect(actionItemsByOrganizationPayload).toEqual( - actionItemsByOrganizationInfo, + expect(actionItemsByOrganizationPayload[0].assignee).toEqual( + expect.objectContaining({ + _id: actionItemsByOrganizationInfo[0].assignee, + }), ); }); }); diff --git a/tests/resolvers/Query/helperFunctions/getSort.spec.ts b/tests/resolvers/Query/helperFunctions/getSort.spec.ts index e37476b1f4..10b0b1668c 100644 --- a/tests/resolvers/Query/helperFunctions/getSort.spec.ts +++ b/tests/resolvers/Query/helperFunctions/getSort.spec.ts @@ -59,6 +59,8 @@ describe("getSort function", () => { ["commentCount_DESC", { commentCount: -1 }], ["fundingGoal_ASC", { fundingGoal: 1 }], ["fundingGoal_DESC", { fundingGoal: -1 }], + ["dueDate_ASC", { dueDate: 1 }], + ["dueDate_DESC", { dueDate: -1 }], ]; it.each(testCases)( diff --git a/tests/resolvers/Query/helperFunctions/getWhere.spec.ts b/tests/resolvers/Query/helperFunctions/getWhere.spec.ts index c699e2057b..3c3494c9b6 100644 --- a/tests/resolvers/Query/helperFunctions/getWhere.spec.ts +++ b/tests/resolvers/Query/helperFunctions/getWhere.spec.ts @@ -12,6 +12,7 @@ import type { CampaignWhereInput, EventVolunteerGroupWhereInput, PledgeWhereInput, + ActionItemCategoryWhereInput, } from "../../../../src/types/generatedGraphQLTypes"; describe("getWhere function", () => { @@ -25,6 +26,7 @@ describe("getWhere function", () => { UserWhereInput & DonationWhereInput & ActionItemWhereInput & + ActionItemCategoryWhereInput & FundWhereInput & CampaignWhereInput & VenueWhereInput & @@ -106,8 +108,8 @@ describe("getWhere function", () => { { actionItemCategory_id: "6f43d" }, { actionItemCategoryId: "6f43d" }, ], - ["is_active", { is_active: true }, { isCompleted: false }], ["is_completed", { is_completed: true }, { isCompleted: true }], + ["is_completed", { is_completed: false }, { isCompleted: false }], ["event_id", { event_id: "6f43d" }, { eventId: "6f43d" }], ["eventId", { eventId: "6f43d" }, { eventId: "6f43d" }], ["location", { location: "test location" }, { location: "test location" }], @@ -342,6 +344,8 @@ describe("getWhere function", () => { }, }, ], + ["is_disabled", { is_disabled: true }, { isDisabled: true }], + ["is_disabled", { is_disabled: false }, { isDisabled: false }], ]; it.each(testCases)(