Skip to content

Commit

Permalink
10217 - use document key (without file ending) for computing the docu…
Browse files Browse the repository at this point in the history
…ment to reupload during qc
  • Loading branch information
Absolutestunna committed Feb 25, 2024
1 parent 73465e3 commit 85fe347
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ describe('saveCaseDetailInternalEditAction', () => {
modules: {
presenter,
},
props: {
fileUploadProgressMap: {
petition: {
file: {},
uploadProgress: jest.fn(),
},
},
},
state: {
caseDetail: {
...caseDetail,
Expand All @@ -49,10 +57,7 @@ describe('saveCaseDetailInternalEditAction', () => {
},
],
},
form: {
...caseDetail,
petitionFile: {},
},
form: caseDetail,
},
});

Expand All @@ -76,12 +81,17 @@ describe('saveCaseDetailInternalEditAction', () => {
modules: {
presenter,
},
props: {
fileUploadProgressMap: {
corporateDisclosure: {
file: {},
uploadProgress: jest.fn(),
},
},
},
state: {
caseDetail,
form: {
...caseDetail,
corporateDisclosureFile: {},
},
form: caseDetail,
},
});

Expand Down Expand Up @@ -115,6 +125,14 @@ describe('saveCaseDetailInternalEditAction', () => {
modules: {
presenter,
},
props: {
fileUploadProgressMap: {
corporateDisclosure: {
file: {},
uploadProgress: jest.fn(),
},
},
},
state: {
caseDetail,
form: caseDetail,
Expand All @@ -139,6 +157,14 @@ describe('saveCaseDetailInternalEditAction', () => {
modules: {
presenter,
},
props: {
fileUploadProgressMap: {
corporateDisclosure: {
file: {},
uploadProgress: jest.fn(),
},
},
},
state: {
caseDetail,
form: caseDetail,
Expand All @@ -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,
},
Expand Down Expand Up @@ -214,6 +252,14 @@ describe('saveCaseDetailInternalEditAction', () => {
modules: {
presenter,
},
props: {
fileUploadProgressMap: {
requestForPlaceOfTrial: {
file: mockRqtFile,
uploadProgress: jest.fn(),
},
},
},
state: {
form: caseDetail,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -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];
Expand Down

0 comments on commit 85fe347

Please sign in to comment.