fix: fixed the default value of zero not present in parent form data on pageload (#9324)
* fix: fixed the default value of zero not present in parent form data on pageload * test: added cypress test for Checking default value 0 * refactor: changed the DSL and added reset condition at the end of test * refactor: removed the proxy variable * refactor: corrected the typo
This commit is contained in:
parent
74a9e7c892
commit
ba5262df2c
184
app/client/cypress/fixtures/formWidgetWithInputValCheckDsl.json
Normal file
184
app/client/cypress/fixtures/formWidgetWithInputValCheckDsl.json
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
{
|
||||
"dsl":{
|
||||
"widgetName": "MainContainer",
|
||||
"backgroundColor": "none",
|
||||
"rightColumn": 752,
|
||||
"snapColumns": 64,
|
||||
"detachFromLayout": true,
|
||||
"widgetId": "0",
|
||||
"topRow": 0,
|
||||
"bottomRow": 1320,
|
||||
"containerStyle": "none",
|
||||
"snapRows": 125,
|
||||
"parentRowSpace": 1,
|
||||
"type": "CANVAS_WIDGET",
|
||||
"canExtend": true,
|
||||
"version": 46,
|
||||
"minHeight": 1292,
|
||||
"parentColumnSpace": 1,
|
||||
"dynamicBindingPathList": [],
|
||||
"leftColumn": 0,
|
||||
"children": [
|
||||
{
|
||||
"widgetName": "Form1",
|
||||
"backgroundColor": "white",
|
||||
"rightColumn": 43,
|
||||
"isCanvas": true,
|
||||
"displayName": "Form",
|
||||
"iconSVG": "/static/media/icon.ea3e08d1.svg",
|
||||
"widgetId": "u6qzpvlqxg",
|
||||
"topRow": 33,
|
||||
"bottomRow": 73,
|
||||
"parentRowSpace": 10,
|
||||
"isVisible": true,
|
||||
"type": "FORM_WIDGET",
|
||||
"hideCard": false,
|
||||
"parentId": "0",
|
||||
"renderMode": "CANVAS",
|
||||
"isLoading": false,
|
||||
"parentColumnSpace": 25.6875,
|
||||
"leftColumn": 19,
|
||||
"children": [
|
||||
{
|
||||
"widgetName": "Canvas1",
|
||||
"rightColumn": 616.5,
|
||||
"detachFromLayout": true,
|
||||
"displayName": "Canvas",
|
||||
"widgetId": "zkqsia9dzd",
|
||||
"containerStyle": "none",
|
||||
"topRow": 0,
|
||||
"bottomRow": 400,
|
||||
"parentRowSpace": 1,
|
||||
"isVisible": true,
|
||||
"type": "CANVAS_WIDGET",
|
||||
"canExtend": false,
|
||||
"version": 1,
|
||||
"hideCard": true,
|
||||
"parentId": "u6qzpvlqxg",
|
||||
"minHeight": 400,
|
||||
"renderMode": "CANVAS",
|
||||
"isLoading": false,
|
||||
"parentColumnSpace": 1,
|
||||
"leftColumn": 0,
|
||||
"children": [
|
||||
{
|
||||
"widgetName": "Text1",
|
||||
"rightColumn": 25.5,
|
||||
"textAlign": "LEFT",
|
||||
"displayName": "Text",
|
||||
"iconSVG": "/static/media/icon.97c59b52.svg",
|
||||
"widgetId": "gh71y0ot75",
|
||||
"topRow": 1,
|
||||
"bottomRow": 5,
|
||||
"isVisible": true,
|
||||
"fontStyle": "BOLD",
|
||||
"type": "TEXT_WIDGET",
|
||||
"textColor": "#231F20",
|
||||
"version": 1,
|
||||
"hideCard": false,
|
||||
"parentId": "zkqsia9dzd",
|
||||
"renderMode": "CANVAS",
|
||||
"isLoading": false,
|
||||
"leftColumn": 1.5,
|
||||
"fontSize": "HEADING1",
|
||||
"text": "Form",
|
||||
"key": "jlovma12cc"
|
||||
},
|
||||
{
|
||||
"resetFormOnClick": true,
|
||||
"widgetName": "FormButton1",
|
||||
"onClick": "{{showAlert(JSON.stringify(Form1.data),'success')}}",
|
||||
"buttonColor": "#03B365",
|
||||
"displayName": "FormButton",
|
||||
"iconSVG": "/static/media/icon.c8f649ed.svg",
|
||||
"topRow": 33,
|
||||
"bottomRow": 37,
|
||||
"type": "FORM_BUTTON_WIDGET",
|
||||
"hideCard": true,
|
||||
"dynamicTriggerPathList": [
|
||||
{
|
||||
"key": "onClick"
|
||||
}
|
||||
],
|
||||
"leftColumn": 46.4,
|
||||
"dynamicBindingPathList": [],
|
||||
"text": "Submit",
|
||||
"key": "txl91qn4v7",
|
||||
"rightColumn": 62.4,
|
||||
"isDefaultClickDisabled": true,
|
||||
"widgetId": "10ii5n734a",
|
||||
"recaptchaV2": false,
|
||||
"isVisible": true,
|
||||
"version": 1,
|
||||
"parentId": "zkqsia9dzd",
|
||||
"renderMode": "CANVAS",
|
||||
"isLoading": false,
|
||||
"disabledWhenInvalid": true,
|
||||
"buttonVariant": "PRIMARY"
|
||||
},
|
||||
{
|
||||
"resetFormOnClick": true,
|
||||
"widgetName": "FormButton2",
|
||||
"rightColumn": 46,
|
||||
"isDefaultClickDisabled": true,
|
||||
"buttonColor": "#03B365",
|
||||
"displayName": "FormButton",
|
||||
"iconSVG": "/static/media/icon.c8f649ed.svg",
|
||||
"widgetId": "v79qn33c97",
|
||||
"topRow": 33,
|
||||
"bottomRow": 37,
|
||||
"recaptchaV2": false,
|
||||
"isVisible": true,
|
||||
"type": "FORM_BUTTON_WIDGET",
|
||||
"version": 1,
|
||||
"hideCard": true,
|
||||
"parentId": "zkqsia9dzd",
|
||||
"renderMode": "CANVAS",
|
||||
"isLoading": false,
|
||||
"disabledWhenInvalid": false,
|
||||
"leftColumn": 30,
|
||||
"buttonVariant": "SECONDARY",
|
||||
"text": "Reset",
|
||||
"key": "txl91qn4v7"
|
||||
},
|
||||
{
|
||||
"widgetName": "Input1",
|
||||
"displayName": "Input",
|
||||
"iconSVG": "/static/media/icon.9f505595.svg",
|
||||
"topRow": 15,
|
||||
"bottomRow": 19,
|
||||
"parentRowSpace": 10,
|
||||
"autoFocus": false,
|
||||
"type": "INPUT_WIDGET",
|
||||
"hideCard": false,
|
||||
"parentColumnSpace": 9.3203125,
|
||||
"dynamicTriggerPathList": [],
|
||||
"resetOnSubmit": true,
|
||||
"leftColumn": 3,
|
||||
"dynamicBindingPathList": [],
|
||||
"labelStyle": "",
|
||||
"inputType": "NUMBER",
|
||||
"isDisabled": false,
|
||||
"key": "hsnmfwzbat",
|
||||
"isRequired": false,
|
||||
"rightColumn": 23,
|
||||
"widgetId": "87tck9yils",
|
||||
"isVisible": true,
|
||||
"label": "",
|
||||
"allowCurrencyChange": false,
|
||||
"version": 1,
|
||||
"parentId": "zkqsia9dzd",
|
||||
"renderMode": "CANVAS",
|
||||
"isLoading": false,
|
||||
"iconAlign": "left",
|
||||
"defaultText": "0"
|
||||
}
|
||||
],
|
||||
"key": "5kmhfog0cm"
|
||||
}
|
||||
],
|
||||
"key": "w94gfcu5cu"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
const dsl = require("../../../../fixtures/formWidgetWithInputValCheckDsl.json");
|
||||
const widgetsPage = require("../../../../locators/Widgets.json");
|
||||
|
||||
describe("Form Widget with Input Functionality", function() {
|
||||
before(() => {
|
||||
cy.addDsl(dsl);
|
||||
});
|
||||
|
||||
it("Check if the default value of text input is 0", function() {
|
||||
//Check if the Input widget is visible
|
||||
cy.get(widgetsPage.inputWidget).should("be.visible");
|
||||
|
||||
//Check if the submit button is visible;
|
||||
cy.get(widgetsPage.formButtonWidget)
|
||||
.contains("Submit")
|
||||
.scrollIntoView()
|
||||
.should("be.visible");
|
||||
|
||||
//Do Submission
|
||||
cy.get(widgetsPage.formButtonWidget)
|
||||
.contains("Submit")
|
||||
.click();
|
||||
|
||||
//Check if on submission if the notification toast appears with text containing input1: 0
|
||||
cy.get(widgetsPage.toastActionText)
|
||||
.last()
|
||||
.invoke("text")
|
||||
.then((text) => {
|
||||
expect(text).to.equal('{"Text1":"Form","Input1":0}');
|
||||
});
|
||||
|
||||
cy.get(widgetsPage.formButtonWidget)
|
||||
.contains("Reset")
|
||||
.scrollIntoView()
|
||||
.should("be.visible");
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import React from "react";
|
||||
import { get, some, isEqual } from "lodash";
|
||||
import { get, some, isEqual, isNil } from "lodash";
|
||||
import { WidgetProps } from "../../BaseWidget";
|
||||
import { WidgetType } from "constants/WidgetConstants";
|
||||
import ContainerWidget, {
|
||||
|
|
@ -48,7 +48,7 @@ class FormWidget extends ContainerWidget {
|
|||
const formData: any = {};
|
||||
if (formWidget.children)
|
||||
formWidget.children.forEach((widgetData) => {
|
||||
if (widgetData.value) {
|
||||
if (!isNil(widgetData.value)) {
|
||||
formData[widgetData.widgetName] = widgetData.value;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user