diff --git a/app/client/cypress/fixtures/ChartDsl.json b/app/client/cypress/fixtures/ChartDsl.json new file mode 100644 index 0000000000..34d6e92062 --- /dev/null +++ b/app/client/cypress/fixtures/ChartDsl.json @@ -0,0 +1,69 @@ +{ + "dsl": { + "widgetName": "MainContainer", + "backgroundColor": "none", + "rightColumn": 1224, + "snapColumns": 16, + "detachFromLayout": true, + "widgetId": "0", + "topRow": 0, + "bottomRow": 1280, + "containerStyle": "none", + "snapRows": 33, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "version": 11, + "minHeight": 1292, + "parentColumnSpace": 1, + "dynamicBindingPathList": [], + "leftColumn": 0, + "children": [ + { + "isVisible": true, + "widgetName": "Chart1", + "chartType": "BAR_CHART", + "chartName": "Sales on working days", + "allowHorizontalScroll": false, + "version": 1, + "chartData": [ + { + "seriesName": "Sales", + "data": "[\n {\n \"x\": \"Mon\",\n \"y\": 10000\n },\n {\n \"x\": \"Tue\",\n \"y\": 12000\n },\n {\n \"x\": \"Wed\",\n \"y\": 32000\n },\n {\n \"x\": \"Thu\",\n \"y\": 28000\n },\n {\n \"x\": \"Fri\",\n \"y\": 14000\n },\n {\n \"x\": \"Sat\",\n \"y\": 19000\n },\n {\n \"x\": \"Sun\",\n \"y\": 36000\n }\n]" + } + ], + "xAxisName": "Last Week", + "yAxisName": "Total Order Revenue $", + "type": "CHART_WIDGET", + "isLoading": false, + "parentColumnSpace": 74, + "parentRowSpace": 40, + "leftColumn": 0, + "rightColumn": 6, + "topRow": 0, + "bottomRow": 8, + "parentId": "0", + "widgetId": "d1o9lu9jzs", + "dynamicBindingPathList": [] + }, + { + "isVisible": true, + "inputType": "TEXT", + "label": "", + "widgetName": "Input1", + "version": 1, + "resetOnSubmit": true, + "type": "INPUT_WIDGET", + "isLoading": false, + "parentColumnSpace": 74, + "parentRowSpace": 40, + "leftColumn": 8, + "rightColumn": 13, + "topRow": 5, + "bottomRow": 6, + "parentId": "0", + "widgetId": "y4gcv7cjg0" + } + ] + } +} \ No newline at end of file diff --git a/app/client/cypress/fixtures/testdata.json b/app/client/cypress/fixtures/testdata.json index 84d2a402ce..fdf38aa4b6 100644 --- a/app/client/cypress/fixtures/testdata.json +++ b/app/client/cypress/fixtures/testdata.json @@ -113,5 +113,7 @@ "currentRowWithIdInside": "{{\"#\" + currentRow.email}}", "defaultdataBinding": "{'Test','This'}", "dropdownErrorMsg": "This value does not evaluate to type \"Array<{ label: string, value: string }>\". Transform it using JS inside '{{ }}'", - "tableWidgetErrorMsg": "This value does not evaluate to type \"Array\". Transform it using JS inside '{{ }}'" + "tableWidgetErrorMsg": "This value does not evaluate to type \"Array\". Transform it using JS inside '{{ }}'", + "bindingDataPoint": "{{JSON.stringify(Chart1.selectedDataPoint)}}", + "bindChardData": "{{Chart1.selectedDataPoint" } diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Chart_Data_point_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Chart_Data_point_spec.js new file mode 100644 index 0000000000..2f21df6a03 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Chart_Data_point_spec.js @@ -0,0 +1,51 @@ +const commonlocators = require("../../../../locators/commonlocators.json"); +const viewWidgetsPage = require("../../../../locators/ViewWidgets.json"); +const publish = require("../../../../locators/publishWidgetspage.json"); +const dsl = require("../../../../fixtures/ChartDsl.json"); +const pages = require("../../../../locators/Pages.json"); +const testdata = require("../../../../fixtures/testdata.json"); +const widgetsPage = require("../../../../locators/Widgets.json"); + +describe("Chart Widget Functionality", function() { + before(() => { + cy.addDsl(dsl); + }); + + it("Input widget test with default value from chart datapoint", function() { + cy.SearchEntityandOpen("Input1"); + cy.wait(500); + cy.get(widgetsPage.defaultInput).type(testdata.bindChardData); + cy.get(commonlocators.editPropCrossButton).click(); + cy.wait("@updateLayout").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + }); + + it("Chart with datapoint feature validation", function() { + cy.SearchEntityandOpen("Chart1"); + cy.addAction(testdata.bindingDataPoint); + cy.closePropertyPane(); + cy.wait(500); + cy.xpath("(//*[local-name()='rect'])[13]") + .first() + .click({ force: true }); + cy.get(publish.inputWidget + " " + "input") + .first() + .invoke("attr", "value") + .then(($value) => { + const text = $value; + cy.log(text); + cy.wait(3000); + cy.get(".t--toast-action span") + .first() + .invoke("text") + .then((text) => { + const toasttext = text; + cy.log(toasttext); + expect(text.trim()).to.equal(toasttext.trim()); + }); + }); + }); +}); diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 3f01e10883..6814e53e52 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -1309,6 +1309,17 @@ Cypress.Commands.add("evaluateErrorMessage", (value) => { }); }); +Cypress.Commands.add("addAction", (value) => { + cy.get(commonlocators.dropdownSelectButton) + .last() + .click(); + cy.get(commonlocators.chooseAction) + .children() + .contains("Show Message") + .click(); + cy.enterActionValue(value); +}); + Cypress.Commands.add("selectShowMsg", (value) => { cy.get(commonlocators.chooseAction) .children() @@ -1326,6 +1337,7 @@ Cypress.Commands.add("addSuccessMessage", (value) => { .click(); cy.enterActionValue(value); }); + Cypress.Commands.add("SetDateToToday", () => { cy.get(formWidgetsPage.datepickerFooter) .contains("Today")