diff --git a/src/views/ModelPlan/TaskList/index.test.tsx b/src/views/ModelPlan/TaskList/index.test.tsx index 485b273313..f7adaae74f 100644 --- a/src/views/ModelPlan/TaskList/index.test.tsx +++ b/src/views/ModelPlan/TaskList/index.test.tsx @@ -10,7 +10,7 @@ import GetModelPlanQuery from 'queries/GetModelPlan'; import { GetModelPlan_modelPlan as GetModelPlanTypes } from 'queries/types/GetModelPlan'; import { ModelStatus } from 'types/graphql-global-types'; -import TaskList from './index'; +import TaskList, { getLatestModifiedDate } from './index'; describe('The Model Plan Task List', () => { const mockStore = configureMockStore(); @@ -117,6 +117,30 @@ describe('The Model Plan Task List', () => { ).toBeInTheDocument(); }); + it('gets the last modified date of it solutions', async () => { + const expectedDate: string = '2023-05-21T13:38:11.998962Z'; + + const lastUpdated = getLatestModifiedDate([ + { + __typename: 'OperationalNeed', + id: '724c19ce-0309-4f04-a4fe-d9ed345dbec', + modifiedDts: null + }, + { + __typename: 'OperationalNeed', + id: '864c19ce-0309-4f04-a4fe-d9ed844edbec', + modifiedDts: '2023-04-01T13:38:11.998962Z' + }, + { + __typename: 'OperationalNeed', + id: '134c19ce-0309-4f04-a4fe-d9ed844edbec', + modifiedDts: '2023-05-21T13:38:11.998962Z' + } + ]); + + expect(lastUpdated).toEqual(expectedDate); + }); + it('displays the model plan task list steps', async () => { modelPlan.modelName = ''; render( diff --git a/src/views/ModelPlan/TaskList/index.tsx b/src/views/ModelPlan/TaskList/index.tsx index 0e76b42635..6cf4de5cef 100644 --- a/src/views/ModelPlan/TaskList/index.tsx +++ b/src/views/ModelPlan/TaskList/index.tsx @@ -95,6 +95,17 @@ const taskListSectionMap: TaskListSectionMapType = { prepareForClearance: TaskListSection.PREPARE_FOR_CLEARANCE }; +export const getLatestModifiedDate = ( + operationalNeedsArray: OperationalNeedsType[] +) => { + if (operationalNeedsArray.length !== 0) { + return operationalNeedsArray + .filter(need => !!need.modifiedDts) + .reduce((a, b) => (a.modifiedDts! > b.modifiedDts! ? a : b)).modifiedDts; + } + return null; +}; + const TaskList = () => { const { t } = useTranslation('modelPlanTaskList'); const { t: h } = useTranslation('draftModelPlan'); @@ -152,18 +163,6 @@ const TaskList = () => { return inProgress ? TaskStatus.IN_PROGRESS : TaskStatus.READY; }; - const getLatestModifiedDate = ( - operationalNeedsArray: OperationalNeedsType[] - ) => { - if (operationalNeedsArray.length !== 0) { - return operationalNeedsArray - .filter(need => !!need.modifiedDts) - .reduce((a, b) => (a.modifiedDts! > b.modifiedDts! ? a : b)) - .modifiedDts; - } - return null; - }; - const itSolutions: ITSolutionsType = { modifiedDts: getLatestModifiedDate(operationalNeeds), status: getITSolutionsStatus(operationalNeeds)