[ADF-3912] Improved folder retrieving for DL (#4423)

* [ADF-3912] added abstract class for document-list component to be provided

* [ADF-3912] - created abstract class for document-list service

* [ADF-3912] - fixing and removing the custom resource from document-list

* [ADF-3912] added interface for document list service

* [ADF-3912] added interface for loadFolderById for DL component

* [ADF-3912] fixed missing return type

* [ADF-3912] removed comment

* [ADF-3912] fixed PR comments

* [ADF-3912] fixed wrong import

* [ADF-3912] fixed unit test failing

* [ADF-3912] removed unused method

* [ADF-3912] fixed lint problems
This commit is contained in:
Vito
2019-03-27 13:10:59 +00:00
committed by Eugenio Romano
parent 3b1c4923b2
commit a2823eeb99
14 changed files with 256 additions and 166 deletions

View File

@@ -866,9 +866,9 @@ describe('DocumentList', () => {
it('should display folder content from loadFolderByNodeId on reload if currentFolderId defined', () => {
documentList.currentFolderId = 'id-folder';
spyOn(documentList, 'loadFolderByNodeId').and.stub();
spyOn(documentList, 'loadFolder').and.stub();
documentList.reload();
expect(documentList.loadFolderByNodeId).toHaveBeenCalled();
expect(documentList.loadFolder).toHaveBeenCalled();
});
it('should require node to resolve context menu actions', () => {
@@ -1050,8 +1050,8 @@ describe('DocumentList', () => {
disposableError.unsubscribe();
done();
});
documentList.loadFolderByNodeId('123');
documentList.currentFolderId = '123';
documentList.loadFolder();
});
it('should emit folderChange event when a folder node is clicked', (done) => {
@@ -1075,7 +1075,8 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('123');
documentList.currentFolderId = '123';
documentList.loadFolder();
});
it('should reset noPermission upon reload', () => {
@@ -1135,7 +1136,8 @@ describe('DocumentList', () => {
it('should fetch trashcan', () => {
spyOn(apiService.nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-trashcan-');
documentList.currentFolderId = '-trashcan-';
documentList.loadFolder();
expect(apiService.nodesApi.getDeletedNodes).toHaveBeenCalled();
});
@@ -1148,14 +1150,16 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-trashcan-');
documentList.currentFolderId = '-trashcan-';
documentList.loadFolder();
});
it('should fetch shared links', () => {
const sharedlinksApi = apiService.getInstance().core.sharedlinksApi;
spyOn(sharedlinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-sharedlinks-');
documentList.currentFolderId = '-sharedlinks-';
documentList.loadFolder();
expect(sharedlinksApi.findSharedLinks).toHaveBeenCalled();
});
@@ -1169,13 +1173,15 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-sharedlinks-');
documentList.currentFolderId = '-sharedlinks-';
documentList.loadFolder();
});
it('should fetch sites', () => {
const sitesApi = apiService.getInstance().core.sitesApi;
documentList.loadFolderByNodeId('-sites-');
documentList.currentFolderId = '-sites-';
documentList.loadFolder();
expect(sitesApi.getSites).toHaveBeenCalled();
});
@@ -1188,7 +1194,8 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-sites-');
documentList.currentFolderId = '-sites-';
documentList.loadFolder();
});
it('should assure that sites have name property set', (done) => {
@@ -1201,7 +1208,8 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-sites-');
documentList.currentFolderId = '-sites-';
documentList.loadFolder();
});
it('should assure that sites have name property set correctly', (done) => {
@@ -1214,14 +1222,16 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-sites-');
documentList.currentFolderId = '-sites-';
documentList.loadFolder();
});
it('should fetch user membership sites', () => {
const peopleApi = apiService.getInstance().core.peopleApi;
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
documentList.loadFolderByNodeId('-mysites-');
documentList.currentFolderId = '-mysites-';
documentList.loadFolder();
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
});
@@ -1235,7 +1245,8 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-mysites-');
documentList.currentFolderId = '-mysites-';
documentList.loadFolder();
});
it('should assure that user membership sites have name property set', (done) => {
@@ -1243,7 +1254,8 @@ describe('DocumentList', () => {
const peopleApi = apiService.getInstance().core.peopleApi;
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
documentList.loadFolderByNodeId('-mysites-');
documentList.currentFolderId = '-mysites-';
documentList.loadFolder();
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
const disposableReady = documentList.ready.subscribe((page) => {
@@ -1259,7 +1271,8 @@ describe('DocumentList', () => {
const peopleApi = apiService.getInstance().core.peopleApi;
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
documentList.loadFolderByNodeId('-mysites-');
documentList.currentFolderId = '-mysites-';
documentList.loadFolder();
expect(peopleApi.listSiteMembershipsForPerson).toHaveBeenCalled();
const disposableReady = documentList.ready.subscribe((page) => {
@@ -1274,7 +1287,8 @@ describe('DocumentList', () => {
const favoritesApi = apiService.getInstance().core.favoritesApi;
spyFavorite.and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-favorites-');
documentList.currentFolderId = '-favorites-';
documentList.loadFolder();
expect(favoritesApi.getFavorites).toHaveBeenCalled();
});
@@ -1287,7 +1301,8 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-favorites-');
documentList.currentFolderId = '-favorites-';
documentList.loadFolder();
});
it('should fetch recent', () => {
@@ -1295,7 +1310,8 @@ describe('DocumentList', () => {
const getPersonSpy = spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.resolve(person));
documentList.loadFolderByNodeId('-recent-');
documentList.currentFolderId = '-recent-';
documentList.loadFolder();
expect(getPersonSpy).toHaveBeenCalledWith('-me-');
});
@@ -1309,7 +1325,8 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-recent-');
documentList.currentFolderId = '-recent-';
documentList.loadFolder();
});
it('should emit error when fetch recent fails on search call', (done) => {
@@ -1321,7 +1338,8 @@ describe('DocumentList', () => {
done();
});
documentList.loadFolderByNodeId('-recent-');
documentList.currentFolderId = '-recent-';
documentList.loadFolder();
});
it('should have correct currentFolderId on loading folder by node id', () => {
@@ -1330,7 +1348,8 @@ describe('DocumentList', () => {
const peopleApi = apiService.getInstance().core.peopleApi;
spyOn(peopleApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve(fakeGetSiteMembership));
documentList.loadFolderByNodeId('-mysites-');
documentList.currentFolderId = '-mysites-';
documentList.loadFolder();
expect(documentList.currentFolderId).toBe('-mysites-');
});