Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug run button not disabled in response pane #36864

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(
<Provider store={store}>
<ThemeProvider theme={lightTheme}>
<Router>
<QueryResponseTab {...propsWithEmptyQuery} />
</Router>
</ThemeProvider>
</Provider>,
);

const runButton = screen.getByRole('button');
expect(runButton).toBeDisabled();
});
});
3 changes: 2 additions & 1 deletion app/client/src/pages/Editor/QueryEditor/QueryResponseTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const QueryResponseTab = (props: Props) => {
isFeatureEnabled,
currentActionConfig?.userPermissions,
);
const isQueryEmpty = !currentActionConfig?.actionConfiguration?.body;

const actionResponse = useSelector((state) =>
getActionData(state, currentActionConfig.id),
Expand Down Expand Up @@ -345,7 +346,7 @@ const QueryResponseTab = (props: Props) => {
)}
{!output && !error && (
<NoResponse
isRunDisabled={!isExecutePermitted}
isRunDisabled={!isExecutePermitted || isQueryEmpty}
isRunning={isRunning}
onRunClick={responseTabOnRunClick}
/>
Expand Down