PromucFlow_constructor/app/client/src/entities/Engine/AppViewerEngine.ts
Vemparala Surya Vamsi 8bb61d996a
chore: reverted consolidated api (#30314)
## Description
Reverted consolidated api changes and also some CE related changes to
make it compatible with EE.
#### PR fixes following issue(s)
Reverts  #29650 & #29939

#### Type of change

- Chore (housekeeping or task changes that don't impact user perception)
>
>
>
## Testing
#### How Has This Been Tested?
- [ ] Manual
- [ ] JUnit
- [ ] Jest
- [x ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed


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

## Summary by CodeRabbit

- **Refactor**
- Enhanced the reliability and efficiency of Cypress e2e tests by
adjusting wait conditions and assertions.
	- Simplified network request handling across various test cases.
- Updated test logic to align with changes in application data structure
and network requests.

- **Tests**
- Improved test stability for application import/export, Git sync, page
load behavior, and widget interactions.
- Refined mobile responsiveness tests to accurately validate layout
conversions and autofill behaviors.

- **Chores**
- Removed deprecated feature flags and code related to consolidated page
load functionality.
- Cleaned up unused parameters and simplified action payloads in Redux
actions.

- **Documentation**
	- Updated comments for clarity in test specifications.

- **Style**
	- Adjusted code styling for consistency across test suites.

- **Bug Fixes**
- Fixed data retrieval logic in tests to ensure correct data extraction
from API responses.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-01-16 10:16:48 +05:30

126 lines
3.9 KiB
TypeScript

import {
fetchAllPageEntityCompletion,
setupPublishedPage,
} from "actions/pageActions";
import {
executePageLoadActions,
fetchActionsForView,
} from "actions/pluginActionActions";
import {
ReduxActionErrorTypes,
ReduxActionTypes,
} from "@appsmith/constants/ReduxActionConstants";
import type { APP_MODE } from "entities/App";
import { call, put, spawn } from "redux-saga/effects";
import {
failFastApiCalls,
reportSWStatus,
waitForWidgetConfigBuild,
} from "sagas/InitSagas";
import PerformanceTracker, {
PerformanceTransactionName,
} from "utils/PerformanceTracker";
import type { AppEnginePayload } from ".";
import AppEngine, { ActionsNotFoundError } from ".";
import { fetchJSLibraries } from "actions/JSLibraryActions";
import {
waitForSegmentInit,
waitForFetchUserSuccess,
} from "@appsmith/sagas/userSagas";
import { waitForFetchEnvironments } from "@appsmith/sagas/EnvironmentSagas";
import { fetchJSCollectionsForView } from "actions/jsActionActions";
import {
fetchAppThemesAction,
fetchSelectedAppThemeAction,
} from "actions/appThemingActions";
export default class AppViewerEngine extends AppEngine {
constructor(mode: APP_MODE) {
super(mode);
this.setupEngine = this.setupEngine.bind(this);
this.loadAppData = this.loadAppData.bind(this);
this.loadAppURL = this.loadAppURL.bind(this);
this.loadAppEntities = this.loadAppEntities.bind(this);
this.loadGit = this.loadGit.bind(this);
this.completeChore = this.completeChore.bind(this);
}
*loadGit() {
return;
}
*completeChore() {
yield call(waitForWidgetConfigBuild);
yield put({
type: ReduxActionTypes.INITIALIZE_PAGE_VIEWER_SUCCESS,
});
if ("serviceWorker" in navigator) {
yield put({
type: ReduxActionTypes.FETCH_ALL_PUBLISHED_PAGES,
});
}
yield spawn(reportSWStatus);
}
*setupEngine(payload: AppEnginePayload) {
yield call(super.setupEngine.bind(this), payload);
}
startPerformanceTracking() {
PerformanceTracker.startAsyncTracking(
PerformanceTransactionName.INIT_VIEW_APP,
);
}
stopPerformanceTracking() {
PerformanceTracker.stopAsyncTracking(
PerformanceTransactionName.INIT_VIEW_APP,
);
}
*loadAppEntities(toLoadPageId: string, applicationId: string): any {
const initActionsCalls: any = [
fetchActionsForView({ applicationId }),
fetchJSCollectionsForView({ applicationId }),
fetchSelectedAppThemeAction(applicationId),
fetchAppThemesAction(applicationId),
setupPublishedPage(toLoadPageId, true, true),
];
const successActionEffects = [
ReduxActionTypes.FETCH_ACTIONS_VIEW_MODE_SUCCESS,
ReduxActionTypes.FETCH_JS_ACTIONS_VIEW_MODE_SUCCESS,
ReduxActionTypes.FETCH_APP_THEMES_SUCCESS,
ReduxActionTypes.FETCH_SELECTED_APP_THEME_SUCCESS,
ReduxActionTypes.SETUP_PUBLISHED_PAGE_SUCCESS,
];
const failureActionEffects = [
ReduxActionErrorTypes.FETCH_ACTIONS_VIEW_MODE_ERROR,
ReduxActionErrorTypes.FETCH_JS_ACTIONS_VIEW_MODE_ERROR,
ReduxActionErrorTypes.FETCH_APP_THEMES_ERROR,
ReduxActionErrorTypes.FETCH_SELECTED_APP_THEME_ERROR,
ReduxActionErrorTypes.SETUP_PUBLISHED_PAGE_ERROR,
];
initActionsCalls.push(fetchJSLibraries(applicationId));
successActionEffects.push(ReduxActionTypes.FETCH_JS_LIBRARIES_SUCCESS);
failureActionEffects.push(ReduxActionErrorTypes.FETCH_JS_LIBRARIES_FAILED);
const resultOfPrimaryCalls: boolean = yield failFastApiCalls(
initActionsCalls,
successActionEffects,
failureActionEffects,
);
if (!resultOfPrimaryCalls)
throw new ActionsNotFoundError(
`Unable to fetch actions for the application: ${applicationId}`,
);
yield call(waitForFetchUserSuccess);
yield call(waitForSegmentInit, true);
yield call(waitForFetchEnvironments);
yield put(fetchAllPageEntityCompletion([executePageLoadActions()]));
}
}