From c85a59214003b3814c2eee7d4b212f4ffdaf57ef Mon Sep 17 00:00:00 2001 From: PrasadMadine Date: Mon, 14 Oct 2024 16:37:11 +0530 Subject: [PATCH] fix: bug run button not disabled in response pane --- .../QueryEditor/QueryResponseTab.test.tsx | 29 ++++++++++++++++++- .../Editor/QueryEditor/QueryResponseTab.tsx | 3 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.test.tsx b/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.test.tsx index 2ddca2cbc9bf..33141b35f1a2 100644 --- a/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.test.tsx +++ b/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.test.tsx @@ -1,5 +1,6 @@ import React from "react"; -import { render } from "@testing-library/react"; +import { render, screen } from "@testing-library/react"; +import '@testing-library/jest-dom/extend-expect'; import { Provider } from "react-redux"; import configureStore from "redux-mock-store"; import QueryResponseTab from "./QueryResponseTab"; @@ -194,4 +195,30 @@ describe("QueryResponseTab", () => { container.querySelector("[data-testid='t--prepared-statement-warning']"), ).toBeNull(); }); + it("6. Check if run button is disabled when query is empty", () => { + const propsWithEmptyQuery = { + ...defaultProps, + isRunDisabled: true, + currentActionConfig: { + ...defaultProps.currentActionConfig, + actionConfiguration: { + ...defaultProps.currentActionConfig.actionConfiguration, + body: "", + }, + }, + }; + + render( + + + + + + + , + ); + + const runButton = screen.getByRole('button'); + expect(runButton).toBeDisabled(); + }); }); diff --git a/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx b/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx index fa73e1ae1ef2..27d741fb550b 100644 --- a/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx +++ b/app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx @@ -96,6 +96,7 @@ const QueryResponseTab = (props: Props) => { isFeatureEnabled, currentActionConfig?.userPermissions, ); + const isQueryEmpty = !currentActionConfig?.actionConfiguration?.body; const actionResponse = useSelector((state) => getActionData(state, currentActionConfig.id), @@ -345,7 +346,7 @@ const QueryResponseTab = (props: Props) => { )} {!output && !error && (