[ACA-2040] handle invalid email cases on join request (#857)

* [ACA-2040] handle invalid email cases on join request

* [ACA-2040] fix json

* [ACA-2040] unit test
This commit is contained in:
Suzana Dirla
2018-12-06 13:53:55 +02:00
committed by Denys Vuika
parent 01a7a8efb6
commit db66c72a06
3 changed files with 28 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ import { AppTestingModule } from '../testing/app-testing.module';
import { DirectivesModule } from './directives.module'; import { DirectivesModule } from './directives.module';
import { LibraryMembershipDirective } from './library-membership.directive'; import { LibraryMembershipDirective } from './library-membership.directive';
import { NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core'; import { NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
import { throwError } from 'rxjs';
describe('LibraryMembershipDirective', () => { describe('LibraryMembershipDirective', () => {
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
@@ -165,5 +166,18 @@ describe('LibraryMembershipDirective', () => {
expect(addMembershipSpy).toHaveBeenCalled(); expect(addMembershipSpy).toHaveBeenCalled();
expect(deleteMembershipSpy).not.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();
}));
}); });
}); });

View File

@@ -130,6 +130,18 @@ export class LibraryMembershipDirective implements OnChanges {
error, error,
i18nKey: 'APP.MESSAGES.ERRORS.JOIN_REQUEST_FAILED' 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); this.error.emit(errWithMessage);
} }
); );

View File

@@ -277,7 +277,8 @@
"DELETE_LIBRARY_FAILED": "Cannot delete the library", "DELETE_LIBRARY_FAILED": "Cannot delete the library",
"JOIN_REQUEST_FAILED": "Cannot join the library", "JOIN_REQUEST_FAILED": "Cannot join the library",
"JOIN_CANCEL_FAILED": "Cannot cancel the request to 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": { "UPLOAD": {
"ERROR": { "ERROR": {