diff --git a/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.ts b/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.ts index dd1506c77ea..6436f6b4db7 100644 --- a/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.ts +++ b/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.test.ts @@ -39,6 +39,14 @@ describe('saveCaseDetailInternalEditAction', () => { modules: { presenter, }, + props: { + fileUploadProgressMap: { + petition: { + file: {}, + uploadProgress: jest.fn(), + }, + }, + }, state: { caseDetail: { ...caseDetail, @@ -49,10 +57,7 @@ describe('saveCaseDetailInternalEditAction', () => { }, ], }, - form: { - ...caseDetail, - petitionFile: {}, - }, + form: caseDetail, }, }); @@ -76,12 +81,17 @@ describe('saveCaseDetailInternalEditAction', () => { modules: { presenter, }, + props: { + fileUploadProgressMap: { + corporateDisclosure: { + file: {}, + uploadProgress: jest.fn(), + }, + }, + }, state: { caseDetail, - form: { - ...caseDetail, - corporateDisclosureFile: {}, - }, + form: caseDetail, }, }); @@ -115,6 +125,14 @@ describe('saveCaseDetailInternalEditAction', () => { modules: { presenter, }, + props: { + fileUploadProgressMap: { + corporateDisclosure: { + file: {}, + uploadProgress: jest.fn(), + }, + }, + }, state: { caseDetail, form: caseDetail, @@ -139,6 +157,14 @@ describe('saveCaseDetailInternalEditAction', () => { modules: { presenter, }, + props: { + fileUploadProgressMap: { + corporateDisclosure: { + file: {}, + uploadProgress: jest.fn(), + }, + }, + }, state: { caseDetail, form: caseDetail, @@ -164,10 +190,22 @@ describe('saveCaseDetailInternalEditAction', () => { requestForPlaceOfTrialFileSize: 2, }; + applicationContext + .getUseCases() + .saveCaseDetailInternalEditInteractor.mockReturnValue(caseDetail); + await runAction(saveCaseDetailInternalEditAction, { modules: { presenter, }, + props: { + fileUploadProgressMap: { + requestForPlaceOfTrial: { + file: mockRqtFile, + uploadProgress: jest.fn(), + }, + }, + }, state: { form: caseDetail, }, @@ -214,6 +252,14 @@ describe('saveCaseDetailInternalEditAction', () => { modules: { presenter, }, + props: { + fileUploadProgressMap: { + requestForPlaceOfTrial: { + file: mockRqtFile, + uploadProgress: jest.fn(), + }, + }, + }, state: { form: caseDetail, }, diff --git a/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.ts b/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.ts index e348989a701..fefadd29f21 100644 --- a/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.ts +++ b/web-client/src/presenter/actions/saveCaseDetailInternalEditAction.ts @@ -1,10 +1,13 @@ +import { FileUploadProgressMapType } from '@shared/business/entities/EntityConstants'; import { state } from '@web-client/presenter/app.cerebral'; export const saveCaseDetailInternalEditAction = async ({ applicationContext, get, props, -}: ActionProps) => { +}: ActionProps<{ + fileUploadProgressMap: FileUploadProgressMapType; +}>) => { const { INITIAL_DOCUMENT_TYPES, INITIAL_DOCUMENT_TYPES_FILE_MAP, @@ -18,8 +21,9 @@ export const saveCaseDetailInternalEditAction = async ({ for (const key of keys) { const fileKey = INITIAL_DOCUMENT_TYPES_FILE_MAP[key]; - if (fileUploadProgressMap[fileKey]) { - if (fileKey === 'petitionFile') { + + if (fileUploadProgressMap[key]) { + if (key === 'petition') { const oldPetitionDocument = originalCase.docketEntries.find( document => document.eventCode === INITIAL_DOCUMENT_TYPES.petition.eventCode, @@ -28,16 +32,16 @@ export const saveCaseDetailInternalEditAction = async ({ await applicationContext .getUseCases() .uploadDocumentAndMakeSafeInteractor(applicationContext, { - document: fileUploadProgressMap[fileKey].file, + document: fileUploadProgressMap[key].file, key: oldPetitionDocument.docketEntryId, - onUploadProgress: fileUploadProgressMap[fileKey].uploadProgress, + onUploadProgress: fileUploadProgressMap[key].uploadProgress, }); } else { const newDocketEntryId = await applicationContext .getUseCases() .uploadDocumentAndMakeSafeInteractor(applicationContext, { - document: fileUploadProgressMap[fileKey].file, - onUploadProgress: fileUploadProgressMap[fileKey].uploadProgress, + document: fileUploadProgressMap[key].file, + onUploadProgress: fileUploadProgressMap[key].uploadProgress, }); let { documentTitle, documentType } = INITIAL_DOCUMENT_TYPES[key];