mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Execute test when change exclude file (#5989)
* Execute test when change exclude file * Update protractor.excludes.json * Update nx.json * fix first call use all params document list
This commit is contained in:
@@ -74,7 +74,8 @@ describe('DocumentList', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
eventMock = {
|
||||
preventDefault: function () {}
|
||||
preventDefault: function () {
|
||||
}
|
||||
};
|
||||
|
||||
fixture = TestBed.createComponent(DocumentListComponent);
|
||||
@@ -278,7 +279,7 @@ describe('DocumentList', () => {
|
||||
|
||||
documentList.executeContentAction(node, action);
|
||||
expect(action.handler).toHaveBeenCalledWith(node, documentList, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
it('should call action handler with node and permission', () => {
|
||||
const node = new FileNode();
|
||||
@@ -457,7 +458,7 @@ describe('DocumentList', () => {
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not display hidden content actions', () => {
|
||||
documentList.actions = [
|
||||
@@ -546,7 +547,7 @@ describe('DocumentList', () => {
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should disable the action if there is no permission for the folder and disableWithNoPermission true', () => {
|
||||
const documentMenu = new ContentActionModel({
|
||||
@@ -566,7 +567,7 @@ describe('DocumentList', () => {
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FolderAction');
|
||||
expect(actions[0].disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not disable the action if there is the right permission for the file', () => {
|
||||
const documentMenu = new ContentActionModel({
|
||||
@@ -830,7 +831,7 @@ describe('DocumentList', () => {
|
||||
|
||||
documentList.onNodeClick(null);
|
||||
expect(documentList.loadFolder).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should display folder content only on folder node click', () => {
|
||||
expect(documentList.navigate).toBe(true);
|
||||
@@ -1180,13 +1181,15 @@ describe('DocumentList', () => {
|
||||
documentList.onNodeDblClick(node);
|
||||
});
|
||||
|
||||
it('should load folder by ID on init', () => {
|
||||
it('should load folder by ID on init', async () => {
|
||||
spyOn(documentList, 'loadFolder').and.returnValue(Promise.resolve());
|
||||
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, '1d26e465-dea3-42f3-b415-faa8364b9692', true) });
|
||||
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(documentList.loadFolder).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -1442,13 +1445,13 @@ describe('DocumentList', () => {
|
||||
documentList.includeFields = ['test-include'];
|
||||
documentList.currentFolderId = 'fake-id';
|
||||
|
||||
fixture.detectChanges();
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
||||
|
||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
||||
where: undefined,
|
||||
maxItems: 25,
|
||||
skipCount: 0,
|
||||
orderBy: ['isFolder DESC', 'name asc' ],
|
||||
orderBy: ['isFolder DESC', 'name asc'],
|
||||
rootFolderId: 'fake-id'
|
||||
}, ['test-include']);
|
||||
});
|
||||
@@ -1458,13 +1461,13 @@ describe('DocumentList', () => {
|
||||
documentList.where = '(isFolder=true)';
|
||||
documentList.currentFolderId = 'fake-id';
|
||||
|
||||
fixture.detectChanges();
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
||||
|
||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
||||
where: '(isFolder=true)',
|
||||
maxItems: 25,
|
||||
skipCount: 0,
|
||||
orderBy: ['isFolder DESC', 'name asc' ],
|
||||
orderBy: ['isFolder DESC', 'name asc'],
|
||||
rootFolderId: 'fake-id'
|
||||
}, ['test-include']);
|
||||
});
|
||||
@@ -1472,15 +1475,15 @@ describe('DocumentList', () => {
|
||||
it('should add orderBy in the server request', () => {
|
||||
documentList.includeFields = ['test-include'];
|
||||
documentList.sorting = ['size', 'DESC'];
|
||||
documentList.currentFolderId = 'fake-id';
|
||||
documentList.where = null;
|
||||
documentList.currentFolderId = 'fake-id';
|
||||
|
||||
fixture.detectChanges();
|
||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
||||
|
||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
||||
maxItems: 25,
|
||||
skipCount: 0,
|
||||
where: undefined,
|
||||
where: null,
|
||||
orderBy: ['isFolder DESC', 'size DESC'],
|
||||
rootFolderId: 'fake-id'
|
||||
}, ['test-include']);
|
||||
@@ -1494,15 +1497,23 @@ describe('DocumentList', () => {
|
||||
skipCount: 10
|
||||
});
|
||||
|
||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, Object({
|
||||
maxItems: 10,
|
||||
skipCount: 10,
|
||||
orderBy: ['name ASC'],
|
||||
rootFolderId: 'no-node',
|
||||
where: undefined
|
||||
}), undefined);
|
||||
|
||||
documentList.onNodeClick(folder);
|
||||
|
||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, Object({
|
||||
maxItems: 25,
|
||||
skipCount: 0,
|
||||
orderBy: ['isFolder DESC', 'name asc' ],
|
||||
orderBy: ['name ASC'],
|
||||
rootFolderId: 'folder-id',
|
||||
where: undefined
|
||||
}, undefined);
|
||||
}), undefined);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -233,7 +233,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this._rowFilter = rowFilter;
|
||||
if (this.data) {
|
||||
this.data.setFilter(this._rowFilter);
|
||||
if (this._currentFolderId) {
|
||||
if (this.currentFolderId) {
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
@@ -255,31 +255,9 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
@Input()
|
||||
stickyHeader: boolean = false;
|
||||
|
||||
_currentFolderId: string = null;
|
||||
|
||||
/** The ID of the folder node to display or a reserved string alias for special sources */
|
||||
@Input()
|
||||
set currentFolderId(currentFolderId: string) {
|
||||
if (this._currentFolderId !== currentFolderId) {
|
||||
this._currentFolderId = currentFolderId;
|
||||
if (this.sorting) {
|
||||
const [key, direction] = this.sorting;
|
||||
this.orderBy = this.buildOrderByArray(key, direction);
|
||||
}
|
||||
if (this.data) {
|
||||
this.data.loadPage(null, false);
|
||||
this.resetNewFolderPagination();
|
||||
}
|
||||
|
||||
if (this._currentFolderId) {
|
||||
this.loadFolder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get currentFolderId(): string {
|
||||
return this._currentFolderId;
|
||||
}
|
||||
currentFolderId: string = null;
|
||||
|
||||
/** The Document list will show all the nodes contained in the NodePaging entity */
|
||||
@Input()
|
||||
@@ -461,15 +439,15 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
const columns = this.data.getColumns();
|
||||
if (!columns || columns.length === 0) {
|
||||
this.setupDefaultColumns(this._currentFolderId);
|
||||
this.setupDefaultColumns(this.currentFolderId);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
this.resetSelection();
|
||||
|
||||
if (changes.sorting && changes.sorting.currentValue) {
|
||||
const [key, direction] = changes.sorting.currentValue;
|
||||
if (this.sorting) {
|
||||
const [key, direction] = this.sorting;
|
||||
this.orderBy = this.buildOrderByArray(key, direction);
|
||||
}
|
||||
|
||||
@@ -489,6 +467,19 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
}
|
||||
|
||||
if (changes['currentFolderId']?.currentValue !== changes['currentFolderId']?.previousValue) {
|
||||
if (this.data) {
|
||||
this.data.loadPage(null, false);
|
||||
this.resetNewFolderPagination();
|
||||
}
|
||||
|
||||
if (changes['currentFolderId'].currentValue) {
|
||||
|
||||
this.loadFolder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.data) {
|
||||
if (changes.node && changes.node.currentValue) {
|
||||
const merge = this._pagination ? this._pagination.merge : false;
|
||||
@@ -597,15 +588,15 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
navigateTo(node: Node | string): boolean {
|
||||
if (typeof node === 'string') {
|
||||
this.resetNewFolderPagination();
|
||||
this._currentFolderId = node;
|
||||
this.currentFolderId = node;
|
||||
this.folderChange.emit(new NodeEntryEvent(<Node> {id: node}));
|
||||
this.reload();
|
||||
return true;
|
||||
} else {
|
||||
if (this.canNavigateFolder(node)) {
|
||||
this.resetNewFolderPagination();
|
||||
this._currentFolderId = this.getNodeFolderDestinationId(node);
|
||||
this.folderChange.emit(new NodeEntryEvent(<Node> {id: this._currentFolderId}));
|
||||
this.currentFolderId = this.getNodeFolderDestinationId(node);
|
||||
this.folderChange.emit(new NodeEntryEvent(<Node> {id: this.currentFolderId}));
|
||||
this.reload();
|
||||
return true;
|
||||
}
|
||||
@@ -623,7 +614,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
updateCustomSourceData(nodeId: string): void {
|
||||
this._currentFolderId = nodeId;
|
||||
this.currentFolderId = nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,20 +653,19 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
loadFolder() {
|
||||
|
||||
if (!this._pagination.merge) {
|
||||
this.setLoadingState(true);
|
||||
}
|
||||
|
||||
if (!this.hasCustomLayout) {
|
||||
this.setupDefaultColumns(this._currentFolderId);
|
||||
this.setupDefaultColumns(this.currentFolderId);
|
||||
}
|
||||
|
||||
if (this.documentListService.isCustomSourceService(this._currentFolderId)) {
|
||||
this.updateCustomSourceData(this._currentFolderId);
|
||||
if (this.documentListService.isCustomSourceService(this.currentFolderId)) {
|
||||
this.updateCustomSourceData(this.currentFolderId);
|
||||
}
|
||||
|
||||
this.documentListService.loadFolderByNodeId(this._currentFolderId, this._pagination, this.includeFields, this.where, this.orderBy)
|
||||
this.documentListService.loadFolderByNodeId(this.currentFolderId, this._pagination, this.includeFields, this.where, this.orderBy)
|
||||
.subscribe((documentNode: DocumentLoaderNode) => {
|
||||
if (documentNode.currentNode) {
|
||||
this.folderNode = documentNode.currentNode.entry;
|
||||
|
Reference in New Issue
Block a user