diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a0f519381c..f6989965bc 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -38,7 +38,7 @@ jobs: - name: Count number of lines run: | chmod +x ./.github/workflows/countline.py - ./.github/workflows/countline.py --lines 600 --exclude_files src/screens/LoginPage/LoginPage.tsx src/GraphQl/Queries/Queries.ts src/screens/OrgList/OrgList.tsx src/GraphQl/Mutations/mutations.ts src/components/EventListCard/EventListCardModals.tsx src/screens/ManageTag/ManageTag.tsx + ./.github/workflows/countline.py --lines 600 --exclude_files src/screens/LoginPage/LoginPage.tsx src/GraphQl/Queries/Queries.ts src/screens/OrgList/OrgList.tsx src/GraphQl/Mutations/mutations.ts src/components/EventListCard/EventListCardModals.tsx src/screens/ManageTag/ManageTag.tsx src/utils/interfaces.ts - name: Get changed TypeScript files id: changed-files diff --git a/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts b/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts index 27924dd014..908328bfc2 100644 --- a/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts +++ b/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts @@ -4,409 +4,19 @@ import { DELETE_ACTION_ITEM_MUTATION, UPDATE_ACTION_ITEM_MUTATION, } from 'GraphQl/Mutations/ActionItemMutations'; -import { - EVENT_VOLUNTEER_GROUP_LIST, - EVENT_VOLUNTEER_LIST, -} from 'GraphQl/Queries/EventVolunteerQueries'; -import { - ACTION_ITEM_CATEGORY_LIST, - ACTION_ITEM_LIST, - MEMBERS_LIST, -} from 'GraphQl/Queries/Queries'; -import type { InterfaceActionItemInfo } from 'utils/interfaces'; - -const actionItemCategory1 = { - _id: 'actionItemCategoryId1', - name: 'Category 1', -}; - -const actionItemCategory2 = { - _id: 'actionItemCategoryId2', - name: 'Category 2', -}; - -const baseActionItem = { - assigner: { - _id: 'userId', - firstName: 'Wilt', - lastName: 'Shepherd', - image: null, - }, - creator: { - _id: 'userId', - firstName: 'Wilt', - lastName: 'Shepherd', - image: null, - __typename: 'User', - }, -}; - -const itemWithVolunteer: InterfaceActionItemInfo = { - _id: 'actionItemId1', - assigneeType: 'EventVolunteer', - assignee: { - _id: 'volunteerId1', - hasAccepted: true, - hoursVolunteered: 12, - assignments: [], - groups: [], - user: { - _id: 'userId1', - firstName: 'John', - lastName: 'Doe', - image: null, - }, - }, - assigneeUser: null, - assigneeGroup: null, - preCompletionNotes: 'Notes 1', - postCompletionNotes: 'Cmp Notes 1', - assignmentDate: new Date('2024-08-27'), - dueDate: new Date('2044-08-30'), - completionDate: new Date('2044-09-03'), - isCompleted: true, - event: null, - allotedHours: 24, - actionItemCategory: actionItemCategory1, - ...baseActionItem, -}; - -const itemWithVolunteerImage: InterfaceActionItemInfo = { - _id: 'actionItemId1b', - assigneeType: 'EventVolunteer', - assignee: { - _id: 'volunteerId1', - hasAccepted: true, - hoursVolunteered: 12, - assignments: [], - groups: [], - user: { - _id: 'userId1', - firstName: 'John', - lastName: 'Doe', - image: 'user-image', - }, - }, - assigneeUser: null, - assigneeGroup: null, - preCompletionNotes: 'Notes 1', - postCompletionNotes: 'Cmp Notes 1', - assignmentDate: new Date('2024-08-27'), - dueDate: new Date('2044-08-30'), - completionDate: new Date('2044-09-03'), - isCompleted: true, - event: null, - allotedHours: 24, - actionItemCategory: actionItemCategory1, - ...baseActionItem, -}; - -const itemWithUser: InterfaceActionItemInfo = { - _id: 'actionItemId2', - assigneeType: 'User', - assigneeUser: { - _id: 'userId1', - firstName: 'Jane', - lastName: 'Doe', - image: null, - }, - assignee: null, - assigneeGroup: null, - preCompletionNotes: 'Notes 2', - postCompletionNotes: null, - assignmentDate: new Date('2024-08-27'), - dueDate: new Date('2044-09-30'), - completionDate: new Date('2044-10-03'), - isCompleted: false, - event: null, - allotedHours: null, - actionItemCategory: actionItemCategory2, - ...baseActionItem, -}; - -const itemWithUserImage: InterfaceActionItemInfo = { - _id: 'actionItemId2b', - assigneeType: 'User', - assigneeUser: { - _id: 'userId1', - firstName: 'Jane', - lastName: 'Doe', - image: 'user-image', - }, - assignee: null, - assigneeGroup: null, - preCompletionNotes: 'Notes 2', - postCompletionNotes: null, - assignmentDate: new Date('2024-08-27'), - dueDate: new Date('2044-09-30'), - completionDate: new Date('2044-10-03'), - isCompleted: false, - event: null, - allotedHours: null, - actionItemCategory: actionItemCategory2, - ...baseActionItem, -}; - -const itemWithGroup: InterfaceActionItemInfo = { - _id: 'actionItemId3', - assigneeType: 'EventVolunteerGroup', - assigneeUser: null, - assignee: null, - assigneeGroup: { - _id: 'volunteerGroupId1', - name: 'Group 1', - description: 'Group 1 Description', - volunteersRequired: 10, - event: { - _id: 'eventId1', - }, - assignments: [], - volunteers: [], - createdAt: '2024-08-27', - creator: { - _id: 'userId1', - firstName: 'John', - lastName: 'Doe', - image: undefined, - }, - leader: { - _id: 'userId1', - firstName: 'John', - lastName: 'Doe', - image: undefined, - }, - }, - preCompletionNotes: 'Notes 1', - postCompletionNotes: 'Cmp Notes 1', - assignmentDate: new Date('2024-08-27'), - dueDate: new Date('2044-08-30'), - completionDate: new Date('2044-09-03'), - isCompleted: true, - event: null, - allotedHours: 24, - actionItemCategory: actionItemCategory1, - ...baseActionItem, -}; - -const memberListQuery = { - request: { - query: MEMBERS_LIST, - variables: { id: 'orgId' }, - }, - result: { - data: { - organizations: [ - { - _id: 'orgId', - members: [ - { - _id: 'userId1', - firstName: 'Harve', - lastName: 'Lance', - email: 'harve@example.com', - image: '', - organizationsBlockedBy: [], - createdAt: '2024-02-14', - }, - { - _id: 'userId2', - firstName: 'Wilt', - lastName: 'Shepherd', - email: 'wilt@example.com', - image: '', - organizationsBlockedBy: [], - createdAt: '2024-02-14', - }, - ], - }, - ], - }, - }, -}; - -const volunteerListQuery = [ - { - request: { - query: EVENT_VOLUNTEER_LIST, - variables: { where: { eventId: 'eventId', hasAccepted: true } }, - }, - result: { - data: { - getEventVolunteers: [ - { - _id: 'volunteerId1', - hasAccepted: true, - hoursVolunteered: 0, - user: { - _id: 'userId1', - firstName: 'Teresa', - lastName: 'Bradley', - image: null, - }, - assignments: [], - groups: [ - { - _id: 'groupId1', - name: 'group1', - volunteers: [ - { - _id: 'volunteerId1', - }, - ], - }, - ], - }, - { - _id: 'volunteerId2', - hasAccepted: true, - hoursVolunteered: 0, - user: { - _id: 'userId3', - firstName: 'Bruce', - lastName: 'Graza', - image: null, - }, - assignments: [], - groups: [], - }, - ], - }, - }, - }, - { - request: { - query: EVENT_VOLUNTEER_LIST, - variables: { where: { hasAccepted: true } }, - }, - result: { - data: { - getEventVolunteers: [], - }, - }, - }, -]; - -const groupListQuery = [ - { - request: { - query: EVENT_VOLUNTEER_GROUP_LIST, - variables: { where: { eventId: 'eventId' } }, - }, - result: { - data: { - getEventVolunteerGroups: [ - { - _id: 'groupId1', - name: 'group1', - description: 'desc', - volunteersRequired: 10, - createdAt: '2024-10-27T15:34:15.889Z', - creator: { - _id: 'userId2', - firstName: 'Wilt', - lastName: 'Shepherd', - image: null, - }, - leader: { - _id: 'userId1', - firstName: 'Teresa', - lastName: 'Bradley', - image: null, - }, - volunteers: [ - { - _id: 'volunteerId1', - user: { - _id: 'userId1', - firstName: 'Teresa', - lastName: 'Bradley', - image: null, - }, - }, - ], - assignments: [], - event: { - _id: 'eventId', - }, - }, - { - _id: 'groupId2', - name: 'group2', - description: 'desc', - volunteersRequired: 10, - createdAt: '2024-10-27T15:34:15.889Z', - creator: { - _id: 'userId2', - firstName: 'Wilt', - lastName: 'Shepherd', - image: null, - }, - leader: { - _id: 'userId1', - firstName: 'Teresa', - lastName: 'Bradley', - image: null, - }, - volunteers: [], - assignments: [], - event: { - _id: 'eventId', - }, - }, - ], - }, - }, - }, - { - request: { - query: EVENT_VOLUNTEER_GROUP_LIST, - variables: { where: { eventId: undefined } }, - }, - result: { - data: { - getEventVolunteerGroups: [], - }, - }, - }, -]; +import { ACTION_ITEM_LIST } from 'GraphQl/Queries/Queries'; -const actionItemCategoryListQuery = { - request: { - query: ACTION_ITEM_CATEGORY_LIST, - variables: { - organizationId: 'orgId', - where: { is_disabled: false }, - }, - }, - result: { - data: { - actionItemCategoriesByOrganization: [ - { - _id: 'categoryId1', - name: 'Category 1', - isDisabled: false, - createdAt: '2024-08-26', - creator: { - _id: 'creatorId1', - firstName: 'Wilt', - lastName: 'Shepherd', - }, - }, - { - _id: 'categoryId2', - name: 'Category 2', - isDisabled: true, - createdAt: '2024-08-25', - creator: { - _id: 'creatorId2', - firstName: 'John', - lastName: 'Doe', - }, - }, - ], - }, - }, -}; +import { + actionItemCategoryListQuery, + groupListQuery, + itemWithGroup, + itemWithUser, + itemWithUserImage, + itemWithVolunteer, + itemWithVolunteerImage, + memberListQuery, + volunteerListQuery, +} from './testObject.mocks'; export const MOCKS = [ { diff --git a/src/screens/OrganizationActionItems/testObject.mocks.ts b/src/screens/OrganizationActionItems/testObject.mocks.ts new file mode 100644 index 0000000000..d4abe53406 --- /dev/null +++ b/src/screens/OrganizationActionItems/testObject.mocks.ts @@ -0,0 +1,402 @@ +import { + EVENT_VOLUNTEER_GROUP_LIST, + EVENT_VOLUNTEER_LIST, +} from 'GraphQl/Queries/EventVolunteerQueries'; +import { + ACTION_ITEM_CATEGORY_LIST, + MEMBERS_LIST, +} from 'GraphQl/Queries/Queries'; +import type { InterfaceActionItemInfo } from 'utils/interfaces'; + +export const actionItemCategory1 = { + _id: 'actionItemCategoryId1', + name: 'Category 1', +}; + +export const actionItemCategory2 = { + _id: 'actionItemCategoryId2', + name: 'Category 2', +}; + +export const baseActionItem = { + assigner: { + _id: 'userId', + firstName: 'Wilt', + lastName: 'Shepherd', + image: null, + }, + creator: { + _id: 'userId', + firstName: 'Wilt', + lastName: 'Shepherd', + image: null, + __typename: 'User', + }, +}; + +export const itemWithVolunteer: InterfaceActionItemInfo = { + _id: 'actionItemId1', + assigneeType: 'EventVolunteer', + assignee: { + _id: 'volunteerId1', + hasAccepted: true, + hoursVolunteered: 12, + assignments: [], + groups: [], + user: { + _id: 'userId1', + firstName: 'John', + lastName: 'Doe', + image: null, + }, + }, + assigneeUser: null, + assigneeGroup: null, + preCompletionNotes: 'Notes 1', + postCompletionNotes: 'Cmp Notes 1', + assignmentDate: new Date('2024-08-27'), + dueDate: new Date('2044-08-30'), + completionDate: new Date('2044-09-03'), + isCompleted: true, + event: null, + allotedHours: 24, + actionItemCategory: actionItemCategory1, + ...baseActionItem, +}; + +export const itemWithVolunteerImage: InterfaceActionItemInfo = { + _id: 'actionItemId1b', + assigneeType: 'EventVolunteer', + assignee: { + _id: 'volunteerId1', + hasAccepted: true, + hoursVolunteered: 12, + assignments: [], + groups: [], + user: { + _id: 'userId1', + firstName: 'John', + lastName: 'Doe', + image: 'user-image', + }, + }, + assigneeUser: null, + assigneeGroup: null, + preCompletionNotes: 'Notes 1', + postCompletionNotes: 'Cmp Notes 1', + assignmentDate: new Date('2024-08-27'), + dueDate: new Date('2044-08-30'), + completionDate: new Date('2044-09-03'), + isCompleted: true, + event: null, + allotedHours: 24, + actionItemCategory: actionItemCategory1, + ...baseActionItem, +}; + +export const itemWithUser: InterfaceActionItemInfo = { + _id: 'actionItemId2', + assigneeType: 'User', + assigneeUser: { + _id: 'userId1', + firstName: 'Jane', + lastName: 'Doe', + image: null, + }, + assignee: null, + assigneeGroup: null, + preCompletionNotes: 'Notes 2', + postCompletionNotes: null, + assignmentDate: new Date('2024-08-27'), + dueDate: new Date('2044-09-30'), + completionDate: new Date('2044-10-03'), + isCompleted: false, + event: null, + allotedHours: null, + actionItemCategory: actionItemCategory2, + ...baseActionItem, +}; + +export const itemWithUserImage: InterfaceActionItemInfo = { + _id: 'actionItemId2b', + assigneeType: 'User', + assigneeUser: { + _id: 'userId1', + firstName: 'Jane', + lastName: 'Doe', + image: 'user-image', + }, + assignee: null, + assigneeGroup: null, + preCompletionNotes: 'Notes 2', + postCompletionNotes: null, + assignmentDate: new Date('2024-08-27'), + dueDate: new Date('2044-09-30'), + completionDate: new Date('2044-10-03'), + isCompleted: false, + event: null, + allotedHours: null, + actionItemCategory: actionItemCategory2, + ...baseActionItem, +}; + +export const itemWithGroup: InterfaceActionItemInfo = { + _id: 'actionItemId3', + assigneeType: 'EventVolunteerGroup', + assigneeUser: null, + assignee: null, + assigneeGroup: { + _id: 'volunteerGroupId1', + name: 'Group 1', + description: 'Group 1 Description', + volunteersRequired: 10, + event: { + _id: 'eventId1', + }, + assignments: [], + volunteers: [], + createdAt: '2024-08-27', + creator: { + _id: 'userId1', + firstName: 'John', + lastName: 'Doe', + image: undefined, + }, + leader: { + _id: 'userId1', + firstName: 'John', + lastName: 'Doe', + image: undefined, + }, + }, + preCompletionNotes: 'Notes 1', + postCompletionNotes: 'Cmp Notes 1', + assignmentDate: new Date('2024-08-27'), + dueDate: new Date('2044-08-30'), + completionDate: new Date('2044-09-03'), + isCompleted: true, + event: null, + allotedHours: 24, + actionItemCategory: actionItemCategory1, + ...baseActionItem, +}; + +export const memberListQuery = { + request: { + query: MEMBERS_LIST, + variables: { id: 'orgId' }, + }, + result: { + data: { + organizations: [ + { + _id: 'orgId', + members: [ + { + _id: 'userId1', + firstName: 'Harve', + lastName: 'Lance', + email: 'harve@example.com', + image: '', + organizationsBlockedBy: [], + createdAt: '2024-02-14', + }, + { + _id: 'userId2', + firstName: 'Wilt', + lastName: 'Shepherd', + email: 'wilt@example.com', + image: '', + organizationsBlockedBy: [], + createdAt: '2024-02-14', + }, + ], + }, + ], + }, + }, +}; + +export const volunteerListQuery = [ + { + request: { + query: EVENT_VOLUNTEER_LIST, + variables: { where: { eventId: 'eventId', hasAccepted: true } }, + }, + result: { + data: { + getEventVolunteers: [ + { + _id: 'volunteerId1', + hasAccepted: true, + hoursVolunteered: 0, + user: { + _id: 'userId1', + firstName: 'Teresa', + lastName: 'Bradley', + image: null, + }, + assignments: [], + groups: [ + { + _id: 'groupId1', + name: 'group1', + volunteers: [ + { + _id: 'volunteerId1', + }, + ], + }, + ], + }, + { + _id: 'volunteerId2', + hasAccepted: true, + hoursVolunteered: 0, + user: { + _id: 'userId3', + firstName: 'Bruce', + lastName: 'Graza', + image: null, + }, + assignments: [], + groups: [], + }, + ], + }, + }, + }, + { + request: { + query: EVENT_VOLUNTEER_LIST, + variables: { where: { hasAccepted: true } }, + }, + result: { + data: { + getEventVolunteers: [], + }, + }, + }, +]; + +export const groupListQuery = [ + { + request: { + query: EVENT_VOLUNTEER_GROUP_LIST, + variables: { where: { eventId: 'eventId' } }, + }, + result: { + data: { + getEventVolunteerGroups: [ + { + _id: 'groupId1', + name: 'group1', + description: 'desc', + volunteersRequired: 10, + createdAt: '2024-10-27T15:34:15.889Z', + creator: { + _id: 'userId2', + firstName: 'Wilt', + lastName: 'Shepherd', + image: null, + }, + leader: { + _id: 'userId1', + firstName: 'Teresa', + lastName: 'Bradley', + image: null, + }, + volunteers: [ + { + _id: 'volunteerId1', + user: { + _id: 'userId1', + firstName: 'Teresa', + lastName: 'Bradley', + image: null, + }, + }, + ], + assignments: [], + event: { + _id: 'eventId', + }, + }, + { + _id: 'groupId2', + name: 'group2', + description: 'desc', + volunteersRequired: 10, + createdAt: '2024-10-27T15:34:15.889Z', + creator: { + _id: 'userId2', + firstName: 'Wilt', + lastName: 'Shepherd', + image: null, + }, + leader: { + _id: 'userId1', + firstName: 'Teresa', + lastName: 'Bradley', + image: null, + }, + volunteers: [], + assignments: [], + event: { + _id: 'eventId', + }, + }, + ], + }, + }, + }, + { + request: { + query: EVENT_VOLUNTEER_GROUP_LIST, + variables: { where: { eventId: undefined } }, + }, + result: { + data: { + getEventVolunteerGroups: [], + }, + }, + }, +]; + +export const actionItemCategoryListQuery = { + request: { + query: ACTION_ITEM_CATEGORY_LIST, + variables: { + organizationId: 'orgId', + where: { is_disabled: false }, + }, + }, + result: { + data: { + actionItemCategoriesByOrganization: [ + { + _id: 'categoryId1', + name: 'Category 1', + isDisabled: false, + createdAt: '2024-08-26', + creator: { + _id: 'creatorId1', + firstName: 'Wilt', + lastName: 'Shepherd', + }, + }, + { + _id: 'categoryId2', + name: 'Category 2', + isDisabled: true, + createdAt: '2024-08-25', + creator: { + _id: 'creatorId2', + firstName: 'John', + lastName: 'Doe', + }, + }, + ], + }, + }, +};