Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading