From ea3baf476cd1f1cb066704d6be269912a0b17356 Mon Sep 17 00:00:00 2001 From: Adam Levin Date: Wed, 4 Sep 2024 11:00:13 -0400 Subject: [PATCH 1/2] make sure we pass created here to the BE so its persisted to the DB --- frontend/src/pages/ActivityReport/formDataHelpers.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/pages/ActivityReport/formDataHelpers.js b/frontend/src/pages/ActivityReport/formDataHelpers.js index 1d81aa02bc..087d6870bb 100644 --- a/frontend/src/pages/ActivityReport/formDataHelpers.js +++ b/frontend/src/pages/ActivityReport/formDataHelpers.js @@ -129,6 +129,7 @@ export const packageGoals = (goals, goal, grantIds, prompts) => { courses: objective.courses, closeSuspendReason: objective.closeSuspendReason, closeSuspendContext: objective.closeSuspendContext, + createdHere: objective.createdHere, })), })), ]; @@ -155,6 +156,7 @@ export const packageGoals = (goals, goal, grantIds, prompts) => { courses: objective.courses, closeSuspendReason: objective.closeSuspendReason, closeSuspendContext: objective.closeSuspendContext, + createdHere: objective.createdHere, })), grantIds, prompts: grantIds.length < 2 ? prompts : [], From abc39b86d8a428f2a309e416f4abcb49a17f301b Mon Sep 17 00:00:00 2001 From: Adam Levin Date: Wed, 4 Sep 2024 11:14:56 -0400 Subject: [PATCH 2/2] add test to assert packaged obj values --- .../__tests__/formDataHelpers.js | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/frontend/src/pages/ActivityReport/__tests__/formDataHelpers.js b/frontend/src/pages/ActivityReport/__tests__/formDataHelpers.js index c9fd485e30..1af5d365f9 100644 --- a/frontend/src/pages/ActivityReport/__tests__/formDataHelpers.js +++ b/frontend/src/pages/ActivityReport/__tests__/formDataHelpers.js @@ -160,6 +160,115 @@ describe('FormDataHelpers', () => { }, ]); }); + + it('correctly pacakges all objective fields', () => { + const grantIds = [1]; + const packagedGoals = packageGoals( + [ + { + ...baseGoal, + name: 'goal name', + endDate: '09/01/2020', + prompts: [{ fieldName: 'prompt' }], + objectives: [ + { + id: 1, + isNew: false, + ttaProvided: 'Not Created Here TTA', + title: 'Not Created Here Title', + status: 'status', + resources: 'resources', + topics: 'topics', + files: 'files', + supportType: 'supportType', + courses: 'courses', + closeSuspendReason: 'closeSuspendReason', + closeSuspendContext: 'closeSuspendContext', + createdHere: false, + }, + ], + }, + ], + { + ...baseGoal, + name: 'recipient', + endDate: '09/01/2020', + isActivelyBeingEditing: true, + objectives: [ + { + id: 2, + isNew: false, + ttaProvided: 'Created Here TTA', + title: 'Created Here Title', + status: 'status', + resources: 'resources', + topics: 'topics', + files: 'files', + supportType: 'supportType', + courses: 'courses', + closeSuspendReason: 'closeSuspendReason', + closeSuspendContext: 'closeSuspendContext', + createdHere: true, + }, + ], + }, + grantIds, + [{ fieldName: 'prompt2' }], + ); + + expect(packagedGoals).toEqual([ + { + ...baseGoal, + name: 'goal name', + endDate: '09/01/2020', + prompts: [{ fieldName: 'prompt' }], + grantIds, + isActivelyBeingEditing: false, + objectives: [ + { + id: 1, + isNew: false, + ttaProvided: 'Not Created Here TTA', + title: 'Not Created Here Title', + status: 'status', + resources: 'resources', + topics: 'topics', + files: 'files', + supportType: 'supportType', + courses: 'courses', + closeSuspendReason: 'closeSuspendReason', + closeSuspendContext: 'closeSuspendContext', + createdHere: false, + }, + ], + }, + { + ...baseGoal, + name: 'recipient', + endDate: '09/01/2020', + isActivelyBeingEditing: true, + grantIds, + prompts: [{ fieldName: 'prompt2' }], + objectives: [ + { + id: 2, + isNew: false, + ttaProvided: 'Created Here TTA', + title: 'Created Here Title', + status: 'status', + resources: 'resources', + topics: 'topics', + files: 'files', + supportType: 'supportType', + courses: 'courses', + closeSuspendReason: 'closeSuspendReason', + closeSuspendContext: 'closeSuspendContext', + createdHere: true, + }, + ], + }, + ]); + }); }); describe('convertGoalsToFormData', () => {