Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-8769 added check for the simpleConditional properties state #136

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/utils/__tests__/formUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
findComponents,
getComponent,
flattenComponents,
getComponentActualValue
getComponentActualValue,
hasCondition
} from "../formUtil";
import { fastCloneDeep } from 'utils/fastCloneDeep';

Expand Down Expand Up @@ -1795,4 +1796,22 @@ describe('getComponentActualValue', () => {
expect(value).to.equal('yes');
});
});

describe('hasCondition', () => {
it('Should return false if conditions is saved in invalid state', () => {
const component = {
label: 'Text Field',
hidden: true,
key: 'textField',
conditional: {
conjunction: 'all'
},
type: 'textfield',
input: true
}

const result = hasCondition(component as Component);
expect(result).to.equal(false);
})
})

5 changes: 3 additions & 2 deletions src/utils/formUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
isPlainObject,
isArray,
isEqual,
trim
trim,
isBoolean
} from "lodash";
import { compare, applyPatch } from 'fast-json-patch';
import {
Expand Down Expand Up @@ -745,7 +746,7 @@ export function hasCondition(component: Component) {
(component.conditional && (
(component.conditional as LegacyConditional).when ||
(component.conditional as JSONConditional).json ||
(component.conditional as SimpleConditional).conjunction
((component.conditional as SimpleConditional).conjunction && isBoolean((component.conditional as SimpleConditional).show) && !isEmpty((component.conditional as SimpleConditional).conditions))
))
);
}
Expand Down
Loading