[ACA-2345] Metadata - edit button is not displayed for folders (#1078)

* remove node type check

* tests
This commit is contained in:
Cilibiu Bogdan
2019-04-17 11:57:30 +03:00
committed by Adina Parpalita
parent 380a5f0cb0
commit b2b234c3cb
2 changed files with 61 additions and 3 deletions

View File

@@ -24,9 +24,67 @@
*/
import { MetadataTabComponent } from './metadata-tab.component';
import { NodePermissionService } from '../../../services/node-permission.service';
import { Node } from '@alfresco/js-api';
describe('MetadataTabComponent', () => {
it('should be defined', () => {
expect(MetadataTabComponent).toBeDefined();
let nodePermissionService: NodePermissionService;
let component: MetadataTabComponent;
beforeEach(() => {
nodePermissionService = new NodePermissionService();
const appConfig = <any>{ config: { 'content-metadata': {} } };
const extension = <any>{ contentMetadata: {} };
component = new MetadataTabComponent(
nodePermissionService,
extension,
appConfig
);
});
describe('canUpdateNode()', () => {
it('should return true if node is not locked and has update permission', () => {
const node = <Node>{
isLocked: false,
allowableOperations: ['update']
};
component.node = node;
expect(component.canUpdateNode).toBe(true);
});
it('should return false if node is locked', () => {
const node = <Node>{
isLocked: true,
allowableOperations: ['update']
};
component.node = node;
expect(component.canUpdateNode).toBe(false);
});
it('should return false if node has no update permission', () => {
const node = <Node>{
isLocked: false,
allowableOperations: ['other']
};
component.node = node;
expect(component.canUpdateNode).toBe(false);
});
it('should return false if node has read only property', () => {
const node = <Node>{
isLocked: false,
allowableOperations: ['update'],
properties: {
'cm:lockType': 'WRITE_LOCK'
}
};
component.node = node;
expect(component.canUpdateNode).toBe(false);
});
});
});

View File

@@ -65,7 +65,7 @@ export class MetadataTabComponent {
}
get canUpdateNode(): boolean {
if (this.node && this.node.isFile && !isLocked({ entry: this.node })) {
if (this.node && !isLocked({ entry: this.node })) {
return this.permission.check(this.node, ['update']);
}