From aceb496da066a09669c6eec92b0a0889731e55f1 Mon Sep 17 00:00:00 2001 From: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:32:13 +0100 Subject: [PATCH 1/2] fix: Fix uqi query switching issue (#26167) --- .../ClientSide/BugTests/Bug25982_Spec.ts | 31 +++++++++++++++++++ .../formControls/DropDownControl.tsx | 9 ++---- 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 app/client/cypress/e2e/Regression/ClientSide/BugTests/Bug25982_Spec.ts diff --git a/app/client/cypress/e2e/Regression/ClientSide/BugTests/Bug25982_Spec.ts b/app/client/cypress/e2e/Regression/ClientSide/BugTests/Bug25982_Spec.ts new file mode 100644 index 0000000000..522c9026d4 --- /dev/null +++ b/app/client/cypress/e2e/Regression/ClientSide/BugTests/Bug25982_Spec.ts @@ -0,0 +1,31 @@ +import { ObjectsRegistry } from "../../../../support/Objects/Registry"; + +const dataSources = ObjectsRegistry.DataSources, + agHelper = ObjectsRegistry.AggregateHelper, + ee = ObjectsRegistry.EntityExplorer; + +describe("Fix UQI query switching", function () { + it("The command of the query must be preserved and should not default to initial value after changed.", function () { + dataSources.NavigateToDSCreateNew(); + dataSources.CreateDataSource("Mongo", false, false); + dataSources.CreateQueryAfterDSSaved("", "MongoQuery"); + dataSources.ValidateNSelectDropdown( + "Commands", + "Find document(s)", + "Insert document(s)", + ); + dataSources.NavigateToDSCreateNew(); + dataSources.CreateDataSource("S3", false, false); + dataSources.CreateQueryAfterDSSaved("", "S3Query"); + dataSources.ValidateNSelectDropdown( + "Commands", + "List files in bucket", + "Create a new file", + ); + ee.SelectEntityByName("MongoQuery", "Queries/JS"); + dataSources.ValidateNSelectDropdown("Commands", "Insert document(s)"); + + ee.SelectEntityByName("S3Query", "Queries/JS"); + dataSources.ValidateNSelectDropdown("Commands", "Create a new file"); + }); +}); diff --git a/app/client/src/components/formControls/DropDownControl.tsx b/app/client/src/components/formControls/DropDownControl.tsx index 0abdb5cb4f..878433e544 100644 --- a/app/client/src/components/formControls/DropDownControl.tsx +++ b/app/client/src/components/formControls/DropDownControl.tsx @@ -201,13 +201,8 @@ function renderDropdown( }); if (selectedValue !== tempSelectedValues) { - // when pre-selected value is not found in dropdown options, - // initializing dropdown to initial value instead of blank - const tempValues = !isNil(props?.initialValue) - ? (props.initialValue as string[]) - : tempSelectedValues; - selectedValue = tempValues; - props.input?.onChange(tempValues); + selectedValue = tempSelectedValues; + props.input?.onChange(tempSelectedValues); } const isOptionDynamic = options.some((opt) => "disabled" in opt); From 7c54e9ecc67861083ffbeb6ab7dc6dc9afe09fae Mon Sep 17 00:00:00 2001 From: Rajat Agrawal Date: Wed, 9 Aug 2023 20:49:00 +0530 Subject: [PATCH 2/2] hotfix: Add an optional data check around series data (#26207) --- .../src/widgets/ChartWidget/widget/index.test.ts | 12 ++++++++++++ app/client/src/widgets/ChartWidget/widget/index.tsx | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/client/src/widgets/ChartWidget/widget/index.test.ts b/app/client/src/widgets/ChartWidget/widget/index.test.ts index 15f6d34610..a3651be668 100644 --- a/app/client/src/widgets/ChartWidget/widget/index.test.ts +++ b/app/client/src/widgets/ChartWidget/widget/index.test.ts @@ -73,6 +73,18 @@ describe("emptyChartData", () => { props.chartData.seriesID1 = { data: [] }; expect(emptyChartData(props)).toEqual(false); }); + + it("returns true if chart data isn't present", () => { + const props = JSON.parse(JSON.stringify(defaultProps)); + props.chartType = "LINE_CHART"; + props.chartData = null; + expect(emptyChartData(props)).toEqual(true); + + props.chartData = { + seriesID1: {}, + }; + expect(emptyChartData(props)).toEqual(true); + }); }); describe("when chart type is custom fusion charts", () => { diff --git a/app/client/src/widgets/ChartWidget/widget/index.tsx b/app/client/src/widgets/ChartWidget/widget/index.tsx index aecade7085..408ea2ab35 100644 --- a/app/client/src/widgets/ChartWidget/widget/index.tsx +++ b/app/client/src/widgets/ChartWidget/widget/index.tsx @@ -31,7 +31,7 @@ export const emptyChartData = (props: ChartWidgetProps) => { } } else { for (const seriesID in props.chartData) { - if (props.chartData[seriesID].data.length > 0) { + if (props.chartData[seriesID].data?.length > 0) { return false; } }