## 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 -->
110 lines
3.8 KiB
TypeScript
110 lines
3.8 KiB
TypeScript
import { fetchApplication } from "@appsmith/actions/applicationActions";
|
|
import { setAppMode, updateAppStore } from "actions/pageActions";
|
|
import type { ApplicationPayload } from "@appsmith/constants/ReduxActionConstants";
|
|
import {
|
|
ReduxActionErrorTypes,
|
|
ReduxActionTypes,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import { getPersistentAppStore } from "constants/AppConstants";
|
|
import type { APP_MODE } from "entities/App";
|
|
import log from "loglevel";
|
|
import { call, put, select } from "redux-saga/effects";
|
|
import { failFastApiCalls } from "sagas/InitSagas";
|
|
import { getDefaultPageId } from "sagas/selectors";
|
|
import { getCurrentApplication } from "@appsmith/selectors/applicationSelectors";
|
|
import history from "utils/history";
|
|
import type URLRedirect from "entities/URLRedirect/index";
|
|
import URLGeneratorFactory from "entities/URLRedirect/factory";
|
|
import { updateBranchLocally } from "actions/gitSyncActions";
|
|
import { getCurrentGitBranch } from "selectors/gitSyncSelectors";
|
|
|
|
export interface AppEnginePayload {
|
|
applicationId?: string;
|
|
pageId?: string;
|
|
branch?: string;
|
|
mode: APP_MODE;
|
|
}
|
|
|
|
export interface IAppEngine {
|
|
setupEngine(payload: AppEnginePayload): any;
|
|
loadAppData(payload: AppEnginePayload): any;
|
|
loadAppURL(pageId: string, pageIdInUrl?: string): any;
|
|
loadAppEntities(toLoadPageId: string, applicationId: string): any;
|
|
loadGit(applicationId: string): any;
|
|
completeChore(): any;
|
|
}
|
|
|
|
export class AppEngineApiError extends Error {}
|
|
export class PageNotFoundError extends AppEngineApiError {}
|
|
export class ActionsNotFoundError extends AppEngineApiError {}
|
|
export class PluginsNotFoundError extends AppEngineApiError {}
|
|
export class PluginFormConfigsNotFoundError extends AppEngineApiError {}
|
|
|
|
export default abstract class AppEngine {
|
|
private _mode: APP_MODE;
|
|
constructor(mode: APP_MODE) {
|
|
this._mode = mode;
|
|
this._urlRedirect = null;
|
|
}
|
|
private _urlRedirect: URLRedirect | null;
|
|
|
|
abstract loadAppEntities(toLoadPageId: string, applicationId: string): any;
|
|
abstract loadGit(applicationId: string): any;
|
|
abstract startPerformanceTracking(): any;
|
|
abstract stopPerformanceTracking(): any;
|
|
abstract completeChore(): any;
|
|
|
|
*loadAppData(payload: AppEnginePayload) {
|
|
const { applicationId, branch, pageId } = payload;
|
|
const apiCalls: boolean = yield failFastApiCalls(
|
|
[fetchApplication({ applicationId, pageId, mode: this._mode })],
|
|
[
|
|
ReduxActionTypes.FETCH_APPLICATION_SUCCESS,
|
|
ReduxActionTypes.FETCH_PAGE_LIST_SUCCESS,
|
|
],
|
|
[
|
|
ReduxActionErrorTypes.FETCH_APPLICATION_ERROR,
|
|
ReduxActionErrorTypes.FETCH_PAGE_LIST_ERROR,
|
|
],
|
|
);
|
|
if (!apiCalls)
|
|
throw new PageNotFoundError(`Cannot find page with id: ${pageId}`);
|
|
const application: ApplicationPayload = yield select(getCurrentApplication);
|
|
const currentGitBranch: ReturnType<typeof getCurrentGitBranch> =
|
|
yield select(getCurrentGitBranch);
|
|
yield put(
|
|
updateAppStore(
|
|
getPersistentAppStore(application.id, branch || currentGitBranch),
|
|
),
|
|
);
|
|
const toLoadPageId: string = pageId || (yield select(getDefaultPageId));
|
|
this._urlRedirect = URLGeneratorFactory.create(
|
|
application.applicationVersion,
|
|
this._mode,
|
|
);
|
|
return { toLoadPageId, applicationId: application.id };
|
|
}
|
|
|
|
*setupEngine(payload: AppEnginePayload): any {
|
|
const { branch } = payload;
|
|
yield put(updateBranchLocally(branch || ""));
|
|
yield put(setAppMode(this._mode));
|
|
yield put({ type: ReduxActionTypes.START_EVALUATION });
|
|
}
|
|
|
|
*loadAppURL(pageId: string, pageIdInUrl?: string) {
|
|
try {
|
|
if (!this._urlRedirect) return;
|
|
const newURL: string = yield call(
|
|
this._urlRedirect.generateRedirectURL.bind(this),
|
|
pageId,
|
|
pageIdInUrl,
|
|
);
|
|
if (!newURL) return;
|
|
history.replace(newURL);
|
|
} catch (e) {
|
|
log.error(e);
|
|
}
|
|
}
|
|
}
|