AAE-22037 Set static value for form variables in start event form (#9676)

This commit is contained in:
Pablo Martinez
2024-05-14 10:25:19 +02:00
committed by GitHub
parent 4025eb5b0e
commit 9e7312719c
2 changed files with 24 additions and 0 deletions

View File

@@ -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: {
@@ -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';

View File

@@ -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();