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

TESTING EXTERNAL SCRIPT: external merge request from Contributor #36534

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3d47dbc
fix:query response count on error in QueryDebuggerTabs
raushan3737 Aug 2, 2024
b586477
Merge branch 'release' of https://github.com/raushan3737/appsmith int…
raushan3737 Aug 14, 2024
20ba6f0
chore:remove space b/w form and CTA onboarding page
Shivam-z Aug 29, 2024
f3d043a
chore:added RadioButtonControl unit test case
Shivam-z Sep 5, 2024
230a8a7
fix/removed hardcoded height value and adjusted spacing
Shivam-z Sep 19, 2024
61fcaa2
Update JSONtoForm.tsx
Shivam-z Sep 20, 2024
105b64d
fix: change the result-text to data-testid from classname
raushan3737 Sep 25, 2024
b85eb6f
Merge remote-tracking branch 'external-raushan3737/fix/query-response…
AmanAgarwal041 Sep 25, 2024
7a5f577
Merge branch 'release' of https://github.com/raushan3737/appsmith int…
raushan3737 Sep 25, 2024
51cee7d
Merged the release code and fixed the conflicts
raushan3737 Sep 25, 2024
bff6a50
Merge branch 'fix/query-response-error-count' of https://github.com/r…
AmanAgarwal041 Sep 25, 2024
df6872f
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
AmanAgarwal041 Sep 25, 2024
8dcc55b
Merge branch 'release' of github.com:Shivam-z/appsmith into Task-#305…
Shivam-z Sep 26, 2024
0877299
Merge remote-tracking branch 'external-Shivam-z/Task-#30523/chore-rem…
AmanAgarwal041 Sep 26, 2024
e3215ac
fix: prettier issue
raushan3737 Sep 29, 2024
3584608
Merge branch 'fix/query-response-error-count' of https://github.com/r…
AmanAgarwal041 Sep 30, 2024
5f3b581
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
AmanAgarwal041 Sep 30, 2024
bd002db
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
AmanAgarwal041 Oct 1, 2024
834be71
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
AmanAgarwal041 Oct 2, 2024
b18b625
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
AmanAgarwal041 Oct 3, 2024
1dce9de
merge from release
AmanAgarwal041 Oct 14, 2024
0c75633
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
AmanAgarwal041 Oct 17, 2024
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
Expand Up @@ -115,4 +115,4 @@ describe("RadioButtonControl", () => {
expect(options[1]).toBeChecked();
expect(options[2]).not.toBeChecked();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function renderComponent(props: renderComponentProps) {
</StyledRadioGroup>
);
}

export interface RadioButtonControlProps extends ControlProps {
options: SelectOptionProps[];
}
Expand Down
1 change: 0 additions & 1 deletion app/client/src/pages/Editor/DataSourceEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ type Props = ReduxStateProps &
}>;

export const DSEditorWrapper = styled.div`
height: calc(100vh - ${(props) => props.theme.headerHeight});
overflow: hidden;
display: flex;
flex-direction: row;
Expand Down
92 changes: 87 additions & 5 deletions app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
import React from "react";
import { render } from "@testing-library/react";
import { render, screen } from "@testing-library/react";
import configureStore from "redux-mock-store";
import { Provider } from "react-redux";
import type { AnyAction, Store } from "redux";
import { ThemeProvider } from "styled-components";
import { unitTestBaseMockStore } from "layoutSystems/common/dropTarget/unitTestUtils";
import { lightTheme } from "selectors/themeSelectors";
import { BrowserRouter as Router } from "react-router-dom";
import { EditorViewMode } from "ee/entities/IDE/constants";
import "@testing-library/jest-dom/extend-expect";
import QueryDebuggerTabs from "./QueryDebuggerTabs";
import type { ActionResponse } from "api/ActionAPI";
import { ENTITY_TYPE } from "ee/entities/AppsmithConsole/utils";
import { EditorViewMode } from "ee/entities/IDE/constants";

const mockStore = configureStore([]);

const mockSuccessResponse: ActionResponse = {
body: ["Record 1", "Record 2"],
statusCode: "200",
dataTypes: [],
duration: "3000",
size: "200",
isExecutionSuccess: true,
headers: {
"Content-Type": ["application/json"],
"Cache-Control": ["no-cache"],
},
};

const mockFailedResponse: ActionResponse = {
body: [{ response: "Failed" }],
statusCode: "200",
dataTypes: [],
duration: "3000",
size: "200",
isExecutionSuccess: false,
headers: {
"Content-Type": ["application/json"],
"Cache-Control": ["no-cache"],
},
};

const storeState = {
...unitTestBaseMockStore,
evaluations: {
Expand Down Expand Up @@ -53,9 +81,7 @@ const storeState = {
};

describe("ApiResponseView", () => {
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let store: any;
let store: Store<any, AnyAction>;

beforeEach(() => {
store = mockStore(storeState);
Expand Down Expand Up @@ -87,4 +113,60 @@ describe("ApiResponseView", () => {
?.classList.contains("select-text"),
).toBe(true);
});

it("should show record count as result if the query response returns records", () => {
render(
<Provider store={store}>
<ThemeProvider theme={lightTheme}>
<Router>
<QueryDebuggerTabs
actionName="Query1"
actionResponse={mockSuccessResponse}
actionSource={{
id: "ID1",
name: "Query1",
type: ENTITY_TYPE.ACTION,
}}
isRunning={false}
onRunClick={() => {}}
/>
</Router>
</ThemeProvider>
</Provider>,
);

const expectedResultText = "Result: 2 Records";
const resultTextElement = screen.getByTestId("result-text");

expect(resultTextElement).toBeInTheDocument();
expect(resultTextElement?.textContent).toContain(expectedResultText);
});

it("should show error as result if the query response returns the error", () => {
render(
<Provider store={store}>
<ThemeProvider theme={lightTheme}>
<Router>
<QueryDebuggerTabs
actionName="Query1"
actionResponse={mockFailedResponse}
actionSource={{
id: "ID1",
name: "Query1",
type: ENTITY_TYPE.ACTION,
}}
isRunning={false}
onRunClick={() => {}}
/>
</Router>
</ThemeProvider>
</Provider>,
);

const expectedResultText = "Result: Error";
const resultTextElement = screen.getByTestId("result-text");

expect(resultTextElement).toBeInTheDocument();
expect(resultTextElement?.textContent).toContain(expectedResultText);
});
});
14 changes: 10 additions & 4 deletions app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,17 @@ function QueryDebuggerTabs({
>
{output && !!output.length && (
<ResultsCount>
<Text type={TextType.P3}>
<Text data-testid="result-text" type={TextType.P3}>
Result:
<Text type={TextType.H5}>{` ${output.length} Record${
output.length > 1 ? "s" : ""
}`}</Text>
{actionResponse?.isExecutionSuccess ? (
<Text type={TextType.H5}>{` ${output.length} Record${
output.length > 1 ? "s" : ""
}`}</Text>
) : (
<Text color="red" type={TextType.H5}>
{" Error"}
</Text>
)}
</Text>
</ResultsCount>
)}
Expand Down
Loading