@@ -14,6 +14,9 @@ import {
1414 DiscardSubmissionSuccessAction ,
1515 EditFileDataAction ,
1616 EnableSectionAction ,
17+ ExecuteExternalUploadAction ,
18+ ExecuteExternalUploadErrorAction ,
19+ ExecuteExternalUploadSuccessAction ,
1720 InertSectionErrorsAction ,
1821 InitSectionAction ,
1922 InitSubmissionFormAction ,
@@ -88,7 +91,6 @@ describe('submissionReducer test suite', () => {
8891 savePending : false ,
8992 saveDecisionPending : false ,
9093 externalUploadPending : false ,
91- externalUploadErrors : [ ] ,
9294 depositPending : false ,
9395 metadataSecurityConfiguration : metadataSecurityConfiguration as any ,
9496 }
@@ -125,7 +127,6 @@ describe('submissionReducer test suite', () => {
125127 savePending : false ,
126128 depositPending : false ,
127129 externalUploadPending : false ,
128- externalUploadErrors : [ ]
129130 }
130131 } ;
131132
@@ -752,4 +753,48 @@ describe('submissionReducer test suite', () => {
752753 expect ( newState [ 826 ] . saveDecisionPending ) . toBeFalsy ( ) ;
753754 } ) ;
754755
756+ it ( 'should set the externalUploadPending to true' , ( ) => {
757+ const action : any = new ExecuteExternalUploadAction ( submissionId , 'external-upload' ) ;
758+ let newState ;
759+
760+ newState = submissionObjectReducer ( initState , action ) ;
761+
762+ expect ( newState [ 826 ] . externalUploadPending ) . toBeTrue ( ) ;
763+ } ) ;
764+
765+ it ( 'should set the errors fo the external Upload section' , ( ) => {
766+ const errors = [ {
767+ path : '/sections/external-upload' ,
768+ message : 'error.validation.notfound'
769+ } ] ;
770+ const action : any = new ExecuteExternalUploadErrorAction ( submissionId , 'external-upload' , errors ) ;
771+
772+ const newState = submissionObjectReducer ( initState , action ) ;
773+
774+ expect ( newState [ 826 ] . externalUploadPending ) . toBeFalse ( ) ;
775+ expect ( newState [ 826 ] . sections [ 'external-upload' ] . errorsToShow ) . toEqual ( errors ) ;
776+ expect ( newState [ 826 ] . sections [ 'external-upload' ] . serverValidationErrors ) . toEqual ( errors ) ;
777+ } ) ;
778+
779+ it ( 'should clean the errors fo the external Upload section' , ( ) => {
780+ const errors = [ {
781+ path : '/sections/external-upload' ,
782+ message : 'error.validation.notfound'
783+ } ] ;
784+ let action : any = new ExecuteExternalUploadErrorAction ( submissionId , 'external-upload' , errors ) ;
785+ let newState = submissionObjectReducer ( initState , action ) ;
786+
787+ expect ( newState [ 826 ] . externalUploadPending ) . toBeFalse ( ) ;
788+ expect ( newState [ 826 ] . sections [ 'external-upload' ] . errorsToShow ) . toEqual ( errors ) ;
789+ expect ( newState [ 826 ] . sections [ 'external-upload' ] . serverValidationErrors ) . toEqual ( errors ) ;
790+
791+ action = new ExecuteExternalUploadSuccessAction ( submissionId , 'external-upload' ) ;
792+
793+ newState = submissionObjectReducer ( initState , action ) ;
794+
795+ expect ( newState [ 826 ] . externalUploadPending ) . toBeFalse ( ) ;
796+ expect ( newState [ 826 ] . sections [ 'external-upload' ] . errorsToShow ) . toEqual ( [ ] ) ;
797+ expect ( newState [ 826 ] . sections [ 'external-upload' ] . serverValidationErrors ) . toEqual ( [ ] ) ;
798+ } ) ;
799+
755800} ) ;
0 commit comments