From 4455c98ff78ee377fa054ce8f877beea7cbb04d9 Mon Sep 17 00:00:00 2001 From: acharyaaditya18 <59086894+acharyaaditya18@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:34:38 +0530 Subject: [PATCH 1/2] Locatorfix --- .../integration/Smoke_TestSuite/CommonWidgets/Input_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Input_spec.js b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Input_spec.js index a7bb48470e..3542c37709 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Input_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Input_spec.js @@ -25,14 +25,14 @@ describe("Input Widget Functionality", function() { cy.get(widgetsPage.innertext) .click({ force: true }) .type(this.data.para); - cy.get(publish.inputWidget + " " + "input") + cy.get(widgetsPage.inputWidget + " " + "input") .invoke("attr", "value") .should("contain", this.data.para); cy.openPropertyPane("inputwidget"); cy.get(widgetsPage.defaultInput) .type(this.data.command) .type(this.data.defaultdata); - cy.get(publish.inputWidget + " " + "input") + cy.get(widgetsPage.inputWidget + " " + "input") .invoke("attr", "value") .should("contain", this.data.defaultdata); cy.get(widgetsPage.placeholder) From 973af1c5e7353b601b547e7941a608d6153e3265 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Tue, 2 Jun 2020 11:27:24 +0000 Subject: [PATCH 2/2] Single series chart data --- app/client/cypress/fixtures/viewdsl.json | 61 +++++++++---------- .../Smoke_TestSuite/ViewWidgets/Chart_spec.js | 5 ++ .../cypress/locators/publishWidgetspage.json | 4 +- app/client/src/constants/WidgetValidation.ts | 1 + .../mockResponses/WidgetConfigResponse.tsx | 59 ++++++++---------- app/client/src/utils/Validators.ts | 39 ++++++++++++ app/client/src/widgets/ChartWidget.tsx | 13 +++- 7 files changed, 114 insertions(+), 68 deletions(-) diff --git a/app/client/cypress/fixtures/viewdsl.json b/app/client/cypress/fixtures/viewdsl.json index 19c9d06392..083aa66cbf 100644 --- a/app/client/cypress/fixtures/viewdsl.json +++ b/app/client/cypress/fixtures/viewdsl.json @@ -148,39 +148,34 @@ "chartType": "BAR_CHART", "chartName": "App Sign Up", "allowHorizontalScroll": false, - "chartData": [ + "singleChartData": [ { - "seriesName": "", - "data": [ - { - "x": "Mon", - "y": 10000 - }, - { - "x": "Tue", - "y": 12000 - }, - { - "x": "Wed", - "y": 32000 - }, - { - "x": "Thu", - "y": 28000 - }, - { - "x": "Fri", - "y": 14000 - }, - { - "x": "Sat", - "y": 19000 - }, - { - "x": "Sun", - "y": 36000 - } - ] + "x": "Mon", + "y": 10000 + }, + { + "x": "Tue", + "y": 12000 + }, + { + "x": "Wed", + "y": 32000 + }, + { + "x": "Thu", + "y": 28000 + }, + { + "x": "Fri", + "y": 14000 + }, + { + "x": "Sat", + "y": 19000 + }, + { + "x": "Sun", + "y": 36000 } ], "xAxisName": "Last Week", @@ -265,4 +260,4 @@ ] }, "layoutOnLoadActions": [] - } \ No newline at end of file + } diff --git a/app/client/cypress/integration/Smoke_TestSuite/ViewWidgets/Chart_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ViewWidgets/Chart_spec.js index e82e995792..a254f61b23 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ViewWidgets/Chart_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ViewWidgets/Chart_spec.js @@ -6,6 +6,7 @@ const dsl = require("../../../fixtures/viewdsl.json"); describe("Chart Widget Functionality", function() { before(() => { cy.addDsl(dsl); + cy.viewport("macbook-15"); //To avoid screen Resize issues }); it("Chart Widget Functionality", function() { cy.openPropertyPane("chartwidget"); @@ -65,6 +66,7 @@ describe("Chart Widget Functionality", function() { cy.get(commonlocators.editPropCrossButton).click(); }); it("Chart Widget Functionality To Unchecked Visible Widget", function() { + cy.viewport("macbook-15"); //To avoid screen Resize issues cy.openPropertyPane("chartwidget"); cy.togglebarDisable(commonlocators.visibleCheckbox); cy.PublishtheApp(); @@ -72,6 +74,7 @@ describe("Chart Widget Functionality", function() { cy.get(publish.backToEditor).click(); }); it("Chart Widget Functionality To Check Visible Widget", function() { + cy.viewport("macbook-15"); //To avoid screen Resize issues cy.openPropertyPane("chartwidget"); cy.togglebar(commonlocators.visibleCheckbox); cy.PublishtheApp(); @@ -79,6 +82,7 @@ describe("Chart Widget Functionality", function() { cy.get(publish.backToEditor).click(); }); it("Chart Widget Functionality To Uncheck Horizontal Scroll Visible", function() { + cy.viewport("macbook-15"); //To avoid screen Resize issues cy.openPropertyPane("chartwidget"); cy.togglebarDisable(commonlocators.horizontalScroll); cy.PublishtheApp(); @@ -86,6 +90,7 @@ describe("Chart Widget Functionality", function() { cy.get(publish.backToEditor).click(); }); it("Chart Widget Functionality To Check Horizontal Scroll Visible", function() { + cy.viewport("macbook-15"); //To avoid screen Resize issues cy.openPropertyPane("chartwidget"); cy.togglebar(commonlocators.horizontalScroll); cy.PublishtheApp(); diff --git a/app/client/cypress/locators/publishWidgetspage.json b/app/client/cypress/locators/publishWidgetspage.json index da1c929029..c8f793881b 100644 --- a/app/client/cypress/locators/publishWidgetspage.json +++ b/app/client/cypress/locators/publishWidgetspage.json @@ -12,10 +12,10 @@ "dropdownWidget": ".t--widget-dropdownwidget", "tabWidget": ".t--widget-tabswidget", "chartWidget": ".t--widget-chartwidget", - "horizontalTab": ".t--widget-chartwidget g[class='raphael-group-104-axis-Line-group'] rect", + "horizontalTab": ".t--widget-chartwidget g[class*='-scrollContainer'] rect", "tableWidget": ".t--widget-tablewidget", "mapWidget": ".t--widget-mapwidget", "tableLength": ".t--widget-tablewidget .e-gridcontent.e-lib.e-droppable", "mapSearch": ".t--widget-mapwidget input", "pickMyLocation": ".t--widget-mapwidget div[title='Pick My Location']" -} \ No newline at end of file +} diff --git a/app/client/src/constants/WidgetValidation.ts b/app/client/src/constants/WidgetValidation.ts index 0dc2ac1f5c..6ef0562993 100644 --- a/app/client/src/constants/WidgetValidation.ts +++ b/app/client/src/constants/WidgetValidation.ts @@ -11,6 +11,7 @@ export const VALIDATION_TYPES = { ARRAY: "ARRAY", TABLE_DATA: "TABLE_DATA", OPTIONS_DATA: "OPTIONS_DATA", + SINGLE_CHART_DATA: "SINGLE_CHART_DATA", DATE: "DATE", TABS_DATA: "TABS_DATA", CHART_DATA: "CHART_DATA", diff --git a/app/client/src/mockResponses/WidgetConfigResponse.tsx b/app/client/src/mockResponses/WidgetConfigResponse.tsx index 3364db6393..69dbfc74f3 100644 --- a/app/client/src/mockResponses/WidgetConfigResponse.tsx +++ b/app/client/src/mockResponses/WidgetConfigResponse.tsx @@ -312,39 +312,34 @@ const WidgetConfigResponse: WidgetConfigReducerState = { chartType: "LINE_CHART", chartName: "Sales on working days", allowHorizontalScroll: false, - chartData: [ + singleChartData: [ { - seriesName: "", - data: [ - { - x: "Mon", - y: 10000, - }, - { - x: "Tue", - y: 12000, - }, - { - x: "Wed", - y: 32000, - }, - { - x: "Thu", - y: 28000, - }, - { - x: "Fri", - y: 14000, - }, - { - x: "Sat", - y: 19000, - }, - { - x: "Sun", - y: 36000, - }, - ], + x: "Mon", + y: 10000, + }, + { + x: "Tue", + y: 12000, + }, + { + x: "Wed", + y: 32000, + }, + { + x: "Thu", + y: 28000, + }, + { + x: "Fri", + y: 14000, + }, + { + x: "Sat", + y: 19000, + }, + { + x: "Sun", + y: 36000, }, ], xAxisName: "Last Week", diff --git a/app/client/src/utils/Validators.ts b/app/client/src/utils/Validators.ts index 1ad1c70e7d..6a371004a5 100644 --- a/app/client/src/utils/Validators.ts +++ b/app/client/src/utils/Validators.ts @@ -316,6 +316,45 @@ export const VALIDATORS: Record = { } return { isValid, parsed }; }, + [VALIDATION_TYPES.SINGLE_CHART_DATA]: (value, props, dataTree) => { + const { isValid, parsed } = VALIDATORS[VALIDATION_TYPES.TABLE_DATA]( + value, + props, + dataTree, + ); + if (!isValid) { + return { + isValid: false, + parsed: [], + message: `${WIDGET_TYPE_VALIDATION_ERROR}: Chart Data`, + }; + } + + const isValidChartData = _.every( + parsed, + (chartPoint: { x: string; y: any }) => { + return ( + _.isObject(chartPoint) && + _.isString(chartPoint.x) && + !_.isUndefined(chartPoint.y) + ); + }, + ); + + if (!isValidChartData) { + return { + isValid: false, + parsed: [], + message: `${WIDGET_TYPE_VALIDATION_ERROR}: Chart Data`, + }; + } + + return { + isValid: true, + parsed, + message: "", + }; + }, [VALIDATION_TYPES.MARKERS]: ( value: any, props: WidgetProps, diff --git a/app/client/src/widgets/ChartWidget.tsx b/app/client/src/widgets/ChartWidget.tsx index 09871441c6..d88ef6070c 100644 --- a/app/client/src/widgets/ChartWidget.tsx +++ b/app/client/src/widgets/ChartWidget.tsx @@ -20,10 +20,20 @@ class ChartWidget extends BaseWidget { chartName: VALIDATION_TYPES.TEXT, isVisible: VALIDATION_TYPES.BOOLEAN, chartData: VALIDATION_TYPES.CHART_DATA, + singleChartData: VALIDATION_TYPES.SINGLE_CHART_DATA, }; } getPageView() { + let chartData: ChartData[] = this.props.chartData; + if (this.props.singleChartData) { + chartData = [ + { + seriesName: this.props.chartName, + data: this.props.singleChartData, + }, + ]; + } return ( }> { xAxisName={this.props.xAxisName} yAxisName={this.props.yAxisName} chartName={this.props.chartName} - chartData={this.props.chartData} + chartData={chartData} widgetId={this.props.widgetId} allowHorizontalScroll={this.props.allowHorizontalScroll} /> @@ -67,6 +77,7 @@ export interface ChartData { export interface ChartWidgetProps extends WidgetProps { chartType: ChartType; chartData: ChartData[]; + singleChartData: ChartDataPoint[]; xAxisName: string; yAxisName: string; chartName: string;