[ADF-1220] Extra data sources for Document List (#2224)

* initial trashcan support and demo page

* use testbed for unit tests

* support for restricting navigation for special data sources

* shared links mode, thumbnail fixes

* update unit tests

* improve Trashcan/SharedLinks columns

* Sites view for document list

* Favorites support for DL, upgrade to latest js-api (alpha)

* recent files support for document list

* support default presets

* readme updates and code fixes

* code fixes

* breadcrumb fixes

- show custom root node for certain scenarios
- fix css issues
- fix crash related to missing "path" property for certain scenarios

* toolbar style fixes

- addresses the shrinking issues with components embedded into toolbar (i.e. breadcrumb)

* i18n support for column presets

* unit tests
This commit is contained in:
Denys Vuika
2017-08-17 14:31:00 +01:00
committed by Mario Romano
parent 6b1742c5f0
commit def3cbaee8
36 changed files with 1806 additions and 4215 deletions

View File

@@ -17,7 +17,7 @@
import { CUSTOM_ELEMENTS_SCHEMA, NgZone, SimpleChange, TemplateRef } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { AlfrescoApiService, AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { DataColumn, DataTableComponent } from 'ng2-alfresco-datatable';
import { DataTableModule } from 'ng2-alfresco-datatable';
import { Observable, Subject } from 'rxjs/Rx';
@@ -41,10 +41,10 @@ describe('DocumentList', () => {
let documentList: DocumentListComponent;
let documentListService: DocumentListService;
let apiService: AlfrescoApiService;
let fixture: ComponentFixture<DocumentListComponent>;
let element: HTMLElement;
let eventMock: any;
let componentHandler;
beforeEach(async(() => {
let zone = new NgZone({enableLongStackTrace: false});
@@ -73,15 +73,10 @@ describe('DocumentList', () => {
}
};
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered', 'upgradeElement'
]);
window['componentHandler'] = componentHandler;
fixture = TestBed.createComponent(DocumentListComponent);
let translateService = TestBed.get(AlfrescoTranslationService);
spyOn(translateService, 'addTranslationFolder').and.stub();
// spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => {
return Observable.of(key);
});
@@ -89,6 +84,7 @@ describe('DocumentList', () => {
element = fixture.nativeElement;
documentList = fixture.componentInstance;
documentListService = TestBed.get(DocumentListService);
apiService = TestBed.get(AlfrescoApiService);
fixture.detectChanges();
});
@@ -120,8 +116,8 @@ describe('DocumentList', () => {
columns.push(column);
documentList.ngAfterContentInit();
expect(columns.length).toBe(3);
expect(columns[2]).toBe(column);
expect(columns.length).toBe(6);
expect(columns[5]).toBe(column);
});
it('should call action\'s handler with node', () => {
@@ -873,4 +869,67 @@ describe('DocumentList', () => {
done();
});
});
it('should not perform navigation for virtual sources', () => {
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-favorites-', '-recent-'];
const node = new FolderNode('folder');
documentList.currentFolderId = 'node-id';
expect(documentList.canNavigateFolder(node)).toBeTruthy();
sources.forEach(source => {
documentList.currentFolderId = source;
expect(documentList.canNavigateFolder(node)).toBeFalsy();
});
});
it('should fetch trashcan', () => {
const nodesApi = apiService.getInstance().core.nodesApi;
spyOn(nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-trashcan-');
expect(nodesApi.getDeletedNodes).toHaveBeenCalled();
});
it('should fetch shared links', () => {
const sharedlinksApi = apiService.getInstance().core.sharedlinksApi;
spyOn(sharedlinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-sharedlinks-');
expect(sharedlinksApi.findSharedLinks).toHaveBeenCalled();
});
it('should fetch sites', () => {
const sitesApi = apiService.getInstance().core.sitesApi;
spyOn(sitesApi, 'getSites').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-sites-');
expect(sitesApi.getSites).toHaveBeenCalled();
});
it('should fetch favorites', () => {
const favoritesApi = apiService.getInstance().core.favoritesApi;
spyOn(favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-favorites-');
expect(favoritesApi.getFavorites).toHaveBeenCalled();
});
it('should fetch recent', (done) => {
const person = { entry: { id: 'person '} };
const peopleApi = apiService.getInstance().core.peopleApi;
const searchApi = apiService.getInstance().search.searchApi;
spyOn(peopleApi, 'getPerson').and.returnValue(Promise.resolve(person));
spyOn(searchApi, 'search').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-recent-');
setTimeout(function() {
expect(peopleApi.getPerson).toHaveBeenCalledWith('-me-');
expect(searchApi.search).toHaveBeenCalled();
done();
}, 100);
});
});