PromucFlow_constructor/app/client/test/factories/AppIDEFactoryUtils.ts
Hetu Nandu 77955a9229
chore: IDE query url render tests (#31919)
## Description

IDE rendering tests for Query routes


Fixes #31865  

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]  
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/8372729741>
> Commit: `32d0e14a69f0fef33904eab854b691112cdc6046`
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8372729741&attempt=1"
target="_blank">Click here!</a>
> All cypress tests have passed 🎉🎉🎉

<!-- end of auto-generated comment: Cypress test results  -->



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

## Summary by CodeRabbit

- **New Features**
- Enhanced accessibility by adding `aria-label` to close buttons in the
IDE.
- Improved testing capabilities with new `data-testid` attributes across
various components for better identification.
- **Tests**
- Introduced comprehensive test cases for IDE functionalities including
rendering states, adding queries/APIs, and handling different screen
modes.
- Added factories for creating mock actions and states for API, Google
Sheets, Postgres, and IDE testing.
- **Chores**
- Updated and added `data-testid` attributes for improved testability
and maintenance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-21 16:52:36 +05:30

58 lines
1.4 KiB
TypeScript

import store from "store";
import { EditorViewMode } from "@appsmith/entities/IDE/constants";
import type { AppState } from "@appsmith/reducers";
import MockPluginsState from "test/factories/MockPluginsState";
import type { Page } from "@appsmith/constants/ReduxActionConstants";
import type { Action } from "entities/Action";
import type { IDETabs } from "reducers/uiReducers/ideReducer";
import { IDETabsDefaultValue } from "reducers/uiReducers/ideReducer";
interface IDEStateArgs {
ideView?: EditorViewMode;
pages?: Page[];
actions?: Action[];
tabs?: IDETabs;
}
export const getIDETestState = ({
actions = [],
ideView = EditorViewMode.FullScreen,
pages = [],
tabs = IDETabsDefaultValue,
}: IDEStateArgs): AppState => {
const initialState = store.getState();
const pageList = {
pages,
isGeneratingTemplatePage: false,
applicationId: "655716e035e2c9432e4bd94b",
currentPageId: pages[0]?.pageId,
defaultPageId: pages[0]?.pageId,
loading: {},
};
const actionData = actions.map((a) => ({ isLoading: false, config: a }));
return {
...initialState,
entities: {
...initialState.entities,
plugins: MockPluginsState,
pageList: pageList,
actions: actionData,
},
ui: {
...initialState.ui,
ide: {
...initialState.ui.ide,
view: ideView,
tabs,
},
editor: {
...initialState.ui.editor,
initialized: true,
},
},
};
};