2024-03-21 11:22:36 +00:00
|
|
|
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";
|
2024-03-26 07:20:00 +00:00
|
|
|
import type { JSCollection } from "entities/JSCollection";
|
2024-03-27 12:00:31 +00:00
|
|
|
import type { FocusHistory } from "reducers/uiReducers/focusHistoryReducer";
|
2024-03-21 11:22:36 +00:00
|
|
|
|
|
|
|
|
interface IDEStateArgs {
|
|
|
|
|
ideView?: EditorViewMode;
|
|
|
|
|
pages?: Page[];
|
|
|
|
|
actions?: Action[];
|
2024-03-26 07:20:00 +00:00
|
|
|
js?: JSCollection[];
|
2024-03-21 11:22:36 +00:00
|
|
|
tabs?: IDETabs;
|
2024-03-27 03:39:37 +00:00
|
|
|
branch?: string;
|
2024-03-27 12:00:31 +00:00
|
|
|
focusHistory?: FocusHistory;
|
2024-03-21 11:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getIDETestState = ({
|
|
|
|
|
actions = [],
|
2024-03-27 03:39:37 +00:00
|
|
|
branch,
|
2024-03-27 12:00:31 +00:00
|
|
|
focusHistory = {},
|
2024-03-21 11:22:36 +00:00
|
|
|
ideView = EditorViewMode.FullScreen,
|
2024-03-26 07:20:00 +00:00
|
|
|
js = [],
|
2024-03-21 11:22:36 +00:00
|
|
|
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 }));
|
|
|
|
|
|
2024-03-26 07:20:00 +00:00
|
|
|
const jsData = js.map((a) => ({ isLoading: false, config: a }));
|
|
|
|
|
|
2024-03-21 11:22:36 +00:00
|
|
|
return {
|
|
|
|
|
...initialState,
|
|
|
|
|
entities: {
|
|
|
|
|
...initialState.entities,
|
|
|
|
|
plugins: MockPluginsState,
|
|
|
|
|
pageList: pageList,
|
|
|
|
|
actions: actionData,
|
2024-03-26 07:20:00 +00:00
|
|
|
jsActions: jsData,
|
2024-03-21 11:22:36 +00:00
|
|
|
},
|
|
|
|
|
ui: {
|
|
|
|
|
...initialState.ui,
|
|
|
|
|
ide: {
|
|
|
|
|
...initialState.ui.ide,
|
|
|
|
|
view: ideView,
|
|
|
|
|
tabs,
|
|
|
|
|
},
|
2024-03-27 12:00:31 +00:00
|
|
|
focusHistory: {
|
|
|
|
|
history: {
|
|
|
|
|
...focusHistory,
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-03-21 11:22:36 +00:00
|
|
|
editor: {
|
|
|
|
|
...initialState.ui.editor,
|
|
|
|
|
initialized: true,
|
|
|
|
|
},
|
2024-03-27 03:39:37 +00:00
|
|
|
applications: {
|
|
|
|
|
...initialState.ui.applications,
|
|
|
|
|
currentApplication: branch
|
|
|
|
|
? {
|
|
|
|
|
...initialState.ui.applications.currentApplication,
|
|
|
|
|
gitApplicationMetadata: {
|
|
|
|
|
branchName: branch || "",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: { ...initialState.ui.applications.currentApplication },
|
|
|
|
|
},
|
2024-03-21 11:22:36 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|