mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-22037 Set static value for form variables in start event form (#9676)
This commit is contained in:
@@ -65,6 +65,7 @@ import { ProcessServicesCloudModule } from '../../process-services-cloud.module'
|
|||||||
import { MatButtonHarness } from '@angular/material/button/testing';
|
import { MatButtonHarness } from '@angular/material/button/testing';
|
||||||
import { FormCloudDisplayMode } from '../../services/form-fields.interfaces';
|
import { FormCloudDisplayMode } from '../../services/form-fields.interfaces';
|
||||||
import { CloudFormRenderingService } from './cloud-form-rendering.service';
|
import { CloudFormRenderingService } from './cloud-form-rendering.service';
|
||||||
|
import { TaskVariableCloud } from '../models/task-variable-cloud.model';
|
||||||
|
|
||||||
const mockOauth2Auth: any = {
|
const mockOauth2Auth: any = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
@@ -619,6 +620,28 @@ describe('FormCloudComponent', () => {
|
|||||||
formComponent.loadForm();
|
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', () => {
|
it('should handle error when getting form by definition id', () => {
|
||||||
const error = 'Some error';
|
const error = 'Some error';
|
||||||
|
|
||||||
|
@@ -302,6 +302,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
.subscribe(
|
.subscribe(
|
||||||
(form) => {
|
(form) => {
|
||||||
this.formCloudRepresentationJSON = form;
|
this.formCloudRepresentationJSON = form;
|
||||||
|
this.formCloudRepresentationJSON.processVariables = this.data || [];
|
||||||
const parsedForm = this.parseForm(form);
|
const parsedForm = this.parseForm(form);
|
||||||
this.visibilityService.refreshVisibility(parsedForm);
|
this.visibilityService.refreshVisibility(parsedForm);
|
||||||
parsedForm?.validateForm();
|
parsedForm?.validateForm();
|
||||||
|
Reference in New Issue
Block a user