mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4787] Invalid value of number field is parsed and fields with visibility conditions based on the number field are visible (#5255)
* add another field visibility condition * * Fixed failing unit tests
This commit is contained in:
committed by
Eugenio Romano
parent
173a160ee9
commit
7ca2f5d1e9
@@ -270,6 +270,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
service.getTaskProcessVariable('9999').subscribe(
|
||||
() => {
|
||||
visibilityObjTest.rightValue = 'test_value_2';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).not.toBeNull();
|
||||
@@ -389,14 +390,16 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
});
|
||||
|
||||
it('should be able to retrieve a field value searching in the form', () => {
|
||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||
const formField = service.getFormFieldById(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||
const formValue = service.searchValueInForm(formField, 'FIELD_WITH_CONDITION');
|
||||
|
||||
expect(formValue).not.toBeNull();
|
||||
expect(formValue).toBe('field_with_condition_value');
|
||||
});
|
||||
|
||||
it('should return empty string if the field value is not in the form', () => {
|
||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_MYSTERY');
|
||||
const formField = service.getFormFieldById(stubFormWithFields, 'FIELD_MYSTERY');
|
||||
const formValue = service.searchValueInForm(formField, 'FIELD_MYSTERY');
|
||||
|
||||
expect(formValue).not.toBeUndefined();
|
||||
expect(formValue).toEqual('');
|
||||
@@ -409,15 +412,14 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
expect(value).toBe('field_with_condition_value');
|
||||
});
|
||||
|
||||
it('should return empty string if the element is not present anywhere', () => {
|
||||
it('should return undefined if the element is not present anywhere', () => {
|
||||
const formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
||||
|
||||
expect(formValue).not.toBeUndefined();
|
||||
expect(formValue).toEqual('');
|
||||
expect(formValue).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should retrieve the value for the right field when it is a value', () => {
|
||||
visibilityObjTest.rightValue = '100';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBe('100');
|
||||
@@ -425,6 +427,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
|
||||
it('should return formatted date when right value is a date', () => {
|
||||
visibilityObjTest.rightValue = '9999-12-31';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBe('9999-12-31T00:00:00.000Z');
|
||||
@@ -432,6 +435,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
|
||||
it('should return the value when right value is not a date', () => {
|
||||
visibilityObjTest.rightValue = '9999-99-99';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBe('9999-99-99');
|
||||
@@ -447,6 +451,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
});
|
||||
|
||||
it('should take the value from form values if it is present', () => {
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const formValue = service.getFormValue(formTest, 'test_1');
|
||||
|
||||
expect(formValue).not.toBeNull();
|
||||
@@ -456,6 +461,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
it('should retrieve right value from form values if it is present', () => {
|
||||
visibilityObjTest.rightType = WidgetTypeEnum.field;
|
||||
visibilityObjTest.rightValue = 'test_2';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).not.toBeNull();
|
||||
@@ -475,6 +481,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
it('should retrieve left value from form values if it is present', () => {
|
||||
visibilityObjTest.leftType = WidgetTypeEnum.field;
|
||||
visibilityObjTest.leftValue = 'test_2';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const leftValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(leftValue).not.toBeNull();
|
||||
@@ -492,6 +499,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightType = WidgetTypeEnum.field;
|
||||
visibilityObjTest.rightValue = 'test_3';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
@@ -502,6 +510,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
visibilityObjTest.leftValue = 'test_1';
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightValue = 'value_1';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
@@ -592,6 +601,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
});
|
||||
|
||||
it('should get the dropdown id value from a form', () => {
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const dropdownValue = service.getFormValue(formTest, 'dropdown');
|
||||
|
||||
expect(dropdownValue).not.toBeNull();
|
||||
@@ -602,6 +612,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
it('should retrieve the value for the right field when it is a dropdown id', () => {
|
||||
visibilityObjTest.rightType = 'field';
|
||||
visibilityObjTest.rightValue = 'dropdown';
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBeDefined();
|
||||
@@ -621,6 +632,7 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
});
|
||||
|
||||
it('should be able to get value from form values', () => {
|
||||
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||
const res = service.getFormValue(formTest, 'test_1');
|
||||
|
||||
expect(res).not.toBeNull();
|
||||
|
Reference in New Issue
Block a user