mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-10-08 14:51:14 +00:00
[ACA-1057] Upload - snack-bar error messages (#837)
* upload error notification * remove duplicate * test
This commit is contained in:
committed by
Denys Vuika
parent
9b717c2743
commit
4c77ace5eb
@@ -26,7 +26,72 @@
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
it('should be defined', () => {
|
||||
expect(AppComponent).toBeDefined();
|
||||
let component;
|
||||
const storeMock = <any>{
|
||||
dispatch: jasmine.createSpy('dispatch')
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
component = new AppComponent(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
storeMock,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
describe('onFileUploadedError', () => {
|
||||
afterEach(() => {
|
||||
storeMock.dispatch['calls'].reset();
|
||||
});
|
||||
|
||||
it('should dispatch 403 error message', () => {
|
||||
component.onFileUploadedError({ error: { status: 403 } });
|
||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||
'APP.MESSAGES.UPLOAD.ERROR.403'
|
||||
);
|
||||
});
|
||||
|
||||
it('should dispatch 404 error message', () => {
|
||||
component.onFileUploadedError({ error: { status: 404 } });
|
||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||
'APP.MESSAGES.UPLOAD.ERROR.404'
|
||||
);
|
||||
});
|
||||
|
||||
it('should dispatch 409 error message', () => {
|
||||
component.onFileUploadedError({ error: { status: 409 } });
|
||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||
'APP.MESSAGES.UPLOAD.ERROR.CONFLICT'
|
||||
);
|
||||
});
|
||||
|
||||
it('should dispatch 500 error message', () => {
|
||||
component.onFileUploadedError({ error: { status: 500 } });
|
||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||
'APP.MESSAGES.UPLOAD.ERROR.500'
|
||||
);
|
||||
});
|
||||
|
||||
it('should dispatch 504 error message', () => {
|
||||
component.onFileUploadedError({ error: { status: 504 } });
|
||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||
'APP.MESSAGES.UPLOAD.ERROR.504'
|
||||
);
|
||||
});
|
||||
|
||||
it('should dispatch generic error message', () => {
|
||||
component.onFileUploadedError({ error: { status: 999 } });
|
||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||
'APP.MESSAGES.UPLOAD.ERROR.GENERIC'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -167,6 +167,14 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
onFileUploadedError(error: FileUploadErrorEvent) {
|
||||
let message = 'APP.MESSAGES.UPLOAD.ERROR.GENERIC';
|
||||
|
||||
if (error.error.status === 403) {
|
||||
message = 'APP.MESSAGES.UPLOAD.ERROR.403';
|
||||
}
|
||||
|
||||
if (error.error.status === 404) {
|
||||
message = 'APP.MESSAGES.UPLOAD.ERROR.404';
|
||||
}
|
||||
|
||||
if (error.error.status === 409) {
|
||||
message = 'APP.MESSAGES.UPLOAD.ERROR.CONFLICT';
|
||||
}
|
||||
@@ -175,6 +183,10 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
message = 'APP.MESSAGES.UPLOAD.ERROR.500';
|
||||
}
|
||||
|
||||
if (error.error.status === 504) {
|
||||
message = 'APP.MESSAGES.UPLOAD.ERROR.504';
|
||||
}
|
||||
|
||||
this.store.dispatch(new SnackbarErrorAction(message));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user