PromucFlow_constructor/app/client/src/components/editorComponents/ApiResponseView.test.tsx
Hetu Nandu ac41ad250b
chore: Move entities/IDE/constants (#39064)
## Description

Remove the IDE constants from the entities folder and move it to the
common IDE folder
Create separate buttons exports for sidebar buttons
Update the button usages 

Fixes #39050 

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13191919670>
> Commit: 5055b6ed0394b5f3fe1450bd7a042eb851fe39ab
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13191919670&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Fri, 07 Feb 2025 05:19:56 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced new editor state definitions and enhanced sidebar
configurations with conditional messaging for data source availability.

- **Refactor**
- Reorganized internal module structures and consolidated type
definitions to improve maintainability, consistency, and type safety.

- **Tests**
  - Updated test references to align with the new module organization.

These changes streamline the codebase and lay the groundwork for future
improvements while maintaining the existing end-user experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2025-02-07 16:45:55 +05:30

104 lines
2.5 KiB
TypeScript

import React from "react";
import { render } from "@testing-library/react";
import ApiResponseView from "./ApiResponseView";
import configureStore from "redux-mock-store";
import { Provider } from "react-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 "IDE/Interfaces/EditorTypes";
import "@testing-library/jest-dom/extend-expect";
import { APIFactory } from "test/factories/Actions/API";
import { noop } from "lodash";
jest.mock("./EntityBottomTabs", () => ({
__esModule: true,
default: () => <div />,
}));
jest.mock("selectors/gitModSelectors", () => ({
selectCombinedPreviewMode: jest.fn(() => false),
}));
const mockStore = configureStore([]);
const storeState = {
...unitTestBaseMockStore,
evaluations: {
tree: {},
},
ui: {
...unitTestBaseMockStore.ui,
gitSync: {
branches: [],
fetchingBranches: false,
isDeploying: false,
protectedBranchesLoading: false,
protectedBranches: [],
},
editor: {
isPreviewMode: false,
},
users: {
featureFlag: {
data: {},
overriddenFlags: {},
},
},
ide: {
view: EditorViewMode.FullScreen,
},
debugger: {
context: {
errorCount: 0,
},
},
pluginActionEditor: {
debugger: {
open: true,
responseTabHeight: 200,
selectedTab: "response",
},
},
},
};
describe("ApiResponseView", () => {
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let store: any;
beforeEach(() => {
store = mockStore(storeState);
});
it("the container should have class select-text to enable the selection of text for user", () => {
const Api1 = APIFactory.build({
id: "api_id",
baseId: "api_base_id",
pageId: "pageId",
});
const { container } = render(
<Provider store={store}>
<ThemeProvider theme={lightTheme}>
<Router>
<ApiResponseView
currentActionConfig={Api1}
isRunDisabled={false}
isRunning={false}
onRunClick={noop}
/>
</Router>
</ThemeProvider>
</Provider>,
);
expect(
container
.querySelector(".t--ide-bottom-view")
?.classList.contains("select-text"),
).toBe(true);
});
});