[ADF-4400] Versioning - restore does not update the document list (#4605)

* emit NodeInfo data on restore

* update row data and cache on node update event

* tests

* fix metadatat e2e
This commit is contained in:
Cilibiu Bogdan
2019-04-16 12:59:37 +03:00
committed by Eugenio Romano
parent 74e918d916
commit 36ce9bce0d
5 changed files with 130 additions and 13 deletions

View File

@@ -17,8 +17,16 @@
import { DateCellComponent } from './date-cell.component';
import { Subject } from 'rxjs';
import { AlfrescoApiServiceMock, AppConfigService } from '@alfresco/adf-core';
import { Node } from '@alfresco/js-api';
describe('DataTableCellComponent', () => {
let alfrescoApiService: AlfrescoApiServiceMock;
beforeEach(() => {
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null));
});
it('should use medium format by default', () => {
const component = new DateCellComponent(null, null);
expect(component.format).toBe('medium');
@@ -37,4 +45,72 @@ describe('DataTableCellComponent', () => {
component.ngOnInit();
expect(component.format).toBe('longTime');
});
it('should update cell data on alfrescoApiService.nodeUpdated event', () => {
const component = new DateCellComponent(
null,
alfrescoApiService
);
component.column = {
key: 'name',
type: 'text'
};
component.row = <any> {
cache: {
name: 'some-name'
},
node: {
entry: {
id: 'id',
name: 'test-name'
}
}
};
component.ngOnInit();
alfrescoApiService.nodeUpdated.next(<Node> {
id: 'id',
name: 'updated-name'
});
expect(component.row['node'].entry.name).toBe('updated-name');
expect(component.row['cache'].name).toBe('updated-name');
});
it('not should update cell data if ids don`t match', () => {
const component = new DateCellComponent(
null,
alfrescoApiService
);
component.column = {
key: 'name',
type: 'text'
};
component.row = <any> {
cache: {
name: 'some-name'
},
node: {
entry: {
id: 'some-id',
name: 'test-name'
}
}
};
component.ngOnInit();
alfrescoApiService.nodeUpdated.next(<Node> {
id: 'id',
name: 'updated-name'
});
expect(component.row['node'].entry.name).not.toBe('updated-name');
expect(component.row['cache'].name).not.toBe('updated-name');
});
});

View File

@@ -85,10 +85,9 @@ export class DataTableCellComponent implements OnInit, OnDestroy {
this.updateValue();
this.sub = this.alfrescoApiService.nodeUpdated.subscribe((node: Node) => {
if (this.row) {
const { entry } = this.row['node'];
if (entry === node) {
this.row['node'] = { entry };
if (this.row['node'].entry.id === node.id) {
this.row['node'].entry = node;
this.row['cache'][this.column.key] = this.column.key.split('.').reduce((source, key) => source[key], node);
this.updateValue();
}
}