diff --git a/src/helpers.js b/src/helpers.js index 395d6f0a..0ea3fa38 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -28,6 +28,7 @@ const dynamicInternalJsfAttrs = [ // HOTFIX/TODO Internal customizations, check test conditions.test.js for more info. 'Component', 'calculateDynamicProperties', + 'visibilityCondition', ]; const dynamicInternalJsfAttrsObj = Object.fromEntries( dynamicInternalJsfAttrs.map((k) => [k, true]) diff --git a/src/tests/conditions.test.js b/src/tests/conditions.test.js index 308620d4..3a54c99f 100644 --- a/src/tests/conditions.test.js +++ b/src/tests/conditions.test.js @@ -293,7 +293,7 @@ describe('Conditional attributes updated', () => { expect(fields[1].isVisible).toBe(false); }); - it('Keeps internal attributes (fieldAttrsFromJsf)', () => { + it('Keeps internal attributes (dynamicInternalJsfAttrs)', () => { // This is necessary while we keep supporting "type", even if deprecated // otherwise our Remote app will break because it didn't migrate // from "type" to "inputType" yet. @@ -359,7 +359,7 @@ describe('Conditional attributes updated', () => { }); }); - it('Keeps custom attribute Component (fieldAttrsFromJsf) (hotfix temporary)', () => { + it('Keeps custom attributes (dynamicInternalJsfAttrs) (hotfix temporary)', () => { // This is necessary as hotfix because we (Remote) use it internally. // Not cool, we'll need a better solution asap. const { fields, handleValidation } = createHeadlessForm( @@ -415,5 +415,11 @@ describe('Conditional attributes updated', () => { handleValidation({ is_full_time: 'no' }); expect(fields[1].Component).toBe(''); expect(fields[1].calculateDynamicProperties).toEqual(expect.any(Function)); + + expect(fields[1].visibilityCondition).toEqual(undefined); + // visibilityCondition can be externally changed/updated/added, it stays there too; + fields[1].visibilityCondition = () => false; + handleValidation({ is_full_time: 'no' }); + expect(fields[1].visibilityCondition).toEqual(expect.any(Function)); }); });