mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ADF-4753] - fixed calling for standalone task (#4952)
* [ADF-4753] - fixed calling for standalone task * [ADF-4753] added unit test * [ADF-4753] added unit test * [ADF-4753] improved unit tests * [ADF-4753] - removed extra parameter not needed
This commit is contained in:
parent
05e73a8aa1
commit
bb80d2b6d9
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { SimpleChange, DebugElement, CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
|
import { SimpleChange, DebugElement, CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { Observable, of, throwError } from 'rxjs';
|
import { Observable, of, throwError } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
FormFieldModel, FormFieldTypes, FormService, FormOutcomeEvent, FormOutcomeModel, LogService, WidgetVisibilityService,
|
FormFieldModel, FormFieldTypes, FormService, FormOutcomeEvent, FormOutcomeModel, LogService, WidgetVisibilityService,
|
||||||
@ -237,6 +237,45 @@ describe('FormCloudComponent', () => {
|
|||||||
expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(appName, taskId);
|
expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(appName, taskId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call the process storage to retrieve the folder with only the taskId', fakeAsync(() => {
|
||||||
|
spyOn(formCloudService, 'getTaskForm').and.returnValue(of(cloudFormMock));
|
||||||
|
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of({list: { entries: []}}));
|
||||||
|
spyOn(formCloudService, 'getProcessStorageFolderTask')
|
||||||
|
.and.returnValue( of({nodeId : '123', path: '/a/path/type', type: 'fakeType'}));
|
||||||
|
const taskId = '<task id>';
|
||||||
|
const appName = 'test-app';
|
||||||
|
formComponent.appName = appName;
|
||||||
|
formComponent.taskId = taskId;
|
||||||
|
|
||||||
|
const change = new SimpleChange(null, appName, true);
|
||||||
|
formComponent.ngOnChanges({ 'appName': change });
|
||||||
|
tick();
|
||||||
|
|
||||||
|
expect(formCloudService.getProcessStorageFolderTask).toHaveBeenCalledWith(appName, taskId, undefined);
|
||||||
|
expect(formComponent.form.nodeId).toBe('123');
|
||||||
|
expect(formComponent.form.contentHost).toBe('/a/path/type');
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should call the process storage to retrieve the folder with taskId and processInstanceId', fakeAsync(() => {
|
||||||
|
spyOn(formCloudService, 'getTaskForm').and.returnValue(of(cloudFormMock));
|
||||||
|
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of({list: { entries: []}}));
|
||||||
|
spyOn(formCloudService, 'getProcessStorageFolderTask')
|
||||||
|
.and.returnValue( of({nodeId : '123', path: '/a/path/type', type: 'fakeType'}));
|
||||||
|
const taskId = '<task id>';
|
||||||
|
const processInstanceId = 'i-am-the-process-instance-id';
|
||||||
|
const appName = 'test-app';
|
||||||
|
formComponent.appName = appName;
|
||||||
|
formComponent.taskId = taskId;
|
||||||
|
formComponent.processInstanceId = processInstanceId;
|
||||||
|
|
||||||
|
const change = new SimpleChange(null, 'new-app-name', true);
|
||||||
|
formComponent.ngOnChanges({ 'appName': change });
|
||||||
|
tick();
|
||||||
|
expect(formCloudService.getProcessStorageFolderTask).toHaveBeenCalledWith(appName, taskId, processInstanceId);
|
||||||
|
expect(formComponent.form.nodeId).toBe('123');
|
||||||
|
expect(formComponent.form.contentHost).toBe('/a/path/type');
|
||||||
|
}));
|
||||||
|
|
||||||
it('should reload form definition by form id on binding changes', () => {
|
it('should reload form definition by form id on binding changes', () => {
|
||||||
spyOn(formComponent, 'getFormById').and.stub();
|
spyOn(formComponent, 'getFormById').and.stub();
|
||||||
const formId = '123';
|
const formId = '123';
|
||||||
|
@ -117,10 +117,8 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
const appName = changes['appName'];
|
const appName = changes['appName'];
|
||||||
if (appName && appName.currentValue) {
|
if (appName && appName.currentValue) {
|
||||||
if (this.taskId && this.processInstanceId) {
|
if (this.taskId) {
|
||||||
this.getFormDefinitionWithFolderTask(this.appName, this.taskId, this.processInstanceId);
|
this.getFormDefinitionWithFolderTask(this.appName, this.taskId, this.processInstanceId);
|
||||||
} else if (this.taskId) {
|
|
||||||
this.getFormByTaskId(this.appName, this.taskId);
|
|
||||||
} else if (this.formId) {
|
} else if (this.formId) {
|
||||||
this.getFormById(appName.currentValue, this.formId);
|
this.getFormById(appName.currentValue, this.formId);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,6 @@ describe('Form Cloud service', () => {
|
|||||||
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('GET');
|
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('GET');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch task form flattened', (done) => {
|
it('should fetch task form flattened', (done) => {
|
||||||
@ -187,5 +186,43 @@ describe('Form Cloud service', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should fetch process storage folder with process instance id and task id', (done) => {
|
||||||
|
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({
|
||||||
|
nodeId: 'fake-node-id-really-long',
|
||||||
|
path: 'path/to/node/id',
|
||||||
|
type: 'nodeType'
|
||||||
|
}));
|
||||||
|
|
||||||
|
service.getProcessStorageFolderTask(appName, taskId, processInstanceId).subscribe((result) => {
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
expect(result).not.toBeNull();
|
||||||
|
expect(result.nodeId).toBe('fake-node-id-really-long');
|
||||||
|
expect(result.path).toBe('path/to/node/id');
|
||||||
|
expect(result.type).toBe('nodeType');
|
||||||
|
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[0].endsWith(`${appName}/process-storage/v1/folders/${processInstanceId}/${taskId}`)).toBeTruthy();
|
||||||
|
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('GET');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fetch process storage folder with task id only', (done) => {
|
||||||
|
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({
|
||||||
|
nodeId: 'fake-node-id-really-long',
|
||||||
|
path: 'path/to/node/id',
|
||||||
|
type: 'nodeType'
|
||||||
|
}));
|
||||||
|
|
||||||
|
service.getProcessStorageFolderTask(appName, taskId, null).subscribe((result) => {
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
expect(result).not.toBeNull();
|
||||||
|
expect(result.nodeId).toBe('fake-node-id-really-long');
|
||||||
|
expect(result.path).toBe('path/to/node/id');
|
||||||
|
expect(result.type).toBe('nodeType');
|
||||||
|
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[0].endsWith(`${appName}/process-storage/v1/folders/${taskId}`)).toBeTruthy();
|
||||||
|
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('GET');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -299,7 +299,9 @@ export class FormCloudService extends BaseCloudService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private buildFolderTask(appName: string, taskId: string, processInstanceId: string): string {
|
private buildFolderTask(appName: string, taskId: string, processInstanceId: string): string {
|
||||||
return `${this.getBasePath(appName)}/process-storage/v1/folders/${processInstanceId}/${taskId}`;
|
return processInstanceId
|
||||||
|
? `${this.getBasePath(appName)}/process-storage/v1/folders/${processInstanceId}/${taskId}`
|
||||||
|
: `${this.getBasePath(appName)}/process-storage/v1/folders/${taskId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(error: any) {
|
private handleError(error: any) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user