From 716ddda0ad4be7af47ab3587f8a5bca4a150b590 Mon Sep 17 00:00:00 2001 From: "ICX\\Tatsiana.Hashtold" Date: Wed, 9 Oct 2024 11:39:47 +0300 Subject: [PATCH] FIO-9186: added test for the issue reated to validation inside layout components insode editGrid --- package.json | 2 +- test/unit/EditGrid.unit.js | 27 ++++++++++ test/unit/fixtures/editgrid/comp19.js | 71 +++++++++++++++++++++++++++ test/unit/fixtures/editgrid/index.js | 3 +- yarn.lock | 39 +++------------ 5 files changed, 108 insertions(+), 34 deletions(-) create mode 100644 test/unit/fixtures/editgrid/comp19.js diff --git a/package.json b/package.json index 34942d5f9a..26bde1f438 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "dependencies": { "@formio/bootstrap": "3.0.0-dev.98.17ba6ea", "@formio/choices.js": "^10.2.1", - "@formio/core": "v2.1.0-dev.156.78a83fd", + "@formio/core": "v2.1.0-dev.165.e6994a9", "@formio/text-mask-addons": "^3.8.0-formio.2", "@formio/vanilla-text-mask": "^5.1.1-formio.1", "abortcontroller-polyfill": "^1.7.5", diff --git a/test/unit/EditGrid.unit.js b/test/unit/EditGrid.unit.js index a33d677f18..1e9993de9d 100644 --- a/test/unit/EditGrid.unit.js +++ b/test/unit/EditGrid.unit.js @@ -19,6 +19,7 @@ import { comp15, comp16, comp17, + comp19, withOpenWhenEmptyAndConditions, compOpenWhenEmpty, compWithCustomDefaultValue, @@ -1411,6 +1412,32 @@ describe('EditGrid Component', () => { }, 300); }).catch(done); }); + + it('Should not allow to save invalid row when there are required components inside columns in the editGrod row', (done) => { + const formElement = document.createElement('div'); + const form = new Webform(formElement); + + form.setForm(comp19).then(() => { + const editGrid = form.components[0]; + + setTimeout(() => { + Harness.dispatchEvent('click', form.element, '[ref="editgrid-editGrid-addRow"]'); + setTimeout(() => { + assert.equal(editGrid.editRows.length, 1); + assert.equal(!!editGrid.editRows[0].errors?.length, false); + assert.equal(editGrid.editRows[0].state, 'new'); + Harness.dispatchEvent('click', form.element, '[ref="editgrid-editGrid-saveRow"]'); + setTimeout(() => { + assert.equal(editGrid.editRows.length, 1); + assert.equal(editGrid.editRows[0].errors?.length, 1); + assert.equal(editGrid.editRows[0].state, 'new'); + + done(); + }, 300); + }, 300); + }, 100); + }).catch(done); + }); }); describe('EditGrid Open when Empty', () => { diff --git a/test/unit/fixtures/editgrid/comp19.js b/test/unit/fixtures/editgrid/comp19.js new file mode 100644 index 0000000000..954bdeb210 --- /dev/null +++ b/test/unit/fixtures/editgrid/comp19.js @@ -0,0 +1,71 @@ +export default { + _id: '6704f3d329cf52a3ddd4e244', + title: 'uiu', + name: 'uiu', + path: 'uiu', + type: 'resource', + display: 'form', + components: [ + { + label: 'Edit Grid', + tableView: false, + validateWhenHidden: false, + rowDrafts: false, + key: 'editGrid', + type: 'editgrid', + displayAsTable: false, + input: true, + components: [ + { + label: 'Columns', + columns: [ + { + components: [ + { + label: 'Text Field', + applyMaskOn: 'change', + tableView: true, + validate: { + required: true, + }, + validateWhenHidden: false, + key: 'textField', + type: 'textfield', + input: true, + }, + ], + width: 6, + offset: 0, + push: 0, + pull: 0, + size: 'md', + currentWidth: 6, + }, + { + components: [], + width: 6, + offset: 0, + push: 0, + pull: 0, + size: 'md', + currentWidth: 6, + }, + ], + key: 'columns', + type: 'columns', + input: false, + tableView: false, + }, + ], + }, + { + type: 'button', + label: 'Submit', + key: 'submit', + disableOnInvalid: true, + input: true, + tableView: false, + }, + ], + project: '66f66c655879bf08113cf465', +}; diff --git a/test/unit/fixtures/editgrid/index.js b/test/unit/fixtures/editgrid/index.js index 4cbd89867a..5027789d19 100644 --- a/test/unit/fixtures/editgrid/index.js +++ b/test/unit/fixtures/editgrid/index.js @@ -16,8 +16,9 @@ import comp15 from './comp15'; import comp16 from './comp16'; import comp17 from './comp17'; import comp18 from './comp18'; +import comp19 from './comp19'; import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty'; import compOpenWhenEmpty from './comp-openWhenEmpty'; import compWithCustomDefaultValue from './comp-with-custom-default-value'; import compTestEvents from './comp-test-events'; -export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents }; +export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents }; diff --git a/yarn.lock b/yarn.lock index fcf6828043..6ffc000fcb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -381,10 +381,10 @@ fuse.js "^6.6.2" redux "^4.2.0" -"@formio/core@v2.1.0-dev.156.78a83fd": - version "2.1.0-dev.156.78a83fd" - resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.1.0-dev.156.78a83fd.tgz#a23c2e8f3d52eaa821d1fd32bf7d81a849482d50" - integrity sha512-37B8hswVc3kcwvN+VCBEo9TzvNu5MkUKtiI1AQcnr4yWBJJGljoc9+lrwGN+XMcDhYlfHaXiTnHvi7xKN3kqlA== +"@formio/core@v2.1.0-dev.165.e6994a9": + version "2.1.0-dev.165.e6994a9" + resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.1.0-dev.165.e6994a9.tgz#624ead05fcb7d084253cee5970a7420c6b3ea900" + integrity sha512-GgtAuuLcBJSsuBNW+KQ7YxDQ0Jwb8BtnPjYVj1v4QtAnyE4gZ4t/DSxY+f34wXXZPMd3Q69lEIWjpF2ozIhgFg== dependencies: "@types/json-logic-js" "^2.0.7" browser-cookies "^1.2.0" @@ -7325,7 +7325,7 @@ string-replace-loader@^3.1.0: loader-utils "^2.0.0" schema-utils "^3.0.0" -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0: version "4.2.3" resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -7343,15 +7343,6 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -7412,7 +7403,7 @@ stringifier@^1.3.0: traverse "^0.6.6" type-name "^2.0.1" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -7433,13 +7424,6 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -8502,7 +8486,7 @@ workerpool@6.2.1: resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -8528,15 +8512,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"