@@ -167,7 +167,10 @@ describe('SubmissionUploadFilesComponent Component', () => {
167167 const expectedErrors : any = mockUploadResponse1ParsedErrors ;
168168 fixture . detectChanges ( ) ;
169169
170- comp . onCompleteItem ( Object . assign ( { } , uploadRestResponse , { sections : mockSectionsData } ) ) ;
170+ comp . onCompleteItem ( {
171+ response : Object . assign ( { } , uploadRestResponse , { sections : mockSectionsData } ) ,
172+ fileName : 'test.pdf' ,
173+ } ) ;
171174
172175 Object . keys ( mockSectionsData ) . forEach ( ( sectionId ) => {
173176 expect ( sectionsServiceStub . updateSectionData ) . toHaveBeenCalledWith (
@@ -183,15 +186,42 @@ describe('SubmissionUploadFilesComponent Component', () => {
183186
184187 } ) ;
185188
189+ it ( 'should include the file name in the success notification content' , ( ) => {
190+ fixture . detectChanges ( ) ;
191+
192+ comp . onCompleteItem ( {
193+ response : Object . assign ( { } , uploadRestResponse , { sections : mockSectionsData } ) ,
194+ fileName : 'test.pdf' ,
195+ } ) ;
196+
197+ expect ( translateService . get ) . toHaveBeenCalledWith (
198+ 'submission.sections.upload.upload-successful-file' ,
199+ { fileName : 'test.pdf' } ,
200+ ) ;
201+ } ) ;
202+
203+ it ( 'should fall back to the generic success key when no file name is available' , ( ) => {
204+ fixture . detectChanges ( ) ;
205+
206+ comp . onCompleteItem ( {
207+ response : Object . assign ( { } , uploadRestResponse , { sections : mockSectionsData } ) ,
208+ } ) ;
209+
210+ expect ( translateService . get ) . toHaveBeenCalledWith ( 'submission.sections.upload.upload-successful' ) ;
211+ } ) ;
212+
186213 it ( 'should show an error notification and call updateSectionData if unsuccessful' , ( ) => {
187214 const responseErrors = mockUploadResponse2Errors ;
188215 const expectedErrors : any = mockUploadResponse2ParsedErrors ;
189216 fixture . detectChanges ( ) ;
190217
191- comp . onCompleteItem ( Object . assign ( { } , uploadRestResponse , {
192- sections : mockSectionsData ,
193- errors : responseErrors . errors ,
194- } ) ) ;
218+ comp . onCompleteItem ( {
219+ response : Object . assign ( { } , uploadRestResponse , {
220+ sections : mockSectionsData ,
221+ errors : responseErrors . errors ,
222+ } ) ,
223+ fileName : 'test.pdf' ,
224+ } ) ;
195225
196226 Object . keys ( mockSectionsData ) . forEach ( ( sectionId ) => {
197227 expect ( sectionsServiceStub . updateSectionData ) . toHaveBeenCalledWith (
@@ -207,6 +237,25 @@ describe('SubmissionUploadFilesComponent Component', () => {
207237
208238 } ) ;
209239 } ) ;
240+
241+ describe ( 'on upload error' , ( ) => {
242+ it ( 'should show an error notification including the file name when available' , ( ) => {
243+ comp . onUploadError ( { item : { file : { name : 'broken.zip' } } } ) ;
244+
245+ expect ( notificationsServiceStub . error ) . toHaveBeenCalled ( ) ;
246+ expect ( translateService . get ) . toHaveBeenCalledWith (
247+ 'submission.sections.upload.upload-failed-file' ,
248+ { fileName : 'broken.zip' } ,
249+ ) ;
250+ } ) ;
251+
252+ it ( 'should fall back to the generic error key when no file name is available' , ( ) => {
253+ comp . onUploadError ( ) ;
254+
255+ expect ( notificationsServiceStub . error ) . toHaveBeenCalled ( ) ;
256+ expect ( translateService . get ) . toHaveBeenCalledWith ( 'submission.sections.upload.upload-failed' ) ;
257+ } ) ;
258+ } ) ;
210259 } ) ;
211260} ) ;
212261
0 commit comments