mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
@@ -264,6 +264,52 @@ describe('AlfrescoLogin', () => {
|
||||
expect(element.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ERROR-CREDENTIALS');
|
||||
});
|
||||
|
||||
it('should return CORS error when server CORS error occurs', () => {
|
||||
component.providers = 'ECM';
|
||||
expect(component.success).toBe(false);
|
||||
expect(component.error).toBe(false);
|
||||
|
||||
usernameInput.value = 'fake-username-CORS-error';
|
||||
passwordInput.value = 'fake-password';
|
||||
|
||||
usernameInput.dispatchEvent(new Event('input'));
|
||||
passwordInput.dispatchEvent(new Event('input'));
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
element.querySelector('button').click();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.error).toBe(true);
|
||||
expect(component.success).toBe(false);
|
||||
expect(element.querySelector('#login-error')).toBeDefined();
|
||||
expect(element.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ERROR-CORS');
|
||||
});
|
||||
|
||||
it('should return CSRF error when server CSRF error occurs', () => {
|
||||
component.providers = 'ECM';
|
||||
expect(component.success).toBe(false);
|
||||
expect(component.error).toBe(false);
|
||||
|
||||
usernameInput.value = 'fake-username-CSRF-error';
|
||||
passwordInput.value = 'fake-password';
|
||||
|
||||
usernameInput.dispatchEvent(new Event('input'));
|
||||
passwordInput.dispatchEvent(new Event('input'));
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
element.querySelector('button').click();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.error).toBe(true);
|
||||
expect(component.success).toBe(false);
|
||||
expect(element.querySelector('#login-error')).toBeDefined();
|
||||
expect(element.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ERROR-CSRF');
|
||||
});
|
||||
|
||||
it('should emit onSuccess event after the login has succeeded', () => {
|
||||
spyOn(component.onSuccess, 'emit');
|
||||
component.providers = 'ECM';
|
||||
|
Reference in New Issue
Block a user