[ACA] Shared link - update functionality (#713)

* toggle expiration input field

* expiration input field animation

* update node on value changed

* cleanup code

* test

* fix test

* remove event parameter

* remove event parameter
This commit is contained in:
Cilibiu Bogdan
2018-10-14 22:18:56 +03:00
committed by Denys Vuika
parent 4802656d79
commit b9591ea37f
4 changed files with 108 additions and 27 deletions

View File

@@ -28,6 +28,7 @@ import {
} from '@alfresco/adf-core';
import { ContentNodeShareModule } from './content-node-share.module';
import { ShareDialogComponent } from './content-node-share.dialog';
import moment from 'moment-es6';
describe('ShareDialogComponent', () => {
let node;
@@ -36,6 +37,7 @@ describe('ShareDialogComponent', () => {
openSnackMessage: jasmine.createSpy('openSnackMessage')
};
let sharedLinksApiService: SharedLinksApiService;
let nodesApiService: NodesApiService;
let fixture;
let component;
@@ -58,6 +60,7 @@ describe('ShareDialogComponent', () => {
fixture = TestBed.createComponent(ShareDialogComponent);
matDialog = TestBed.get(MatDialog);
sharedLinksApiService = TestBed.get(SharedLinksApiService);
nodesApiService = TestBed.get(NodesApiService);
component = fixture.componentInstance;
});
@@ -176,7 +179,7 @@ describe('ShareDialogComponent', () => {
it('should unshare file when confirmation dialog returns true', fakeAsync(() => {
spyOn(matDialog, 'open').and.returnValue({ beforeClose: () => of(true) });
spyOn(sharedLinksApiService, 'deleteSharedLink');
spyOn(sharedLinksApiService, 'deleteSharedLink').and.returnValue(of(null));
node.entry.properties['qshare:sharedId'] = 'sharedId';
component.data = {
@@ -242,4 +245,31 @@ describe('ShareDialogComponent', () => {
.disabled
).toBe(true);
});
it('should update node expiration date with selected date and time', () => {
const date = moment();
node.entry.properties['qshare:sharedId'] = 'sharedId';
node.entry.allowableOperations = [];
spyOn(nodesApiService, 'updateNode').and.returnValue(of({}));
fixture.componentInstance.form.controls['time'].setValue(null);
component.data = {
node,
permission: true,
baseShareUrl: 'some-url/'
};
fixture.detectChanges();
fixture.nativeElement
.querySelector('mat-slide-toggle[data-automation-id="adf-expire-toggle"]')
.dispatchEvent(new MouseEvent('click'));
fixture.componentInstance.form.controls['time'].setValue(date);
fixture.detectChanges();
expect(nodesApiService.updateNode).toHaveBeenCalledWith('nodeId', {
properties: { 'qshare:expiryDate': date.utc().format() }
});
});
});