diff --git a/lib/core/form/components/form-renderer.component.spec.ts b/lib/core/form/components/form-renderer.component.spec.ts index d3c6bb7dfa..ec06864ac0 100644 --- a/lib/core/form/components/form-renderer.component.spec.ts +++ b/lib/core/form/components/form-renderer.component.spec.ts @@ -16,18 +16,26 @@ */ import { TestBed, ComponentFixture } from '@angular/core/testing'; +import { setupTestBed } from '../../testing/setup-test-bed'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { FormRendererComponent } from './form-renderer.component'; import { FormBaseModule } from '../form-base.module'; -import { formDisplayValueVisibility, formDisplayValueForm, formDisplayValueCombinedVisibility } from './mock/form-renderer.component.mock'; +import { formDisplayValueVisibility, + formDisplayValueForm, + formDisplayValueCombinedVisibility, + formNumberWidgetVisibility, + formNumberTextJson, + formRequiredNumberWidget, + colspanForm, + numberNotRequiredForm, + numberMinMaxForm } from './mock/form-renderer.component.mock'; import { TranslationService } from 'core/services'; import { TranslationMock } from 'core/mock'; import { TranslateStore } from '@ngx-translate/core'; import { FormService } from '../services/form.service'; -import { setupTestBed } from '../../testing/setup-test-bed'; function typeIntoInput(targetInput: HTMLInputElement, message: string ) { - expect(targetInput).not.toBeNull(); + expect(targetInput).not.toBeNull('Expected input to set to be valid and not null'); targetInput.value = message; targetInput.dispatchEvent(new Event('input')); } @@ -35,19 +43,30 @@ function typeIntoInput(targetInput: HTMLInputElement, message: string ) { function expectElementToBeHidden(targetElement: HTMLElement): void { expect(targetElement).not.toBeNull(); expect(targetElement).toBeDefined(); - expect(targetElement.hidden).toBe(true); + expect(targetElement.hidden).toBe(true, `${targetElement.id} should be hidden but it is not`); } function expectElementToBeVisible(targetElement: HTMLElement): void { expect(targetElement).not.toBeNull(); expect(targetElement).toBeDefined(); - expect(targetElement.hidden).toBe(false); + expect(targetElement.hidden).toBe(false, `${targetElement.id} should be visibile but it is not`); } function expectInputElementValueIs(targetElement: HTMLInputElement, value: string): void { expect(targetElement).not.toBeNull(); expect(targetElement).toBeDefined(); - expect(targetElement.value).toBe(value); + expect(targetElement.value).toBe(value, `invalid value for ${targetElement.name}`); +} + +function expectElementToBeInvalid(fieldId: string, fixture: ComponentFixture): void { + const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`); + expect(invalidElementContainer).not.toBeNull(); + expect(invalidElementContainer).toBeDefined(); +} + +function expectElementToBeValid(fieldId: string, fixture: ComponentFixture): void { + const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`); + expect(invalidElementContainer).toBeNull(); } describe('Form Renderer Component', () => { @@ -73,122 +92,324 @@ describe('Form Renderer Component', () => { formService = TestBed.get(FormService); }); - it('Should be able to see Display value widget when visibility condition refers to another field with specific value', async () => { - formRendererComponent.formDefinition = formService.parseForm(formDisplayValueVisibility.formRepresentation.formDefinition); - fixture.detectChanges(); - await fixture.whenStable(); - - let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - const formInputText: HTMLInputElement = fixture.nativeElement.querySelector('#Text0bq3ar'); - expectElementToBeHidden(displayValueElementContainer); - typeIntoInput(formInputText, 'DisplayValue'); - fixture.detectChanges(); - await fixture.whenStable(); - - displayValueElementContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - expectElementToBeVisible(displayValueElementContainer); - const displayValueElement: HTMLInputElement = fixture.nativeElement.querySelector('#Displayvalue0g6092'); - expectInputElementValueIs(displayValueElement, 'No field selected'); + afterEach(() => { + fixture.destroy(); }); - it('Should be able to see Display value widget when visibility condition refers to a form variable and a field', async () => { - formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm.formRepresentation.formDefinition); - fixture.detectChanges(); - await fixture.whenStable(); - let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueOne-container'); - expectElementToBeHidden(displayValueElementContainer); + describe('Display Value Widget', () => { + it('[C309862] - Should be able to see Display value widget when visibility condition refers to another field with specific value', async () => { + formRendererComponent.formDefinition = formService.parseForm(formDisplayValueVisibility.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); - const formInputText: HTMLInputElement = fixture.nativeElement.querySelector('#Text0howrc'); - typeIntoInput(formInputText, 'aaa'); - fixture.detectChanges(); - await fixture.whenStable(); + let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + const formInputText: HTMLInputElement = fixture.nativeElement.querySelector('#Text0bq3ar'); + expectElementToBeHidden(displayValueElementContainer); + typeIntoInput(formInputText, 'DisplayValue'); + fixture.detectChanges(); + await fixture.whenStable(); - displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueOne-container'); - expectElementToBeVisible(displayValueElementContainer); - const displayValueElement: HTMLInputElement = fixture.nativeElement.querySelector('#DisplayValueOne'); - expectInputElementValueIs(displayValueElement, 'No field selected'); + displayValueElementContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + expectElementToBeVisible(displayValueElementContainer); + const displayValueElement: HTMLInputElement = fixture.nativeElement.querySelector('#Displayvalue0g6092'); + expectInputElementValueIs(displayValueElement, 'No field selected'); + }); - typeIntoInput(formInputText, 'aaab'); - fixture.detectChanges(); - await fixture.whenStable(); - displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueOne-container'); - expectElementToBeHidden(displayValueElementContainer); + it('[C309863] - Should be able to see Display value widget when visibility condition refers to a form variable and a field', async () => { + formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueOne-container'); + expectElementToBeHidden(displayValueElementContainer); + + const formInputText: HTMLInputElement = fixture.nativeElement.querySelector('#Text0howrc'); + typeIntoInput(formInputText, 'aaa'); + fixture.detectChanges(); + await fixture.whenStable(); + + displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueOne-container'); + expectElementToBeVisible(displayValueElementContainer); + const displayValueElement: HTMLInputElement = fixture.nativeElement.querySelector('#DisplayValueOne'); + expectInputElementValueIs(displayValueElement, 'No field selected'); + + typeIntoInput(formInputText, 'aaab'); + fixture.detectChanges(); + await fixture.whenStable(); + displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueOne-container'); + expectElementToBeHidden(displayValueElementContainer); + }); + + it('[C309864] - Should be able to see Display value widget when visibility condition refers to another field and form variable', async () => { + formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container'); + expectElementToBeHidden(displayValueElementContainer); + + const formInputText: HTMLInputElement = fixture.nativeElement.querySelector('#TextOne'); + typeIntoInput(formInputText, 'aaa'); + fixture.detectChanges(); + await fixture.whenStable(); + + displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container'); + expectElementToBeVisible(displayValueElementContainer); + const displayValueElement: HTMLInputElement = fixture.nativeElement.querySelector('#DisplayValueVariableField'); + expectInputElementValueIs(displayValueElement, 'No field selected'); + + typeIntoInput(formInputText, 'aaab'); + fixture.detectChanges(); + await fixture.whenStable(); + displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container'); + expectElementToBeHidden(displayValueElementContainer); + }); + + it('[C309865] - Should be able to see Display value widget when has multiple visibility conditions and next condition operators', async () => { + formRendererComponent.formDefinition = formService.parseForm(formDisplayValueCombinedVisibility.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + const textInputElement: HTMLInputElement = fixture.nativeElement.querySelector('#Text0bq3ar'); + const textTwoInputElement: HTMLInputElement = fixture.nativeElement.querySelector('#TextTwo'); + let displayValueHiddenContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + expectElementToBeVisible(textInputElement); + expectElementToBeVisible(textTwoInputElement); + expectElementToBeHidden(displayValueHiddenContainer); + + typeIntoInput(textInputElement, 'aaa'); + fixture.detectChanges(); + await fixture.whenStable(); + displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + expectInputElementValueIs(textInputElement, 'aaa'); + expectInputElementValueIs(textTwoInputElement, ''); + expectElementToBeVisible(displayValueHiddenContainer); + + typeIntoInput(textInputElement, 'bbb'); + fixture.detectChanges(); + await fixture.whenStable(); + displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + expectInputElementValueIs(textInputElement, 'bbb'); + expectInputElementValueIs(textTwoInputElement, ''); + expectElementToBeHidden(displayValueHiddenContainer); + + typeIntoInput(textTwoInputElement, 'aaa'); + fixture.detectChanges(); + await fixture.whenStable(); + displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + expectInputElementValueIs(textInputElement, 'bbb'); + expectInputElementValueIs(textTwoInputElement, 'aaa'); + expectElementToBeHidden(displayValueHiddenContainer); + + typeIntoInput(textInputElement, 'aaa'); + fixture.detectChanges(); + await fixture.whenStable(); + displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + expectInputElementValueIs(textInputElement, 'aaa'); + expectInputElementValueIs(textTwoInputElement, 'aaa'); + expectElementToBeHidden(displayValueHiddenContainer); + + typeIntoInput(textTwoInputElement, 'bbb'); + fixture.detectChanges(); + await fixture.whenStable(); + displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); + expectInputElementValueIs(textInputElement, 'aaa'); + expectInputElementValueIs(textTwoInputElement, 'bbb'); + expectElementToBeVisible(displayValueHiddenContainer); + }); }); - it('Should be able to see Display value widget when visibility condition refers to another field and form variable', async () => { - formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm.formRepresentation.formDefinition); - fixture.detectChanges(); - await fixture.whenStable(); - let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container'); - expectElementToBeHidden(displayValueElementContainer); + describe('Number widget', () => { - const formInputText: HTMLInputElement = fixture.nativeElement.querySelector('#TextOne'); - typeIntoInput(formInputText, 'aaa'); - fixture.detectChanges(); - await fixture.whenStable(); + it('[C315169] - Should be able to complete a task with a form with number widgets', async () => { + formRendererComponent.formDefinition = formService.parseForm(formNumberWidgetVisibility.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); - displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container'); - expectElementToBeVisible(displayValueElementContainer); - const displayValueElement: HTMLInputElement = fixture.nativeElement.querySelector('#DisplayValueVariableField'); - expectInputElementValueIs(displayValueElement, 'No field selected'); + let inputNumberOne = fixture.nativeElement.querySelector('#Number1'); + let inputNumber2Container = fixture.nativeElement.querySelector('#field-Number2-container'); + expectElementToBeVisible(inputNumberOne); + expectElementToBeHidden(inputNumber2Container); + expect(formRendererComponent.formDefinition.isValid).toBe(true, 'Form should be valid by default'); + + typeIntoInput(inputNumberOne, '5'); + fixture.detectChanges(); + await fixture.whenStable(); + + inputNumberOne = fixture.nativeElement.querySelector('#Number1'); + inputNumber2Container = fixture.nativeElement.querySelector('#field-Number2-container'); + expectElementToBeVisible(inputNumberOne); + expectElementToBeVisible(inputNumber2Container); + expect(formRendererComponent.formDefinition.isValid).toBe(true, 'Form should be valid with a valid value'); + + typeIntoInput(inputNumberOne, 'az'); + fixture.detectChanges(); + await fixture.whenStable(); + + inputNumberOne = fixture.nativeElement.querySelector('#Number1'); + inputNumber2Container = fixture.nativeElement.querySelector('#field-Number2-container'); + expectElementToBeVisible(inputNumberOne); + expectElementToBeHidden(inputNumber2Container); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should be invalid with an invalid value'); + }); + + it('[C309663] - Should be able to see Number widget when visibility condition refers to another field with specific value', async () => { + formRendererComponent.formDefinition = formService.parseForm(formNumberTextJson.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + + const textInput: HTMLInputElement = fixture.nativeElement.querySelector('#Text'); + let numberFieldContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-NumberFieldValue-container'); + expectElementToBeVisible(textInput); + expectElementToBeHidden(numberFieldContainer); + + typeIntoInput(textInput, 'aaa'); + fixture.detectChanges(); + await fixture.whenStable(); + numberFieldContainer = fixture.nativeElement.querySelector('#field-NumberFieldValue-container'); + expectElementToBeVisible(numberFieldContainer); + + typeIntoInput(textInput, 'bbb'); + fixture.detectChanges(); + await fixture.whenStable(); + numberFieldContainer = fixture.nativeElement.querySelector('#field-NumberFieldValue-container'); + expectElementToBeHidden(numberFieldContainer); + }); + + it('[C315170] - Should be able to complete a task with a form with required number widgets', async () => { + formRendererComponent.formDefinition = formService.parseForm(formRequiredNumberWidget.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + + const inputElementNumber: HTMLInputElement = fixture.nativeElement.querySelector('#Number1'); + let numberContainerElement: HTMLDivElement = fixture.nativeElement.querySelector('#field-Number2-container'); + expectElementToBeHidden(numberContainerElement); + expectElementToBeVisible(inputElementNumber); + + typeIntoInput(inputElementNumber, '5'); + fixture.detectChanges(); + await fixture.whenStable(); + numberContainerElement = fixture.nativeElement.querySelector('#field-Number2-container'); + expectElementToBeVisible(numberContainerElement); + + typeIntoInput(inputElementNumber, '123'); + fixture.detectChanges(); + await fixture.whenStable(); + numberContainerElement = fixture.nativeElement.querySelector('#field-Number2-container'); + expectElementToBeHidden(numberContainerElement); + const errorWidetText: HTMLDivElement = fixture.nativeElement.querySelector('#field-Number1-container error-widget .adf-error-text'); + expect(errorWidetText.textContent).toBe(`FORM.FIELD.VALIDATOR.NOT_GREATER_THAN`); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without mandatory field'); + }); + + it('[C309653] - Should disable the save button when Number widget is required', async () => { + formRendererComponent.formDefinition = formService.parseForm(formNumberTextJson.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + const numberRequired: HTMLInputElement = fixture.nativeElement.querySelector('#NumberReq'); + const numberNotRequired: HTMLInputElement = fixture.nativeElement.querySelector('#NumberNotReq'); + expectElementToBeVisible(numberRequired); + expectElementToBeVisible(numberNotRequired); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should be invalid with an empty required value'); + + typeIntoInput(numberNotRequired, '5'); + fixture.detectChanges(); + await fixture.whenStable(); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should be invalid with an empty required value'); + + typeIntoInput(numberRequired, '5'); + typeIntoInput(numberNotRequired, ''); + fixture.detectChanges(); + await fixture.whenStable(); + expect(formRendererComponent.formDefinition.isValid).toBe(true, 'Form should be valid when required field are filled'); + }); + + it('[C309654] - Should display Number widget spans on 2 columns when colspan is set to 2', async () => { + formRendererComponent.formDefinition = formService.parseForm(colspanForm.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + const formSizedElement = fixture.nativeElement.querySelector('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section.adf-grid-list'); + expectElementToBeVisible(formSizedElement); + const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section .adf-grid-list-item'); + sectionGridElement.forEach((element) => { + expect(element.style['width']).toBe('50%', 'Elemens is wrong sized for this section'); + }); + + const fullWidthElement = fixture.nativeElement.querySelector('#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container section.adf-grid-list .adf-grid-list-item'); + expect(fullWidthElement.style['width']).toBe('100%'); + }); + + it('[C309655] - Should display validation error message when Number widget has invalid value', async () => { + formRendererComponent.formDefinition = formService.parseForm(numberNotRequiredForm.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + + const numberInputRequired: HTMLInputElement = fixture.nativeElement.querySelector('#Number0x8cbv'); + expectElementToBeVisible(numberInputRequired); + expectElementToBeInvalid('Number0x8cbv', fixture); + + typeIntoInput(numberInputRequired, '5'); + fixture.detectChanges(); + await fixture.whenStable(); + expectElementToBeValid('Number0x8cbv', fixture); + + typeIntoInput(numberInputRequired, 'a'); + fixture.detectChanges(); + await fixture.whenStable(); + expectElementToBeInvalid('Number0x8cbv', fixture); + let errorWidgetText: HTMLDivElement = fixture.nativeElement.querySelector('#field-Number0x8cbv-container error-widget .adf-error-text'); + expect(errorWidgetText.textContent).toBe(`FORM.FIELD.VALIDATOR.INVALID_NUMBER`); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without mandatory field'); + + typeIntoInput(numberInputRequired, '?'); + fixture.detectChanges(); + await fixture.whenStable(); + expectElementToBeInvalid('Number0x8cbv', fixture); + errorWidgetText = fixture.nativeElement.querySelector('#field-Number0x8cbv-container error-widget .adf-error-text'); + expect(errorWidgetText.textContent).toBe(`FORM.FIELD.VALIDATOR.INVALID_NUMBER`); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without mandatory field'); + + typeIntoInput(numberInputRequired, '-5'); + fixture.detectChanges(); + await fixture.whenStable(); + expectElementToBeValid('Number0x8cbv', fixture); + }); + + it('[C309660] - Should display validation error message when Number widget value is not respecting min max interval', async () => { + formRendererComponent.formDefinition = formService.parseForm(numberMinMaxForm.formRepresentation.formDefinition); + fixture.detectChanges(); + await fixture.whenStable(); + const numberInputElement: HTMLInputElement = fixture.nativeElement.querySelector('#Number0him2z'); + expectElementToBeVisible(numberInputElement); + expectElementToBeValid('Number0him2z', fixture); + + typeIntoInput(numberInputElement, '9'); + fixture.detectChanges(); + await fixture.whenStable(); + + expectElementToBeInvalid('Number0him2z', fixture); + let errorWidgetText = fixture.nativeElement.querySelector('#field-Number0him2z-container error-widget .adf-error-text'); + expect(errorWidgetText.textContent).toBe(`FORM.FIELD.VALIDATOR.NOT_LESS_THAN`); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without valid field'); + + typeIntoInput(numberInputElement, '10'); + fixture.detectChanges(); + await fixture.whenStable(); + + expectElementToBeValid('Number0him2z', fixture); + + typeIntoInput(numberInputElement, '60'); + fixture.detectChanges(); + await fixture.whenStable(); + + expectElementToBeValid('Number0him2z', fixture); + + typeIntoInput(numberInputElement, '61'); + fixture.detectChanges(); + await fixture.whenStable(); + + expectElementToBeInvalid('Number0him2z', fixture); + errorWidgetText = fixture.nativeElement.querySelector('#field-Number0him2z-container error-widget .adf-error-text'); + expect(errorWidgetText.textContent).toBe(`FORM.FIELD.VALIDATOR.NOT_GREATER_THAN`); + expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without valid field'); + }); - typeIntoInput(formInputText, 'aaab'); - fixture.detectChanges(); - await fixture.whenStable(); - displayValueElementContainer = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container'); - expectElementToBeHidden(displayValueElementContainer); }); - - it('Should be able to see Display value widget when has multiple visibility conditions and next condition operators', async () => { - formRendererComponent.formDefinition = formService.parseForm(formDisplayValueCombinedVisibility.formRepresentation.formDefinition); - fixture.detectChanges(); - await fixture.whenStable(); - const textInputElement: HTMLInputElement = fixture.nativeElement.querySelector('#Text0bq3ar'); - const textTwoInputElement: HTMLInputElement = fixture.nativeElement.querySelector('#TextTwo'); - let displayValueHiddenContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - expectElementToBeVisible(textInputElement); - expectElementToBeVisible(textTwoInputElement); - expectElementToBeHidden(displayValueHiddenContainer); - - typeIntoInput(textInputElement, 'aaa'); - fixture.detectChanges(); - await fixture.whenStable(); - displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - expectInputElementValueIs(textInputElement, 'aaa'); - expectInputElementValueIs(textTwoInputElement, ''); - expectElementToBeVisible(displayValueHiddenContainer); - - typeIntoInput(textInputElement, 'bbb'); - fixture.detectChanges(); - await fixture.whenStable(); - displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - expectInputElementValueIs(textInputElement, 'bbb'); - expectInputElementValueIs(textTwoInputElement, ''); - expectElementToBeHidden(displayValueHiddenContainer); - - typeIntoInput(textTwoInputElement, 'aaa'); - fixture.detectChanges(); - await fixture.whenStable(); - displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - expectInputElementValueIs(textInputElement, 'bbb'); - expectInputElementValueIs(textTwoInputElement, 'aaa'); - expectElementToBeHidden(displayValueHiddenContainer); - - typeIntoInput(textInputElement, 'aaa'); - fixture.detectChanges(); - await fixture.whenStable(); - displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - expectInputElementValueIs(textInputElement, 'aaa'); - expectInputElementValueIs(textTwoInputElement, 'aaa'); - expectElementToBeHidden(displayValueHiddenContainer); - - typeIntoInput(textTwoInputElement, 'bbb'); - fixture.detectChanges(); - await fixture.whenStable(); - displayValueHiddenContainer = fixture.nativeElement.querySelector('#field-Displayvalue0g6092-container'); - expectInputElementValueIs(textInputElement, 'aaa'); - expectInputElementValueIs(textTwoInputElement, 'bbb'); - expectElementToBeVisible(displayValueHiddenContainer); - }); - }); diff --git a/lib/core/form/components/mock/form-renderer.component.mock.ts b/lib/core/form/components/mock/form-renderer.component.mock.ts index e4c4e1ed25..f6642501e8 100644 --- a/lib/core/form/components/mock/form-renderer.component.mock.ts +++ b/lib/core/form/components/mock/form-renderer.component.mock.ts @@ -17,288 +17,293 @@ export const formDisplayValueVisibility = { formRepresentation: { - id: 'form-3175b074-53c6-4b5b-92df-246b62108db3', - name: 'displayValueVisibility', - description: '', - version: 0, - standAlone: true, - formDefinition: { - tabs: [], - fields: [ - { - id: '65ba00e6-a669-4710-9a97-0a6e19b429d8', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'Text0bq3ar', - name: 'Text', - type: 'text', - required: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - visibilityCondition: null, - params: { existingColspan: 1, maxColspan: 2 } - } - ], - '2': [ - { - id: 'Displayvalue0g6092', - name: 'Display value', - type: 'readonly', - value: 'No field selected', - colspan: 1, - visibilityCondition: { - leftType: 'field', - leftValue: 'Text0bq3ar', - operator: '==', - rightValue: 'DisplayValue', - rightType: 'value', - nextConditionOperator: '', - nextCondition: null - }, - params: { - existingColspan: 1, - maxColspan: 2, - field: { - id: 'Displayvalue0g6092', - name: 'Display value', - type: 'text' - }, - responseVariable: true - } - } - ] - } - } - ], - outcomes: [], - metadata: {}, - variables: [] - } - }}; + id: 'form-3175b074-53c6-4b5b-92df-246b62108db3', + name: 'displayValueVisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [], + fields: [ + { + id: '65ba00e6-a669-4710-9a97-0a6e19b429d8', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Text0bq3ar', + name: 'Text', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { existingColspan: 1, maxColspan: 2 } + } + ], + '2': [ + { + id: 'Displayvalue0g6092', + name: 'Display value', + type: 'readonly', + value: 'No field selected', + colspan: 1, + visibilityCondition: { + leftType: 'field', + leftValue: 'Text0bq3ar', + operator: '==', + rightValue: 'DisplayValue', + rightType: 'value', + nextConditionOperator: '', + nextCondition: null + }, + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'Displayvalue0g6092', + name: 'Display value', + type: 'text' + }, + responseVariable: true + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; -export const formDisplayValueForm = { formRepresentation : { +export const formDisplayValueForm = { + formRepresentation: { id: 'form-3dd0f2a3-c20a-4195-a760-1db42ec7dcd4', name: 'displayValue', description: '', version: 0, formDefinition: { - 'tabs': [], - 'fields': [ + tabs: [], + fields: [ { - 'id': 'c54f6956-bcf9-4109-a6c1-1daff773936b', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { + id: 'c54f6956-bcf9-4109-a6c1-1daff773936b', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { '1': [ { - 'id': 'DisplayValueColspan', - 'name': 'DisplayValueColspan', - 'type': 'readonly', - 'value': 'No field selected', - 'colspan': 2, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'Displayvalue0hwgvb', - 'name': 'Display value', - 'type': 'text' + id: 'DisplayValueColspan', + name: 'DisplayValueColspan', + type: 'readonly', + value: 'No field selected', + colspan: 2, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'Displayvalue0hwgvb', + name: 'Display value', + type: 'text' } } }, { - 'id': 'DisplayValueFieldValue', - 'name': 'DisplayValueFieldValue', - 'type': 'readonly', - 'value': 'No field selected', - 'colspan': 1, - 'visibilityCondition': { - 'leftFormFieldId': 'TextOne', - 'leftRestResponseId': '', - 'operator': '==', - 'rightValue': 'aaa', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'DisplayValueFieldValue', + name: 'DisplayValueFieldValue', + type: 'readonly', + value: 'No field selected', + colspan: 1, + visibilityCondition: { + leftFormFieldId: 'TextOne', + leftRestResponseId: '', + operator: '==', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null }, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'Displayvalue0pjsfi', - 'name': 'Display value', - 'type': 'text' + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'Displayvalue0pjsfi', + name: 'Display value', + type: 'text' } } }, { - 'id': 'DisplayValueVariableField', - 'name': 'DisplayValueVariableField', - 'type': 'readonly', - 'value': 'No field selected', - 'colspan': 1, - 'visibilityCondition': { - 'leftFormFieldId': '', - 'leftRestResponseId': 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', - 'operator': '==', - 'rightValue': '', - 'rightType': null, - 'rightFormFieldId': 'TextOne', - 'rightRestResponseId': '', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'DisplayValueVariableField', + name: 'DisplayValueVariableField', + type: 'readonly', + value: 'No field selected', + colspan: 1, + visibilityCondition: { + leftFormFieldId: '', + leftRestResponseId: + 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', + operator: '==', + rightValue: '', + rightType: null, + rightFormFieldId: 'TextOne', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null }, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'Displayvalue0sss8o', - 'name': 'Display value', - 'type': 'text' + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'Displayvalue0sss8o', + name: 'Display value', + type: 'text' } } }, { - 'id': 'DisplayValueFieldVariable', - 'name': 'DisplayValueFieldVariable', - 'type': 'readonly', - 'value': 'No field selected', - 'colspan': 1, - 'visibilityCondition': { - 'leftFormFieldId': 'TextOne', - 'leftRestResponseId': '', - 'operator': '==', - 'rightValue': '', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'DisplayValueFieldVariable', + name: 'DisplayValueFieldVariable', + type: 'readonly', + value: 'No field selected', + colspan: 1, + visibilityCondition: { + leftFormFieldId: 'TextOne', + leftRestResponseId: '', + operator: '==', + rightValue: '', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: + 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', + nextConditionOperator: '', + nextCondition: null }, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'Displayvalue0mkrml', - 'name': 'Display value', - 'type': 'text' + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'Displayvalue0mkrml', + name: 'Display value', + type: 'text' } } }, { - 'id': 'DisplayValueOne', - 'name': 'DisplayValueOne', - 'type': 'readonly', - 'value': 'No field selected', - 'colspan': 1, - 'visibilityCondition': { - 'leftFormFieldId': 'Text0howrc', - 'leftRestResponseId': '', - 'operator': '==', - 'rightValue': 'aaa', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftFormFieldId': 'TextTwo', - 'leftRestResponseId': '', - 'operator': '!=', - 'rightValue': 'aaa', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'DisplayValueOne', + name: 'DisplayValueOne', + type: 'readonly', + value: 'No field selected', + colspan: 1, + visibilityCondition: { + leftFormFieldId: 'Text0howrc', + leftRestResponseId: '', + operator: '==', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'and', + nextCondition: { + leftFormFieldId: 'TextTwo', + leftRestResponseId: '', + operator: '!=', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null } }, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'Displayvalue00ldqe', - 'name': 'Display value', - 'type': 'text' + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'Displayvalue00ldqe', + name: 'Display value', + type: 'text' } } } ], '2': [ { - 'id': 'Text0howrc', - 'name': 'Text', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text0howrc', + name: 'Text', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } }, { - 'id': 'TextOne', - 'name': 'TextOne', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'TextOne', + name: 'TextOne', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } }, { - 'id': 'TextTwo', - 'name': 'TextTwo', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'TextTwo', + name: 'TextTwo', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } }, { - 'id': 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', - 'name': 'vstring', - 'type': 'readonly', - 'value': 'Show value of vstring', - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', - 'name': 'vstring', - 'type': 'string' + id: 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', + name: 'vstring', + type: 'readonly', + value: 'Show value of vstring', + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: + 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', + name: 'vstring', + type: 'string' } } } @@ -306,118 +311,718 @@ export const formDisplayValueForm = { formRepresentation : { } } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [ + outcomes: [], + metadata: {}, + variables: [ { - 'id': 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', - 'name': 'vstring', - 'type': 'string', - 'value': 'aaa' + id: 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b', + name: 'vstring', + type: 'string', + value: 'aaa' } ] } - }}; + } +}; export const formDisplayValueCombinedVisibility = { - formRepresentation: { - id: 'form-3175b074-53c6-4b5b-92df-246b62108db3', - name: 'displayValueVisibility', - description: '', - version: 0, - standAlone: true, - formDefinition: { - tabs: [], - fields: [ - { - id: '65ba00e6-a669-4710-9a97-0a6e19b429d8', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'Text0bq3ar', - name: 'Text', - type: 'text', - required: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - visibilityCondition: null, - params: { existingColspan: 1, maxColspan: 2 } - } - ], - '2': [ - { - id: 'Displayvalue0g6092', - name: 'Display value', - type: 'readonly', - value: 'No field selected', - colspan: 1, - visibilityCondition: { - leftType: 'field', - leftValue: 'Text0bq3ar', - operator: '==', - rightValue: 'aaa', - rightType: 'value', - nextConditionOperator: 'and', - nextCondition: { - leftType: 'field', - leftValue: 'TextTwo', - operator: '!=', - rightValue: 'aaa', - rightType: 'value', - nextConditionOperator: '', - nextCondition: null - } - }, - params: { - existingColspan: 1, - maxColspan: 2, - field: { - id: 'Displayvalue0g6092', - name: 'Display value', - type: 'text' - }, - responseVariable: true - } - } - ] - } - }, - { - id: 'b2162507-2204-4fda-a8cb-003dd5d032ef', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'TextTwo', - name: 'TextTwo', - type: 'text', - required: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - visibilityCondition: null, - params: { existingColspan: 1, maxColspan: 2 } - } - ], - '2': [] - } - } - ], - outcomes: [], - metadata: {}, - variables: [] - } - } - }; + formRepresentation: { + id: 'form-3175b074-53c6-4b5b-92df-246b62108db3', + name: 'displayValueVisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [], + fields: [ + { + id: '65ba00e6-a669-4710-9a97-0a6e19b429d8', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Text0bq3ar', + name: 'Text', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { existingColspan: 1, maxColspan: 2 } + } + ], + '2': [ + { + id: 'Displayvalue0g6092', + name: 'Display value', + type: 'readonly', + value: 'No field selected', + colspan: 1, + visibilityCondition: { + leftType: 'field', + leftValue: 'Text0bq3ar', + operator: '==', + rightValue: 'aaa', + rightType: 'value', + nextConditionOperator: 'and', + nextCondition: { + leftType: 'field', + leftValue: 'TextTwo', + operator: '!=', + rightValue: 'aaa', + rightType: 'value', + nextConditionOperator: '', + nextCondition: null + } + }, + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'Displayvalue0g6092', + name: 'Display value', + type: 'text' + }, + responseVariable: true + } + } + ] + } + }, + { + id: 'b2162507-2204-4fda-a8cb-003dd5d032ef', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'TextTwo', + name: 'TextTwo', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { existingColspan: 1, maxColspan: 2 } + } + ], + '2': [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; + +export const formNumberWidgetVisibility = { + formRepresentation: { + id: 'form-00dc42c7-b075-404b-a57c-a8b2adca9abe', + name: 'number_field', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [], + fields: [ + { + id: '182eef06-d245-4388-b3f7-8e08d90fb07a', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Number1', + name: 'Number1', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ], + '2': [ + { + id: 'Number2', + name: 'Number2', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: { + leftType: 'field', + leftValue: 'Number1', + operator: '==', + rightValue: 'integerVariable', + rightType: 'variable', + nextConditionOperator: '', + nextCondition: null + }, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [ + { + id: 'f9f6d1ae-374a-49f9-b664-5286c558abaa', + name: 'integerVariable', + type: 'integer', + value: 5 + } + ] + } + } +}; + +export const formNumberTextJson = { + formRepresentation: { + id: 'form-ed98955c-3e18-4689-a669-377ab801ad0e', + name: 'number', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ + { + id: 'fa0df048-3d73-4922-8b62-71a204b086b2', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'NumberColspan', + name: 'NumberColspan', + type: 'integer', + colspan: 2, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'NumberReq', + name: 'NumberReq', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: true, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'NumberNotReq', + name: 'NumberNotReq', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'NumberAdvanced', + name: 'NumberAdvanced', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: 10, + maxValue: 50, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ], + '2': [ + { + id: 'Text', + name: 'Text', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'TextTwo', + name: 'TextTwo', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'NumberFieldValue', + name: 'NumberFieldValue', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: { + leftFormFieldId: 'Text', + leftRestResponseId: '', + operator: '==', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null + }, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'NumberVariableField', + name: 'NumberVariableField', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: { + leftFormFieldId: '', + leftRestResponseId: + '3b316e21-3632-4dde-ba19-b27dca09a83b', + operator: '==', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null + }, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'NumberFieldVariable', + name: 'NumberFieldVariable', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: { + leftFormFieldId: 'Text', + leftRestResponseId: '', + operator: '==', + rightValue: '', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: + '3b316e21-3632-4dde-ba19-b27dca09a83b', + nextConditionOperator: '', + nextCondition: null + }, + params: { + existingColspan: 1, + maxColspan: 2 + } + }, + { + id: 'NumberOne', + name: 'NumberOne', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: { + leftFormFieldId: 'Text', + leftRestResponseId: '', + operator: '==', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'and', + nextCondition: { + leftFormFieldId: 'TextTwo', + leftRestResponseId: '', + operator: 'not equal', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null + } + }, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [ + { + id: '3b316e21-3632-4dde-ba19-b27dca09a83b', + name: 'name', + type: 'string', + value: 'aaa' + } + ] + } + } + +}; + +export const formRequiredNumberWidget = { + formRepresentation: { + id: 'form-00dc42c7-b075-404b-a57c-a8b2adca9abe', + name: 'number_field', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [], + fields: [ + { + id: '182eef06-d245-4388-b3f7-8e08d90fb07a', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Number1', + name: 'Number1', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: 5, + maxValue: 7, + required: true, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ], + '2': [ + { + id: 'Number2', + name: 'Number2', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: { + leftType: 'field', + leftValue: 'Number1', + operator: '==', + rightValue: 'integerVariable', + rightType: 'variable', + nextConditionOperator: '', + nextCondition: null + }, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [ + { + id: 'f9f6d1ae-374a-49f9-b664-5286c558abaa', + name: 'integerVariable', + type: 'integer', + value: 5 + } + ] + } + } +}; + +export const colspanForm = { + formRepresentation: { + id: 'form-a6af80b9-d200-4a00-b17a-b1309691493d', + name: 'regresion', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [], + fields: [ + { + id: 'd52ada4e-cbdc-4f0c-a480-5b85fa00e4f8', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Number0u0kiv', + name: 'NumberColspan', + type: 'integer', + readOnly: false, + colspan: 2, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + }, + { + id: '2bc275fb-e113-4d7d-885f-6e74a7332d40', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Number00fuuk', + name: 'Number', + type: 'integer', + readOnly: false, + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ], + '2': [ + { + id: 'Number03u9d4', + name: 'Number', + type: 'integer', + readOnly: false, + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + }, + { + id: '1ff21afc-7df4-4607-8363-1dc8576e1c8e', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Text04sjhr', + name: 'Text', + type: 'text', + readOnly: false, + required: false, + colspan: 2, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; + +export const numberNotRequiredForm = { + formRepresentation: { + id: 'form-d4c462db-3838-442e-a006-171e6ccafe61', + name: 'number-not-required', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [], + fields: [ + { + id: '159d0d89-555c-40db-9e69-6c75692061c1', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Number0x8cbv', + name: 'Number', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: true, + visibilityCondition: null, + params: { existingColspan: 1, maxColspan: 2 } + } + ], + '2': [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; + +export const numberMinMaxForm = { + formRepresentation: { + id: 'form-f1e1a17c-d4a2-40dc-b15a-6a9c08afb26f', + name: 'numbercol', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [], + fields: [ + { + id: '530d73c8-9600-4d11-a1b7-20ad6b60a31a', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + '1': [ + { + id: 'Number0him2z', + name: 'Number', + type: 'integer', + colspan: 2, + placeholder: null, + minValue: 10, + maxValue: 60, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ], + '2': [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +};