From c5710c0e6143ca817fefc65d02190424b669411d Mon Sep 17 00:00:00 2001 From: Kasia Biernat <1268696+kathrine0@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:35:15 +0100 Subject: [PATCH] [AAE-12134] unit test: Should be able to set number of columns for Header widget (#8267) --- .../components/form-cloud.component.spec.ts | 23 ++++- .../src/lib/form/mocks/cloud-form.mock.ts | 84 +++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts index 170f559377..88d87a0028 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts @@ -47,7 +47,8 @@ import { cloudFormMock, conditionalUploadWidgetsMock, emptyFormRepresentationJSON, - fakeCloudForm, fakeMetadataForm, multilingualForm + fakeCloudForm, fakeMetadataForm, multilingualForm, + formDefinitionThreeColumnMock } from '../mocks/cloud-form.mock'; import { FormCloudRepresentation } from '../models/form-cloud-representation.model'; import { FormCloudService } from '../services/form-cloud.service'; @@ -1056,6 +1057,26 @@ describe('FormCloudComponent', () => { }); }); + it('should render header and three text field columns', () => { + const formModel = formCloudService.parseForm(formDefinitionThreeColumnMock); + formComponent.form = formModel; + fixture.detectChanges(); + + const columns = fixture.debugElement.queryAll(By.css('.adf-grid-list-single-column')); + + expect(columns.length).toEqual(3); + columns.forEach(column => expect(column.styles.width).toEqual('33.3333%')); + columns.forEach(column => { + const input = column.query(By.css('input[matinput]')); + expect(input.attributes.type).toEqual('text'); + }); + + const header = fixture.debugElement.query(By.css('#container-header')); + expect(header.nativeElement.innerText).toEqual('Header'); + + expect(formComponent.showTitle).toBeTruthy(); + }); + describe('form validations', () => { it('should be able to set visibility conditions for Attach File widget', async () => { spyOn(formCloudService, 'getForm').and.returnValue(of(conditionalUploadWidgetsMock)); diff --git a/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts index 4c2525efed..19af70c96e 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts @@ -741,6 +741,90 @@ export const fakeCloudForm = { } }; +export const formDefinitionThreeColumnMock = { + formRepresentation: { + id: 'form-358ea9b1-7a14-4066-8313-bd84f14e1dbb', + name: 'HeaderColumns', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ + { + id: 'Header', + name: 'Header', + type: 'group', + tab: null, + params: { + allowCollapse: false, + collapseByDefault: false + }, + numberOfColumns: 3, + fields: { + 1: [ + { + 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 + } + } + ], + 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 + } + } + ], + 3: [ + { + 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 + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; + export const emptyFormRepresentationJSON = { description: '', fields: [],