mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4758] - reset form value when field is not visible (#4958)
* [ADF-4758] - reset form value when field is not visible * [ADF-4758] - fix unit test * [ADF-4758] - fix unit tests
This commit is contained in:
committed by
Eugenio Romano
parent
6ca04ee929
commit
5772c1482e
@@ -344,7 +344,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
|
||||
describe('should return the value of the field', () => {
|
||||
let visibilityObjTest: WidgetVisibilityModel;
|
||||
const fakeFormWithField = new FormModel(fakeFormJson);
|
||||
let fakeFormWithField = new FormModel(fakeFormJson);
|
||||
const jsonFieldFake = {
|
||||
id: 'FAKE_FORM_FIELD_ID',
|
||||
value: 'FAKE_FORM_FIELD_VALUE',
|
||||
@@ -362,6 +362,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
beforeEach(() => {
|
||||
visibilityObjTest = new WidgetVisibilityModel({});
|
||||
formTest.values = formValues;
|
||||
fakeFormWithField = new FormModel(fakeFormJson);
|
||||
jsonFieldFake.visibilityCondition = visibilityObjTest;
|
||||
});
|
||||
|
||||
@@ -509,6 +510,18 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
expect(fakeFormField.isVisible).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should reset value when the field is not visibile', () => {
|
||||
visibilityObjTest.leftValue = 'test_1';
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightType = WidgetTypeEnum.field;
|
||||
visibilityObjTest.rightValue = 'test_3';
|
||||
const fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||
|
||||
service.refreshEntityVisibility(fakeFormField);
|
||||
expect(fakeFormField.isVisible).toBeFalsy();
|
||||
expect(fakeFormField.value).toEqual(null);
|
||||
});
|
||||
|
||||
it('should return true when the visibility condition is not valid', () => {
|
||||
visibilityObjTest = new WidgetVisibilityModel();
|
||||
visibilityObjTest.leftType = '';
|
||||
@@ -979,6 +992,5 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user