[ADF-3324] Preview - unshared file breaks preview (#3580)

This commit is contained in:
Suzana Dirla
2018-07-11 19:15:16 +03:00
committed by Eugenio Romano
parent 50b6fb978b
commit ee8151d50d
2 changed files with 44 additions and 4 deletions

View File

@@ -592,6 +592,41 @@ describe('ViewerComponent', () => {
}));
});
describe('error handling', () => {
it('should show unknown view when node file not found', async(() => {
spyOn(alfrescoApiService.getInstance().nodes, 'getNodeInfo')
.and.returnValue(Promise.reject({}));
component.nodeId = 'the-node-id-of-the-file-to-preview';
component.urlFile = null;
component.mimeType = null;
component.ngOnChanges(null);
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('adf-viewer-unknown-format')).not.toBeNull();
});
}));
it('should show unknown view when sharedLink file not found', async(() => {
spyOn(alfrescoApiService.getInstance().core.sharedlinksApi, 'getSharedLink')
.and.returnValue(Promise.reject({}));
component.sharedLinkId = 'the-Shared-Link-id';
component.urlFile = null;
component.mimeType = null;
component.ngOnChanges(null);
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('adf-viewer-unknown-format')).not.toBeNull();
});
}));
});
describe('MimeType handling', () => {
it('should display a PDF file identified by mimetype when the filename has no extension', async(() => {

View File

@@ -298,10 +298,15 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
);
} else if (this.sharedLinkId) {
this.apiService.sharedLinksApi.getSharedLink(this.sharedLinkId).then(details => {
this.setUpSharedLinkFile(details);
this.isLoading = false;
});
this.apiService.sharedLinksApi.getSharedLink(this.sharedLinkId).then(
details => {
this.setUpSharedLinkFile(details);
this.isLoading = false;
},
() => {
this.isLoading = false;
this.logService.error('This sharedLink does not exist');
});
}
}
}