mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-524] Datatable loading state (#1958)
* loading state datatable * modify readme after review
This commit is contained in:
committed by
Eugenio Romano
parent
069345a028
commit
f3d5b88671
@@ -28,6 +28,7 @@ import { ShareDataRow, RowFilter, ImageResolver } from './../data/share-datatabl
|
||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
||||
import { DocumentMenuActionComponent } from './document-menu-action.component';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { MdProgressSpinnerModule } from '@angular/material';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -43,7 +44,7 @@ let fakeNodeAnswerWithEntries = {
|
||||
'entries': [{
|
||||
'entry': {
|
||||
'isFile': true,
|
||||
'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
|
||||
'createdByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
||||
'modifiedAt': '2017-05-24T15:08:55.640Z',
|
||||
'nodeType': 'cm:content',
|
||||
'content': {
|
||||
@@ -60,13 +61,13 @@ let fakeNodeAnswerWithEntries = {
|
||||
'elements': [{
|
||||
'id': '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
'name': 'Company Home'
|
||||
}, { 'id': 'd124de26-6ba0-4f40-8d98-4907da2d337a', 'name': 'Guest Home' }]
|
||||
}, {'id': 'd124de26-6ba0-4f40-8d98-4907da2d337a', 'name': 'Guest Home'}]
|
||||
},
|
||||
'isFolder': false,
|
||||
'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
|
||||
'modifiedByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
||||
'name': 'b_txt_file.rtf',
|
||||
'id': '67b80f77-dbca-4f58-be6c-71b9dd61ea53',
|
||||
'properties': { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
|
||||
'properties': {'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR'},
|
||||
'allowableOperations': ['delete', 'update']
|
||||
}
|
||||
}]
|
||||
@@ -100,7 +101,8 @@ describe('DocumentList', () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot(),
|
||||
DataTableModule.forRoot()
|
||||
DataTableModule.forRoot(),
|
||||
MdProgressSpinnerModule
|
||||
],
|
||||
declarations: [
|
||||
DocumentListComponent,
|
||||
@@ -108,7 +110,7 @@ describe('DocumentList', () => {
|
||||
],
|
||||
providers: [
|
||||
DocumentListService,
|
||||
{ provide: NgZone, useValue: zone }
|
||||
{provide: NgZone, useValue: zone}
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
@@ -199,6 +201,19 @@ describe('DocumentList', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should show the loading state during the loading of new elements', (done) => {
|
||||
documentList.ngAfterContentInit();
|
||||
documentList.node = new NodePaging();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#adf-document-list-loading')).toBeDefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not execute action without node provided', () => {
|
||||
let action = new ContentActionModel();
|
||||
action.handler = function () {
|
||||
@@ -248,7 +263,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
let nodeFile = {entry: {isFile: true, name: 'xyz', allowableOperations: ['create', 'update']}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -269,7 +284,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
let nodeFile = {entry: {isFolder: true, name: 'xyz', allowableOperations: ['create', 'update']}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -290,7 +305,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
let nodeFile = {entry: {isFile: true, name: 'xyz', allowableOperations: ['create', 'update']}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -310,7 +325,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||
let nodeFile = {entry: {isFolder: true, name: 'xyz', allowableOperations: ['create', 'update']}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -330,7 +345,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
||||
let nodeFile = {entry: {isFile: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete']}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -350,7 +365,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
||||
let nodeFile = {entry: {isFolder: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete']}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -369,7 +384,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
||||
let nodeFile = {entry: {isFile: true, name: 'xyz', allowableOperations: null}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -388,7 +403,7 @@ describe('DocumentList', () => {
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
||||
let nodeFile = {entry: {isFolder: true, name: 'xyz', allowableOperations: null}};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
@@ -692,7 +707,7 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
documentList.currentFolderId = 'wrong-id';
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(null, documentList.currentFolderId, true) });
|
||||
documentList.ngOnChanges({currentFolderId: new SimpleChange(null, documentList.currentFolderId, true)});
|
||||
});
|
||||
|
||||
it('should require dataTable to check empty template', () => {
|
||||
@@ -784,11 +799,11 @@ describe('DocumentList', () => {
|
||||
it('should load folder by ID on init', () => {
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
spyOn(documentList, 'loadFolderNodesByFolderNodeId').and.returnValue(Promise.resolve());
|
||||
documentList.ngOnChanges({ folderNode: new SimpleChange(null, documentList.currentFolderId, true) });
|
||||
documentList.ngOnChanges({folderNode: new SimpleChange(null, documentList.currentFolderId, true)});
|
||||
expect(documentList.loadFolderNodesByFolderNodeId).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should load previous page if there are no other elements in multi page table', async(() => {
|
||||
it('should load previous page if there are no other elements in multi page table', () => {
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
documentList.folderNode = new NodeMinimal();
|
||||
documentList.folderNode.id = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
@@ -799,11 +814,12 @@ describe('DocumentList', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
documentList.ready.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let rowElement = element.querySelector('[data-automation-id="b_txt_file.rtf"]');
|
||||
expect(rowElement).toBeDefined();
|
||||
expect(rowElement).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.at(0).respondWith({
|
||||
@@ -817,5 +833,5 @@ describe('DocumentList', () => {
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeNodeAnswerWithEntries)
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user