mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[AAE-1336] add version on completeTaskForm (#5354)
* add version on completeTaskForm * fix test
This commit is contained in:
committed by
Eugenio Romano
parent
bea8c61d91
commit
3ecf6a3663
@@ -608,6 +608,7 @@ describe('FormCloudComponent', () => {
|
|||||||
formComponent.formCompleted.subscribe(() => completed = true);
|
formComponent.formCompleted.subscribe(() => completed = true);
|
||||||
|
|
||||||
const taskId = '123-223';
|
const taskId = '123-223';
|
||||||
|
const appVersion = 1;
|
||||||
const appName = 'test-app';
|
const appName = 'test-app';
|
||||||
const processInstanceId = '333-444';
|
const processInstanceId = '333-444';
|
||||||
|
|
||||||
@@ -620,13 +621,14 @@ describe('FormCloudComponent', () => {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
formComponent.appVersion = appVersion;
|
||||||
formComponent.form = formModel;
|
formComponent.form = formModel;
|
||||||
formComponent.taskId = taskId;
|
formComponent.taskId = taskId;
|
||||||
formComponent.appName = appName;
|
formComponent.appName = appName;
|
||||||
formComponent.processInstanceId = processInstanceId;
|
formComponent.processInstanceId = processInstanceId;
|
||||||
formComponent.completeTaskForm(outcome);
|
formComponent.completeTaskForm(outcome);
|
||||||
|
|
||||||
expect(formCloudService.completeTaskForm).toHaveBeenCalledWith(appName, formModel.taskId, processInstanceId, formModel.id, formModel.values, outcome);
|
expect(formCloudService.completeTaskForm).toHaveBeenCalledWith(appName, formModel.taskId, processInstanceId, formModel.id, formModel.values, outcome, appVersion);
|
||||||
expect(completed).toBeTruthy();
|
expect(completed).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -291,7 +291,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
completeTaskForm(outcome?: string) {
|
completeTaskForm(outcome?: string) {
|
||||||
if (this.form && this.appName && this.taskId) {
|
if (this.form && this.appName && this.taskId) {
|
||||||
this.formCloudService
|
this.formCloudService
|
||||||
.completeTaskForm(this.appName, this.taskId, this.processInstanceId, `${this.form.id}`, this.form.values, outcome)
|
.completeTaskForm(this.appName, this.taskId, this.processInstanceId, `${this.form.id}`, this.form.values, outcome, this.appVersion)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => {
|
() => {
|
||||||
|
@@ -174,11 +174,11 @@ describe('Form Cloud service', () => {
|
|||||||
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve(responseBody));
|
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve(responseBody));
|
||||||
const formId = 'form-id';
|
const formId = 'form-id';
|
||||||
|
|
||||||
service.completeTaskForm(appName, taskId, processInstanceId, formId, {}, '').subscribe((result: any) => {
|
service.completeTaskForm(appName, taskId, processInstanceId, formId, {}, '', 1).subscribe((result: any) => {
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBe('id');
|
expect(result.id).toBe('id');
|
||||||
expect(result.name).toBe('name');
|
expect(result.name).toBe('name');
|
||||||
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[0].endsWith(`${appName}/form/v1/forms/${formId}/submit`)).toBeTruthy();
|
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[0].endsWith(`${appName}/form/v1/forms/${formId}/submit/versions/1`)).toBeTruthy();
|
||||||
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('POST');
|
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('POST');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@@ -112,8 +112,8 @@ export class FormCloudService extends BaseCloudService {
|
|||||||
* @param outcome Form outcome
|
* @param outcome Form outcome
|
||||||
* @returns Updated task details
|
* @returns Updated task details
|
||||||
*/
|
*/
|
||||||
completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string): Observable<TaskDetailsCloudModel> {
|
completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string, version: number): Observable<TaskDetailsCloudModel> {
|
||||||
const apiUrl = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit`;
|
const apiUrl = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit/versions/${version}`;
|
||||||
const completeFormRepresentation = <CompleteFormRepresentation> {values: formValues, taskId: taskId, processInstanceId: processInstanceId};
|
const completeFormRepresentation = <CompleteFormRepresentation> {values: formValues, taskId: taskId, processInstanceId: processInstanceId};
|
||||||
if (outcome) {
|
if (outcome) {
|
||||||
completeFormRepresentation.outcome = outcome;
|
completeFormRepresentation.outcome = outcome;
|
||||||
|
Reference in New Issue
Block a user