Skip to content

Commit

Permalink
AAE-22037 Set static value for form variables in start event form (#9676
Browse files Browse the repository at this point in the history
)
  • Loading branch information
pmartinezga authored May 14, 2024
1 parent 4025eb5 commit 9e73127
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { ProcessServicesCloudModule } from '../../process-services-cloud.module'
import { MatButtonHarness } from '@angular/material/button/testing';
import { FormCloudDisplayMode } from '../../services/form-fields.interfaces';
import { CloudFormRenderingService } from './cloud-form-rendering.service';
import { TaskVariableCloud } from '../models/task-variable-cloud.model';

const mockOauth2Auth: any = {
oauth2Auth: {
Expand Down Expand Up @@ -619,6 +620,28 @@ describe('FormCloudComponent', () => {
formComponent.loadForm();
});

it('should fetch and parse form definition by id and also set the process variables when data is provided and no process variables are present', (done) => {
spyOn(formCloudService, 'getForm').and.returnValue(of(fakeCloudForm));

const appName = 'test-app';
const formId = 'form-de8895be-d0d7-4434-beef-559b15305d72';
const variables: TaskVariableCloud[] = [
new TaskVariableCloud({ name: 'var1', value: 'value1' }),
new TaskVariableCloud({ name: 'var2', value: 'value2' })
];
formComponent.formLoaded.subscribe(() => {
expect(formComponent.form).toBeDefined();
expect(formComponent.form.id).toBe(formId);
expect(formComponent.form.processVariables).toEqual(variables as any);
done();
});

formComponent.appName = appName;
formComponent.formId = formId;
formComponent.data = variables;
formComponent.loadForm();
});

it('should handle error when getting form by definition id', () => {
const error = 'Some error';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
.subscribe(
(form) => {
this.formCloudRepresentationJSON = form;
this.formCloudRepresentationJSON.processVariables = this.data || [];
const parsedForm = this.parseForm(form);
this.visibilityService.refreshVisibility(parsedForm);
parsedForm?.validateForm();
Expand Down

0 comments on commit 9e73127

Please sign in to comment.