[ADF-2540] Lock node feature (#3138)

* add adf-node-lock directive

* add lock-node service + button in context menu

* unit tests

* docs

* unit tests fix

* Remove unnecessary imports

* PR changes

* Remove fit from tests

* Update specific node from list on lock/ulock
This commit is contained in:
Alex Bolboșenco
2018-04-06 08:59:28 +03:00
committed by Denys Vuika
parent 7b7e39d989
commit 7d1b4bf14a
26 changed files with 643 additions and 29 deletions

View File

@@ -22,6 +22,7 @@ import { DocumentListService } from '../document-list/services/document-list.ser
import { ContentNodeDialogService } from './content-node-dialog.service';
import { MatDialog } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
const fakeNode: MinimalNodeEntryEntity = <MinimalNodeEntryEntity> {
id: 'fake',
@@ -56,6 +57,7 @@ describe('ContentNodeDialogService', () => {
let sitesService: SitesService;
let materialDialog: MatDialog;
let spyOnDialogOpen: jasmine.Spy;
let afterOpenObservable: Subject<any>;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -66,6 +68,7 @@ describe('ContentNodeDialogService', () => {
MatDialog
]
}).compileComponents();
}));
beforeEach(() => {
@@ -75,12 +78,29 @@ describe('ContentNodeDialogService', () => {
service = TestBed.get(ContentNodeDialogService);
documentListService = TestBed.get(DocumentListService);
materialDialog = TestBed.get(MatDialog);
sitesService = TestBed.get(SitesService);
spyOnDialogOpen = spyOn(materialDialog, 'open').and.stub();
spyOn(materialDialog, 'closeAll').and.stub();
sitesService = TestBed.get(SitesService);
afterOpenObservable = new Subject<any>();
spyOnDialogOpen = spyOn(materialDialog, 'open').and.returnValue({
afterOpen: () => afterOpenObservable,
afterClosed: () => Observable.of({}),
componentInstance: {
error: new Subject<any>()
}
});
});
it('should not open the lock node dialog if have no permission', () => {
const testNode: MinimalNodeEntryEntity = <MinimalNodeEntryEntity> {
id: 'fake',
isFile: false
};
service.openLockNodeDialog(testNode).subscribe(() => {}, (error) => {
expect(error).toBe('OPERATION.FAIL.NODE.NO_PERMISSION');
});
});
it('should be able to create the service', () => {
expect(service).not.toBeNull();
});
@@ -123,6 +143,7 @@ describe('ContentNodeDialogService', () => {
}));
it('should be able to close the material dialog', () => {
spyOn(materialDialog, 'closeAll');
service.close();
expect(materialDialog.closeAll).toHaveBeenCalled();
});