mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2176] [Destination picker] File Libraries are not displayed (#2868)
* [ADF-2176] [Destination picker] File Libraries are not displayed update columns used for display according to the folder node to display * [ADF-2176] revert initial changes * [ADF-2176] assure that site entries have 'name' property set * [ADF-2176] add unit test
This commit is contained in:
committed by
Eugenio Romano
parent
03cca19599
commit
9e6469c566
@@ -27,7 +27,9 @@ import {
|
|||||||
fakeNodeAnswerWithEntries,
|
fakeNodeAnswerWithEntries,
|
||||||
fakeNodeAnswerWithNOEntries,
|
fakeNodeAnswerWithNOEntries,
|
||||||
fakeNodeWithCreatePermission,
|
fakeNodeWithCreatePermission,
|
||||||
fakeNodeWithNoPermission
|
fakeNodeWithNoPermission,
|
||||||
|
fakeGetSitesAnswer,
|
||||||
|
fakeGetSiteMembership
|
||||||
} from '../../mock';
|
} from '../../mock';
|
||||||
import { MaterialModule } from '../../material.module';
|
import { MaterialModule } from '../../material.module';
|
||||||
import { ContentActionModel } from '../models/content-action.model';
|
import { ContentActionModel } from '../models/content-action.model';
|
||||||
@@ -1017,6 +1019,34 @@ describe('DocumentList', () => {
|
|||||||
documentList.loadFolderByNodeId('-sites-');
|
documentList.loadFolderByNodeId('-sites-');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should assure that sites have name property set', (done) => {
|
||||||
|
const sitesApi = apiService.getInstance().core.sitesApi;
|
||||||
|
spyOn(sitesApi, 'getSites').and.returnValue(Promise.resolve(fakeGetSitesAnswer));
|
||||||
|
|
||||||
|
documentList.loadFolderByNodeId('-sites-');
|
||||||
|
expect(sitesApi.getSites).toHaveBeenCalled();
|
||||||
|
|
||||||
|
documentList.ready.subscribe((page) => {
|
||||||
|
const entriesWithoutName = page.list.entries.filter(item => !item.entry.name);
|
||||||
|
expect(entriesWithoutName.length).toBe(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should assure that sites have name property set correctly', (done) => {
|
||||||
|
const sitesApi = apiService.getInstance().core.sitesApi;
|
||||||
|
spyOn(sitesApi, 'getSites').and.returnValue(Promise.resolve(fakeGetSitesAnswer));
|
||||||
|
|
||||||
|
documentList.loadFolderByNodeId('-sites-');
|
||||||
|
expect(sitesApi.getSites).toHaveBeenCalled();
|
||||||
|
|
||||||
|
documentList.ready.subscribe((page) => {
|
||||||
|
const wrongName = page.list.entries.filter(item => (item.entry.name !== item.entry.title));
|
||||||
|
expect(wrongName.length).toBe(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should fetch user membership sites', () => {
|
it('should fetch user membership sites', () => {
|
||||||
const peopleApi = apiService.getInstance().core.peopleApi;
|
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||||
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve());
|
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve());
|
||||||
@@ -1037,6 +1067,34 @@ describe('DocumentList', () => {
|
|||||||
documentList.loadFolderByNodeId('-mysites-');
|
documentList.loadFolderByNodeId('-mysites-');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should assure that user membership sites have name property set', (done) => {
|
||||||
|
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||||
|
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
||||||
|
|
||||||
|
documentList.loadFolderByNodeId('-mysites-');
|
||||||
|
expect(peopleApi.getSiteMembership).toHaveBeenCalled();
|
||||||
|
|
||||||
|
documentList.ready.subscribe((page) => {
|
||||||
|
const entriesWithoutName = page.list.entries.filter(item => !item.entry.name);
|
||||||
|
expect(entriesWithoutName.length).toBe(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should assure that user membership sites have name property set correctly', (done) => {
|
||||||
|
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||||
|
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve(fakeGetSiteMembership));
|
||||||
|
|
||||||
|
documentList.loadFolderByNodeId('-mysites-');
|
||||||
|
expect(peopleApi.getSiteMembership).toHaveBeenCalled();
|
||||||
|
|
||||||
|
documentList.ready.subscribe((page) => {
|
||||||
|
const wrongName = page.list.entries.filter(item => (item.entry.name !== item.entry.title));
|
||||||
|
expect(wrongName.length).toBe(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should fetch favorites', () => {
|
it('should fetch favorites', () => {
|
||||||
const favoritesApi = apiService.getInstance().core.favoritesApi;
|
const favoritesApi = apiService.getInstance().core.favoritesApi;
|
||||||
spyOn(favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(null));
|
spyOn(favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(null));
|
||||||
|
@@ -608,7 +608,15 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.apiService.sitesApi.getSites(options)
|
this.apiService.sitesApi.getSites(options)
|
||||||
.then((page: NodePaging) => this.onPageLoaded(page, merge))
|
.then((page: NodePaging) => {
|
||||||
|
page.list.entries.map(
|
||||||
|
({entry}: any) => {
|
||||||
|
entry.name = entry.name || entry.title;
|
||||||
|
return {entry};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.onPageLoaded(page, merge);
|
||||||
|
})
|
||||||
.catch(error => this.error.emit(error));
|
.catch(error => this.error.emit(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -626,6 +634,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
entries: result.list.entries
|
entries: result.list.entries
|
||||||
.map(({entry: {site}}: any) => {
|
.map(({entry: {site}}: any) => {
|
||||||
site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION];
|
site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION];
|
||||||
|
site.name = site.name || site.title;
|
||||||
return {
|
return {
|
||||||
entry: site
|
entry: site
|
||||||
};
|
};
|
||||||
|
@@ -115,3 +115,79 @@ export const fakeNodeAnswerWithNOEntries = {
|
|||||||
'entries': []
|
'entries': []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const fakeGetSitesAnswer = {
|
||||||
|
'list': {
|
||||||
|
'pagination': {
|
||||||
|
'count': 3,
|
||||||
|
'hasMoreItems': false,
|
||||||
|
'totalItems': 3,
|
||||||
|
'skipCount': 0,
|
||||||
|
'maxItems': 20
|
||||||
|
},
|
||||||
|
'entries': [{
|
||||||
|
'entry': {
|
||||||
|
'role': 'SiteManager',
|
||||||
|
'visibility': 'PRIVATE',
|
||||||
|
'guid': 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b',
|
||||||
|
'id': 'admin-site',
|
||||||
|
'preset': 'site-dashboard',
|
||||||
|
'title': 'Admin Site'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'role': 'SiteManager',
|
||||||
|
'visibility': 'PUBLIC',
|
||||||
|
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||||
|
'description': 'This is a Sample Alfresco Team site.',
|
||||||
|
'id': 'swsdp',
|
||||||
|
'preset': 'site-dashboard',
|
||||||
|
'title': 'Sample: Web Site Design Project'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'visibility': 'PUBLIC',
|
||||||
|
'guid': 'af36cf8f-d43c-4a4b-84e6-d1b03e3a2ce5',
|
||||||
|
'id': 'test-site',
|
||||||
|
'preset': 'site-dashboard',
|
||||||
|
'title': 'Test Site'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fakeGetSiteMembership = {
|
||||||
|
'list': {
|
||||||
|
'pagination': {
|
||||||
|
'count': 2,
|
||||||
|
'hasMoreItems': false,
|
||||||
|
'totalItems': 2,
|
||||||
|
'skipCount': 0,
|
||||||
|
'maxItems': 20
|
||||||
|
},
|
||||||
|
'entries': [{
|
||||||
|
'entry': {
|
||||||
|
'site': {
|
||||||
|
'role': 'SiteManager',
|
||||||
|
'visibility': 'PRIVATE',
|
||||||
|
'guid': 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b',
|
||||||
|
'id': 'admin-site',
|
||||||
|
'preset': 'site-dashboard',
|
||||||
|
'title': 'Admin Site'
|
||||||
|
}, 'role': 'SiteManager', 'guid': 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', 'id': 'admin-site'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'site': {
|
||||||
|
'role': 'SiteManager',
|
||||||
|
'visibility': 'PUBLIC',
|
||||||
|
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||||
|
'description': 'This is a Sample Alfresco Team site.',
|
||||||
|
'id': 'swsdp',
|
||||||
|
'preset': 'site-dashboard',
|
||||||
|
'title': 'Sample: Web Site Design Project'
|
||||||
|
}, 'role': 'SiteManager', 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', 'id': 'swsdp'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user