Skip to content

Commit

Permalink
AAE-25409 Fix custom outcome button not starting a process if used in…
Browse files Browse the repository at this point in the history
… start process form (#10232)

* AAE-25409 Fix custom outcome button not starting a process if used in start process form

* AAE-25409 comment adjustments

* AAE-25409 remove hardcoded process version

* AAE-25409 modify start process cloud for the solution

* AAE-25409 add unit test
  • Loading branch information
wojd0 authored Sep 20, 2024
1 parent 4998bdd commit 8144006
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
[showValidationIcon]="false"
[showTitle]="false"
(formContentClicked)="onFormContentClicked($event)"
(formLoaded)="onFormLoaded($event)">
(formLoaded)="onFormLoaded($event)"
(executeOutcome)="onCustomOutcomeClicked($event.outcome.name)">
<adf-cloud-form-custom-outcomes>
<ng-template [ngTemplateOutlet]="taskFormCloudButtons">
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,36 @@ describe('StartProcessCloudComponent', () => {
expect(startProcessSpy).toHaveBeenCalledWith(component.appName, payload);
});

it('should call service with the correct parameters when formCloud is defined and custom outcome is clicked', async () => {
formDefinitionSpy.and.returnValue(of(fakeFormModelJson));
component.ngOnChanges({ appName: firstChange });
component.processForm.controls['processInstanceName'].setValue('My Process 1');
component.appName = 'test app name';
component.formCloud = new FormModel(JSON.stringify(fakeFormModelJson));
component.formCloud.values = { dropdown: { id: '1', name: 'label 2' } };
component.processDefinitionCurrent = fakeProcessDefinitions[2];
component.processPayloadCloud.processDefinitionKey = fakeProcessDefinitions[2].key;

const payload: ProcessWithFormPayloadCloud = new ProcessWithFormPayloadCloud({
processName: component.processInstanceName.value,
processDefinitionKey: fakeProcessDefinitions[2].key,
variables: {},
values: component.formCloud.values,
outcome: 'custom_outcome'
});

fixture.detectChanges();

component.onCustomOutcomeClicked('custom_outcome');

expect(startProcessWithFormSpy).toHaveBeenCalledWith(
component.appName,
fakeProcessDefinitions[2].formKey,
fakeProcessDefinitions[2].version,
payload
);
});

it('should call service with the correct parameters when variables are undefined and formCloud is defined', async () => {
getDefinitionsSpy.and.returnValue(of([fakeProcessDefinitions[2]]));
formDefinitionSpy.and.returnValue(of(fakeStartForm));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
filteredProcesses: ProcessDefinitionCloud[] = [];
staticMappings: TaskVariableCloud[] = [];
resolvedValues?: TaskVariableCloud[];
customOutcome: string;

protected onDestroy$ = new Subject<boolean>();

Expand Down Expand Up @@ -366,6 +367,11 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
}
}

onCustomOutcomeClicked(outcome: string) {
this.customOutcome = outcome;
this.startProcess();
}

startProcess() {
this.isProcessStarting = true;

Expand All @@ -378,7 +384,8 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
processName: this.processInstanceName.value,
processDefinitionKey: this.processPayloadCloud.processDefinitionKey,
variables: this.variables ?? {},
values: this.formCloud.values
values: this.formCloud.values,
outcome: this.customOutcome
})
)
: this.startProcessCloudService.startProcess(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ export class ProcessWithFormPayloadCloud {
processDefinitionKey: string;
variables: any;
values: any;
outcome?: string;

constructor(obj: ProcessWithFormPayloadCloud) {
this.processName = obj.processName;
this.processDefinitionKey = obj.processDefinitionKey;
this.variables = obj.variables;
this.values = obj.values;
this.outcome = obj.outcome;
}
}

0 comments on commit 8144006

Please sign in to comment.