Skip to content

Commit

Permalink
Merge branch 'master' into FIO-8414/5x_validation_on_required_datagrid
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekotikov committed Aug 22, 2024
2 parents 7fd5d91 + d596125 commit 53893ff
Show file tree
Hide file tree
Showing 15 changed files with 356 additions and 120 deletions.
14 changes: 14 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
## [Unreleased: 2.3.0-rc.2]
### Changed
- Regression | Nested Form | Components in Nested forms should not validate hidden components without Validate When Hidden = true
- FIO-8807: fixed an issue where conditionals based on selectBoxes component do not work
- FIO-8778: add case for map component model type in filter; add tests
- FIO-8347: Added ability to skip mask validation
- FIO-8731: Update fix to nested hidden components
- FIO-8731: Fixes component gets validated when being in a hidden parent
- FIO-8273 fixed advanced logic for data components
- FIO-8730: Fix submission has hidden fields when 'Clear value when hidden' is checked
- FIO-8626: Updated conditionally hidden logic
- FIO-7733: update most form params to optional
- fixing child components being displayed when they should be removed when clearOnHide is set
- FIO-8639 fixed validation for select component if onlyAvailableItems is set to false
- FIO-8645: added tests and translations for validateRequiredDay
- FIO-8537: Fixing the filter processor to handle nested component data properly
- FIO-8597: fixed an issue with an empty array value for a number component with multiple values enabled

## 2.3.0-rc.1
### Changed
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
"@types/json-logic-js": "^2.0.7",
"browser-cookies": "^1.2.0",
"core-js": "^3.37.1",
"dayjs": "^1.11.11",
"dompurify": "^3.1.4",
"dayjs": "^1.11.12",
"dompurify": "^3.1.6",
"eventemitter3": "^5.0.0",
"fast-json-patch": "^3.1.1",
"fetch-ponyfill": "^7.1.0",
"inputmask": "5.0.8",
"json-logic-js": "^2.0.2",
"inputmask": "5.0.9",
"json-logic-js": "^2.0.5",
"lodash": "^4.17.21",
"moment": "^2.29.4"
},
Expand Down
4 changes: 2 additions & 2 deletions src/process/__tests__/fixtures/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get } from 'lodash';
import { ProcessorContext, ProcessorScope, Component } from 'types';
export const generateProcessorContext = (component: Component, data: any): ProcessorContext<ProcessorScope> => {
import { ProcessorContext, Component } from 'types';
export const generateProcessorContext = <ProcessorScope>(component: Component, data: any): ProcessorContext<ProcessorScope> => {
return {
component,
path: component.key,
Expand Down
52 changes: 52 additions & 0 deletions src/process/__tests__/process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2780,6 +2780,57 @@ describe('Process Tests', () => {
});
});

it('Should not filter a simple datamap compoennt', async () => {
const form = {
display: 'form',
components: [
{
label: "Data Map",
tableView: false,
validateWhenHidden: false,
key: "dataMap",
type: "datamap",
path: "dataMap",
input: true,
valueComponent: {
type: "textfield",
key: "value",
label: "Value",
input: true,
hideLabel: true,
tableView: true,
},
}
]
};
const submission = {
data: {
dataMap: {
key1: "value1",
key2: "value2"
}
}
};
const context = {
form,
submission,
data: submission.data,
components: form.components,
processors: ProcessTargets.evaluator,
scope: {},
config: {
server: true,
},
};
processSync(context);
expect(context.data).to.deep.equal({
dataMap: {
key1: "value1",
key2: "value2"
}
});
})

describe('Required component validation in nested form in DataGrid/EditGrid', () => {
const nestedForm = {
key: 'form',
Expand Down Expand Up @@ -3168,6 +3219,7 @@ describe('Process Tests', () => {

});
});

/*
it('Should not clearOnHide when set to false', async () => {
var components = [
Expand Down
88 changes: 88 additions & 0 deletions src/process/conditions/__tests__/conditions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from 'chai';
import { processSync } from '../../process'
import { conditionProcessInfo } from '../index';
import { ConditionsScope, ProcessContext } from 'types';
import { get } from 'lodash';

const processForm = (form: any, submission: any) => {
const context: ProcessContext<ConditionsScope> = {
Expand Down Expand Up @@ -52,4 +53,91 @@ describe('Condition processor', () => {
expect(context.components[1]).to.haveOwnProperty('hidden');
expect(context.components[1].hidden).to.be.true;
});

it('Should not define a conditional component (that condition is based on selectBoxes value) as hidden', async () => {
const form1 = {
components: [
{
label: 'Select Boxes',
optionsLabelPosition: 'right',
tableView: false,
defaultValue: {
'1': false,
'2': false,
'3': false,
test3: false,
},
values: [
{
label: '1',
value: '1',
shortcut: '',
},
{
label: '2',
value: '2',
shortcut: '',
},
{
label: '3',
value: '3',
shortcut: '',
},
],
validateWhenHidden: false,
key: 'selectBoxes',
type: 'selectboxes',
input: true,
inputType: 'checkbox',
},
{
label: 'Text Field',
applyMaskOn: 'change',
tableView: true,
validateWhenHidden: false,
key: 'textField',
conditional: {
show: true,
conjunction: 'all',
conditions: [
{
component: 'selectBoxes',
operator: 'isEqual',
value: '3',
},
],
},
type: 'textfield',
input: true,
},
{
type: 'button',
label: 'Submit',
key: 'submit',
disableOnInvalid: true,
input: true,
tableView: false,
},
],
};

const submission1 = {
data: {
selectBoxes: {
'1': false,
'2': false,
'3': true,
},
textField: 'test',
submit: true,
},
};

const context: ProcessContext<ConditionsScope> = processForm(
form1,
submission1
);

expect(get(context, 'scope.conditionals[0].conditionallyHidden')).to.be.false;
});
});
169 changes: 106 additions & 63 deletions src/process/filter/__tests__/filter.test.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,116 @@
import { expect } from 'chai';
import { expect } from "chai";

import { filterProcessSync } from '../';
import { generateProcessorContext } from '../../__tests__/fixtures/util';
import { filterProcessSync } from "../";
import { generateProcessorContext } from "../../__tests__/fixtures/util";
import { FilterScope, ProcessorContext } from "types";

it('Should not filter empty array value for dataGrid component', async () => {
const dataGridComp = {
type: 'datagrid',
key: 'dataGrid',
it("Should not filter empty array value for dataGrid component", async () => {
const dataGridComp = {
type: "datagrid",
key: "dataGrid",
input: true,
path: "dataGrid",
components: [
{
type: "textfield",
key: "textField",
input: true,
path: 'dataGrid',
components: [
{
type: 'textfield',
key: 'textField',
input: true,
label: 'Text Field'
}
]
};
const data = {
dataGrid: []
};
const context: any = generateProcessorContext(dataGridComp, data);
filterProcessSync(context);
expect(context.scope.filter).to.deep.equal({'dataGrid': {'compModelType': 'array', 'include': true, value: []}});
label: "Text Field",
},
],
};
const data = {
dataGrid: [],
};
const context: any = generateProcessorContext(dataGridComp, data);
filterProcessSync(context);
expect(context.scope.filter).to.deep.equal({
dataGrid: { compModelType: "array", include: true, value: [] },
});
});

it('Should not filter empty array value for editGrid component', async () => {
const editGridComp = {
type: 'editgrid',
key: 'editGrid',
it("Should not filter empty array value for editGrid component", async () => {
const editGridComp = {
type: "editgrid",
key: "editGrid",
input: true,
path: "editGrid",
components: [
{
type: "textfield",
key: "textField",
input: true,
path: 'editGrid',
components: [
{
type: 'textfield',
key: 'textField',
input: true,
label: 'Text Field'
}
]
};
const data = {
editGrid: []
};
const context: any = generateProcessorContext(editGridComp, data);
filterProcessSync(context);
expect(context.scope.filter).to.deep.equal({'editGrid': {'compModelType': 'array', 'include': true, value: []}});
label: "Text Field",
},
],
};
const data = {
editGrid: [],
};
const context: any = generateProcessorContext(editGridComp, data);
filterProcessSync(context);
expect(context.scope.filter).to.deep.equal({
editGrid: { compModelType: "array", include: true, value: [] },
});
});

it('Should not filter empty array value for datTable component', async () => {
const dataTableComp = {
type: 'datatable',
key: 'dataTable',
it("Should not filter empty array value for dataTable component", async () => {
const dataTableComp = {
type: "datatable",
key: "dataTable",
input: true,
path: "dataTable",
components: [
{
type: "textfield",
key: "textField",
input: true,
path: 'dataTable',
components: [
{
type: 'textfield',
key: 'textField',
input: true,
label: 'Text Field'
}
]
};
const data = {
dataTable: []
};
const context: any = generateProcessorContext(dataTableComp, data);
filterProcessSync(context);
expect(context.scope.filter).to.deep.equal({'dataTable': {'compModelType': 'array', 'include': true, value: []}});
label: "Text Field",
},
],
};
const data = {
dataTable: [],
};
const context: any = generateProcessorContext(dataTableComp, data);
filterProcessSync(context);
expect(context.scope.filter).to.deep.equal({
dataTable: { compModelType: "array", include: true, value: [] },
});
});

it("Should not filter the datamap component", async () => {
const dataMapComp = {
label: "Data Map",
tableView: false,
validateWhenHidden: false,
key: "dataMap",
type: "datamap",
path: "dataMap",
input: true,
valueComponent: {
type: "textfield",
key: "value",
label: "Value",
input: true,
hideLabel: true,
tableView: true,
},
};

const data = {
dataMap: {
foo: "bar",
baz: "biz"
},
};

const context: ProcessorContext<FilterScope> = generateProcessorContext(dataMapComp, data);
filterProcessSync(context);
expect(context.scope.filter).to.deep.equal({
dataMap: {
compModelType: "map",
include: true,
}
});
});
Loading

0 comments on commit 53893ff

Please sign in to comment.