Skip to content

Commit

Permalink
[AAE-12134] unit test: Should be able to set number of columns for He…
Browse files Browse the repository at this point in the history
…ader widget (#8267)
  • Loading branch information
kathrine0 authored Feb 15, 2023
1 parent 54bb8e2 commit c5710c0
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
Expand Down
84 changes: 84 additions & 0 deletions lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down

0 comments on commit c5710c0

Please sign in to comment.