mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ADF-2163] added test for target action 'all'
This commit is contained in:
@@ -198,7 +198,6 @@
|
|||||||
<!-- folder actions -->
|
<!-- folder actions -->
|
||||||
<content-action
|
<content-action
|
||||||
icon="content_copy"
|
icon="content_copy"
|
||||||
|
|
||||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.COPY' | translate}}"
|
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.COPY' | translate}}"
|
||||||
permission="update"
|
permission="update"
|
||||||
[disableWithNoPermission]="true"
|
[disableWithNoPermission]="true"
|
||||||
@@ -206,19 +205,8 @@
|
|||||||
(success)="onContentActionSuccess($event)"
|
(success)="onContentActionSuccess($event)"
|
||||||
handler="copy">
|
handler="copy">
|
||||||
</content-action>
|
</content-action>
|
||||||
<!-- <content-action
|
|
||||||
icon="content_copy"
|
|
||||||
target="document"
|
|
||||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.COPY' | translate}}"
|
|
||||||
permission="update"
|
|
||||||
[disableWithNoPermission]="true"
|
|
||||||
(error)="onContentActionError($event)"
|
|
||||||
(success)="onContentActionSuccess($event)"
|
|
||||||
handler="copy">
|
|
||||||
</content-action> -->
|
|
||||||
<content-action
|
<content-action
|
||||||
icon="redo"
|
icon="redo"
|
||||||
target="folder"
|
|
||||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.MOVE' | translate}}"
|
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.MOVE' | translate}}"
|
||||||
permission="update"
|
permission="update"
|
||||||
[disableWithNoPermission]="true"
|
[disableWithNoPermission]="true"
|
||||||
@@ -228,7 +216,6 @@
|
|||||||
</content-action>
|
</content-action>
|
||||||
<content-action
|
<content-action
|
||||||
icon="delete"
|
icon="delete"
|
||||||
target="folder"
|
|
||||||
permission="delete"
|
permission="delete"
|
||||||
[disableWithNoPermission]="true"
|
[disableWithNoPermission]="true"
|
||||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}"
|
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}"
|
||||||
@@ -237,17 +224,6 @@
|
|||||||
handler="delete">
|
handler="delete">
|
||||||
</content-action>
|
</content-action>
|
||||||
<!-- document actions -->
|
<!-- document actions -->
|
||||||
|
|
||||||
<content-action
|
|
||||||
icon="redo"
|
|
||||||
target="document"
|
|
||||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.MOVE' | translate}}"
|
|
||||||
permission="update"
|
|
||||||
[disableWithNoPermission]="true"
|
|
||||||
(error)="onContentActionError($event)"
|
|
||||||
(success)="onContentActionSuccess($event)"
|
|
||||||
handler="move">
|
|
||||||
</content-action>
|
|
||||||
<content-action
|
<content-action
|
||||||
icon="storage"
|
icon="storage"
|
||||||
target="document"
|
target="document"
|
||||||
@@ -260,16 +236,6 @@
|
|||||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}"
|
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}"
|
||||||
handler="download">
|
handler="download">
|
||||||
</content-action>
|
</content-action>
|
||||||
<content-action
|
|
||||||
icon="delete"
|
|
||||||
target="document"
|
|
||||||
permission="delete"
|
|
||||||
[disableWithNoPermission]="true"
|
|
||||||
(permissionEvent)="handlePermissionError($event)"
|
|
||||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DELETE' | translate}}"
|
|
||||||
(success)="onDeleteActionSuccess($event)"
|
|
||||||
handler="delete">
|
|
||||||
</content-action>
|
|
||||||
<content-action
|
<content-action
|
||||||
*ngIf="authenticationService.isBpmLoggedIn()"
|
*ngIf="authenticationService.isBpmLoggedIn()"
|
||||||
icon="play_arrow"
|
icon="play_arrow"
|
||||||
|
|||||||
+26
-9
@@ -15,8 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*tslint:disable:ban*/
|
|
||||||
|
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { EventEmitter } from '@angular/core';
|
import { EventEmitter } from '@angular/core';
|
||||||
import { async, TestBed } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
@@ -25,7 +23,6 @@ import { DataTableModule } from '@alfresco/adf-core';
|
|||||||
import { MaterialModule } from '../../../material.module';
|
import { MaterialModule } from '../../../material.module';
|
||||||
|
|
||||||
import { DocumentListService } from '../../services/document-list.service';
|
import { DocumentListService } from '../../services/document-list.service';
|
||||||
// import { FileNode } from '../../../mock';
|
|
||||||
import { ContentActionHandler } from './../../models/content-action.model';
|
import { ContentActionHandler } from './../../models/content-action.model';
|
||||||
import { DocumentActionsService } from './../../services/document-actions.service';
|
import { DocumentActionsService } from './../../services/document-actions.service';
|
||||||
import { FolderActionsService } from './../../services/folder-actions.service';
|
import { FolderActionsService } from './../../services/folder-actions.service';
|
||||||
@@ -34,7 +31,7 @@ import { DocumentListComponent } from './../document-list.component';
|
|||||||
import { ContentActionListComponent } from './content-action-list.component';
|
import { ContentActionListComponent } from './content-action-list.component';
|
||||||
import { ContentActionComponent } from './content-action.component';
|
import { ContentActionComponent } from './content-action.component';
|
||||||
|
|
||||||
fdescribe('ContentAction', () => {
|
describe('ContentAction', () => {
|
||||||
|
|
||||||
let documentList: DocumentListComponent;
|
let documentList: DocumentListComponent;
|
||||||
let actionList: ContentActionListComponent;
|
let actionList: ContentActionListComponent;
|
||||||
@@ -133,25 +130,45 @@ fdescribe('ContentAction', () => {
|
|||||||
expect(model.handler).toBe(handler);
|
expect(model.handler).toBe(handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require target to get system handler', () => {
|
it('should create document and folder action when there is no target', () => {
|
||||||
spyOn(folderActions, 'getHandler').and.stub();
|
spyOn(folderActions, 'getHandler').and.stub();
|
||||||
spyOn(documentActions, 'getHandler').and.stub();
|
spyOn(documentActions, 'getHandler').and.stub();
|
||||||
|
|
||||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||||
action.handler = '<handler>';
|
action.handler = '<handler>';
|
||||||
|
|
||||||
|
action.ngOnInit();
|
||||||
|
expect(documentList.actions.length).toBe(2);
|
||||||
|
expect(folderActions.getHandler).toHaveBeenCalled();
|
||||||
|
expect(documentActions.getHandler).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create document action when target is document', () => {
|
||||||
|
spyOn(folderActions, 'getHandler').and.stub();
|
||||||
|
spyOn(documentActions, 'getHandler').and.stub();
|
||||||
|
|
||||||
|
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||||
|
action.handler = '<handler>';
|
||||||
|
action.target = 'document';
|
||||||
|
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
expect(documentList.actions.length).toBe(1);
|
expect(documentList.actions.length).toBe(1);
|
||||||
expect(folderActions.getHandler).not.toHaveBeenCalled();
|
expect(folderActions.getHandler).not.toHaveBeenCalled();
|
||||||
expect(documentActions.getHandler).not.toHaveBeenCalled();
|
|
||||||
|
|
||||||
action.target = 'document';
|
|
||||||
action.ngOnInit();
|
|
||||||
expect(documentActions.getHandler).toHaveBeenCalled();
|
expect(documentActions.getHandler).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create folder action when target is folder', () => {
|
||||||
|
spyOn(folderActions, 'getHandler').and.stub();
|
||||||
|
spyOn(documentActions, 'getHandler').and.stub();
|
||||||
|
|
||||||
|
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||||
|
action.handler = '<handler>';
|
||||||
action.target = 'folder';
|
action.target = 'folder';
|
||||||
|
|
||||||
action.ngOnInit();
|
action.ngOnInit();
|
||||||
|
expect(documentList.actions.length).toBe(1);
|
||||||
expect(folderActions.getHandler).toHaveBeenCalled();
|
expect(folderActions.getHandler).toHaveBeenCalled();
|
||||||
|
expect(documentActions.getHandler).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be case insensitive for document target', () => {
|
it('should be case insensitive for document target', () => {
|
||||||
|
|||||||
+8
-9
@@ -90,13 +90,11 @@ export class ContentActionComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.handler) {
|
if (this.target === 'all') {
|
||||||
if (this.target === 'all') {
|
this.generateAction('folder');
|
||||||
this.generateAction('folder');
|
this.generateAction('document');
|
||||||
this.generateAction('document');
|
} else {
|
||||||
} else {
|
this.generateAction(this.target);
|
||||||
this.generateAction(this.target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +114,9 @@ export class ContentActionComponent implements OnInit {
|
|||||||
target: target,
|
target: target,
|
||||||
disabled: this.disabled
|
disabled: this.disabled
|
||||||
});
|
});
|
||||||
|
if (this.handler) {
|
||||||
model.handler = this.getSystemHandler(target, this.handler);
|
model.handler = this.getSystemHandler(target, this.handler);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.execute) {
|
if (this.execute) {
|
||||||
model.execute = (value: any): void => {
|
model.execute = (value: any): void => {
|
||||||
|
|||||||
Reference in New Issue
Block a user