## Description Adds IDE rendering tests for JS routes Fixes #31867 ## 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/8431959142> > Commit: `ead16d0a5a8bb41003d7c75ae5a4f4fa648e3420` > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8431959142&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 - **Tests** - Introduced test cases for rendering JavaScript components in different states within the IDE. - **Chores** - Added mock data factories for JavaScript objects with actions, enhancing testing capabilities. - Updated factory utilities to support JavaScript actions in IDE test states. - Included a new entry for the JavaScript plugin in the mock plugins state configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
64 lines
1.6 KiB
TypeScript
64 lines
1.6 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";
|
|
import type { JSCollection } from "entities/JSCollection";
|
|
|
|
interface IDEStateArgs {
|
|
ideView?: EditorViewMode;
|
|
pages?: Page[];
|
|
actions?: Action[];
|
|
js?: JSCollection[];
|
|
tabs?: IDETabs;
|
|
}
|
|
|
|
export const getIDETestState = ({
|
|
actions = [],
|
|
ideView = EditorViewMode.FullScreen,
|
|
js = [],
|
|
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 }));
|
|
|
|
const jsData = js.map((a) => ({ isLoading: false, config: a }));
|
|
|
|
return {
|
|
...initialState,
|
|
entities: {
|
|
...initialState.entities,
|
|
plugins: MockPluginsState,
|
|
pageList: pageList,
|
|
actions: actionData,
|
|
jsActions: jsData,
|
|
},
|
|
ui: {
|
|
...initialState.ui,
|
|
ide: {
|
|
...initialState.ui.ide,
|
|
view: ideView,
|
|
tabs,
|
|
},
|
|
editor: {
|
|
...initialState.ui.editor,
|
|
initialized: true,
|
|
},
|
|
},
|
|
};
|
|
};
|