From d5e3b30bf0667b2c857190c249136b2e0983968e Mon Sep 17 00:00:00 2001 From: srikant Date: Sat, 15 Jun 2024 00:58:47 +0530 Subject: [PATCH] #2012 Add support for helperText in all Common Properties controls. (#2013) Signed-off-by: srikant --- .../controls/checkbox-test.js | 16 + .../controls/datefield-test.js | 17 + .../controls/datepicker-test.js | 18 + .../controls/multiselect-test.js | 17 + .../controls/numberfield-test.js | 17 + .../controls/oneofselect-test.js | 16 + .../controls/passwordfield-test.js | 17 + .../controls/radioset-test.js | 5 + .../controls/selectcolumn-test.js | 16 + .../controls/textarea-test.js | 15 + .../controls/textfield-test.js | 17 + .../controls/timefield-test.js | 18 + .../paramDefs/radio_paramDef.json | 5 +- .../controls/checkbox/checkbox.jsx | 1 + .../controls/datefield/datefield.jsx | 1 + .../controls/datepicker/datepicker.jsx | 2 +- .../controls/dropdown/dropdown.jsx | 3 + .../controls/multiselect/multiselect.jsx | 2 + .../controls/numberfield/numberfield.jsx | 1 + .../controls/passwordfield/passwordfield.jsx | 1 + .../controls/radioset/radioset.jsx | 1 + .../controls/textarea/textarea.jsx | 2 + .../controls/textfield/textfield.jsx | 1 + .../controls/timefield/timefield.jsx | 1 + .../src/common-properties/form/ControlInfo.js | 3 + .../src/common-properties/form/EditorForm.js | 2 + .../common-properties/form/ParameterInfo.js | 14 +- .../parameterDefs/checkbox_paramDef.json | 26 +- .../parameterDefs/datefield_paramDef.json | 7 +- .../datepickerRange_paramDef.json | 3 + .../parameterDefs/datepicker_paramDef.json | 568 +++++++++--------- .../parameterDefs/multiselect_paramDef.json | 3 + .../parameterDefs/numberfield_paramDef.json | 5 +- .../parameterDefs/oneofselect_paramDef.json | 5 +- .../parameterDefs/passwordfield_paramDef.json | 5 +- .../parameterDefs/radio_paramDef.json | 5 +- .../parameterDefs/selectcolumn_paramDef.json | 3 + .../parameterDefs/textarea_paramDef.json | 5 +- .../parameterDefs/textfield_paramDef.json | 5 +- .../parameterDefs/timefield_paramDef.json | 3 + docs/pages/04.03-ui-hints.md | 2 + 41 files changed, 558 insertions(+), 316 deletions(-) diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/checkbox-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/checkbox-test.js index dcf7a32b8b..e0bbdfb72c 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/checkbox-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/checkbox-test.js @@ -199,6 +199,22 @@ describe("checkbox control tests", () => { const messageWrapper = checkboxWrapper.find("div.properties-validation-message"); expect(messageWrapper).to.have.length(1); }); + it("Checkbox helperText is rendered correctly", () => { + control.helperText = "Checkbox helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-test-checkbox']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); }); describe("checkbox classnames appear correctly", () => { diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/datefield-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/datefield-test.js index e26e8c4dab..8af0ccdee8 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/datefield-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/datefield-test.js @@ -22,6 +22,7 @@ import { mount } from "../../_utils_/mount-utils.js"; import { expect } from "chai"; import Controller from "../../../src/common-properties/properties-controller"; import datefieldParamDef from "../../test_resources/paramDefs/datefield_paramDef.json"; +import DateField from "../../../src/common-properties/controls/datefield"; const DATEFIELD_PARAM_DEF = require("../../test_resources/paramDefs/datefield_paramDef.json"); @@ -177,6 +178,22 @@ describe("datefield-control renders correctly", () => { const dateWrapper = wrapper.find("div[data-id='properties-test-datefield']"); expect(dateWrapper.find(".cds--text-input--light")).to.have.length(0); }); + it("Datefield helperText is rendered correctly", () => { + control.helperText = "Datefield helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-test-datefield']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); }); describe("error messages renders correctly for datefield controls", () => { diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/datepicker-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/datepicker-test.js index 2ed5d9cd57..35afb2b216 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/datepicker-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/datepicker-test.js @@ -103,6 +103,24 @@ describe("datepicker-control renders correctly", () => { expect(input.prop("value")).to.equal("10-29-2023"); }); + it("should have helperText rendered correctly in `DatepickerControl`", () => { + control.helperText = "Datepicker helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-test-datepicker']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); + it("should allow a valid date to be updated in `DatepickerControl`", () => { const wrapper = mount( { const messageWrapper = multiselectWrapper.find("div.cds--form-requirement"); expect(messageWrapper).to.have.length(1); }); + + it("MultiSelectControl helperText is rendered correctly", () => { + control.helperText = "MultiSelectControl helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-test-multiselect']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); }); describe("multiselect paramDef works correctly", () => { diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/numberfield-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/numberfield-test.js index 676dd1373e..23f172745e 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/numberfield-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/numberfield-test.js @@ -144,6 +144,23 @@ describe("numberfield-control renders correctly", () => { const messageWrapper = textWrapper.find("div.cds--form-requirement"); expect(messageWrapper).to.have.length(1); }); + + it("NumberfieldControl helperText is rendered correctly", () => { + control.helperText = "NumberfieldControl helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-test-number']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); }); describe("numberfield control works correctly", () => { diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/oneofselect-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/oneofselect-test.js index bfb22c0448..cb80332d0e 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/oneofselect-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/oneofselect-test.js @@ -218,6 +218,22 @@ describe("oneofselect renders correctly", () => { const messageWrapper = dropdownWrapper.find("div.cds--form-requirement"); expect(messageWrapper).to.have.length(1); }); + it("oneofselect helperText is rendered correctly", () => { + control.helperText = "Oneofselect helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-test-oneofselect']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); }); describe("oneofselect paramDef works correctly", () => { diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/passwordfield-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/passwordfield-test.js index abe1d161df..8fe4a737e0 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/passwordfield-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/passwordfield-test.js @@ -200,6 +200,23 @@ describe("Passwordfield renders correctly", () => { eyeIcon.simulate("click"); expect(passwordWrapper.find(`span[id='${eyeIconAriaLabelledBy}']`).text()).to.equal(control.tooltip.defaultHide); }); + + it("Passwordfield helperText is rendered correctly", () => { + control.helperText = "Passwordfield helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-test-password']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); }); describe("passwordfield classnames appear correctly", () => { diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/radioset-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/radioset-test.js index eaa62b52e6..5a707e9b67 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/radioset-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/radioset-test.js @@ -52,6 +52,11 @@ describe("radio renders and works correctly with different enum types", () => { expect(renderedController.getPropertyValue({ name: "radioString" })).to.equal("gini"); }); + it("radioset control with string enum helper text is visible", () => { + const controlDiv = wrapper.find("div[data-id='properties-ci-radioString']"); + expect(controlDiv.find("div.cds--form__helper-text").text()).to.equal("RadioSet with enum string type"); + }); + it("radioset control with boolean enum", () => { const controlDiv = wrapper.find("div[data-id='properties-ci-radioBooleanWithEnum']"); const label = controlDiv.find("label.properties-control-label"); diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/selectcolumn-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/selectcolumn-test.js index 87395f7a91..f5b64cddc3 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/selectcolumn-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/selectcolumn-test.js @@ -198,6 +198,22 @@ describe("selectcolumn control renders correctly", () => { dropdownList.at(0).simulate("click"); expect(controller.getPropertyValue(propertyId)).to.equal(""); }); + it("SelectColumn helperText is rendered correctly", () => { + control.helperText = "SelectColumn helperText"; + controller.setPropertyValues( + { } + ); + const wrapper = mount( + + ); + const helpTextWrapper = wrapper.find("div[data-id='properties-targetField']"); + expect(helpTextWrapper.find("div.cds--form__helper-text").text()).to.equal(control.helperText); + }); }); describe("selectcolumn control renders correctly with paramDef", () => { diff --git a/canvas_modules/common-canvas/__tests__/common-properties/controls/textarea-test.js b/canvas_modules/common-canvas/__tests__/common-properties/controls/textarea-test.js index 9bc963ac1e..2135485eea 100644 --- a/canvas_modules/common-canvas/__tests__/common-properties/controls/textarea-test.js +++ b/canvas_modules/common-canvas/__tests__/common-properties/controls/textarea-test.js @@ -300,6 +300,21 @@ describe("textarea control renders correctly", () => { const validationMsg = textWrapper.find("div.cds--form-requirement"); expect(validationMsg).to.have.length(1); }); + + it("textarea should have helper text", () => { + control.helperText = "Textarea helperText"; + controller.setPropertyValues({}); + const wrapper = mount( +