diff --git a/src/app/directives/library-membership.directive.spec.ts b/src/app/directives/library-membership.directive.spec.ts index d6c2abe8f..e6e2b44e4 100644 --- a/src/app/directives/library-membership.directive.spec.ts +++ b/src/app/directives/library-membership.directive.spec.ts @@ -35,6 +35,7 @@ import { AppTestingModule } from '../testing/app-testing.module'; import { DirectivesModule } from './directives.module'; import { LibraryMembershipDirective } from './library-membership.directive'; import { NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core'; +import { throwError } from 'rxjs'; describe('LibraryMembershipDirective', () => { let alfrescoApiService: AlfrescoApiService; @@ -165,5 +166,18 @@ describe('LibraryMembershipDirective', () => { expect(addMembershipSpy).toHaveBeenCalled(); expect(deleteMembershipSpy).not.toHaveBeenCalled(); })); + + it('should emit error when the request to join a library fails', fakeAsync(() => { + spyOn(directive.error, 'emit'); + addMembershipSpy.and.returnValue(throwError('err')); + + const selection = { entry: { id: 'no-membership-requested' } }; + const change = new SimpleChange(null, selection, true); + directive.ngOnChanges({ selection: change }); + tick(); + directive.toggleMembershipRequest(); + tick(); + expect(directive.error.emit).toHaveBeenCalled(); + })); }); }); diff --git a/src/app/directives/library-membership.directive.ts b/src/app/directives/library-membership.directive.ts index 8f9c5710c..fda7569f2 100644 --- a/src/app/directives/library-membership.directive.ts +++ b/src/app/directives/library-membership.directive.ts @@ -130,6 +130,18 @@ export class LibraryMembershipDirective implements OnChanges { error, i18nKey: 'APP.MESSAGES.ERRORS.JOIN_REQUEST_FAILED' }; + + const senderEmailCheck = 'Failed to resolve sender mail address'; + const receiverEmailCheck = + 'All recipients for the mail action were invalid'; + if ( + error.message && + (error.message.includes(senderEmailCheck) || + error.message.includes(receiverEmailCheck)) + ) { + errWithMessage.i18nKey = 'APP.MESSAGES.ERRORS.INVALID_EMAIL'; + } + this.error.emit(errWithMessage); } ); diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 1c3e6ccf3..3aa3db4fb 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -277,7 +277,8 @@ "DELETE_LIBRARY_FAILED": "Cannot delete the library", "JOIN_REQUEST_FAILED": "Cannot join the library", "JOIN_CANCEL_FAILED": "Cannot cancel the request to join the library", - "LEAVE_LIBRARY_FAILED": "Cannot leave this library" + "LEAVE_LIBRARY_FAILED": "Cannot leave this library", + "INVALID_EMAIL": "Sender or receiver email configured on server not valid, contact IT" }, "UPLOAD": { "ERROR": {