## Description - This PR re-writes the entire Text_With_Different_Size_spec.ts spec to fix the master run flakyness and and improves the overall complexity of the test case format - cypress/e2e/Regression/ClientSide/Onboarding/StartFromScratch_spec.ts (agHelper.VisitNAssert improved) - Master runs pass at [Run1](https://github.com/appsmithorg/appsmith-ee/pull/3337#issuecomment-1899183181), [Run2](https://github.com/appsmithorg/appsmith-ee/pull/3337#issuecomment-1899197871) - cypress/e2e/Regression/ClientSide/BugTests/AbortAction_Spec.ts (1st test - replace with TED url) - getConsolidatedDataApi() separated, created new agHelper.CypressReload() - Removed cy.log statements from few places - homePage.LogOutviaAPI() removed static wait - Replaced homePage.LogOutviaAPI(); with homePage.Signout(); in places where its flaky - Split /Onboarding/StartFromScratch_spec.ts to 3 specs to reduce flakyness - Split /ClientSide/PartialImportExport/PartialExport_Widgets_spec.ts with failing test to run the other tests in CI - /Templates/Fork_Template_To_App_spec.ts - Added dynamic check to fix CI flakiness - agHelper.AssertURL(), assertHelper.AssertDocumentReady() improved - jsEditor.NavigateToNewJSEditor() improved - cypress/e2e/Regression/ClientSide/ExplorerTests/JSEditorContextMenu_Spec.ts - jsEditor.ValidateDefaultJSObjProperties improved - cypress/e2e/Regression/ServerSide/OnLoadTests/OnLoadActions_Spec.ts - (3rd case - flaky fix) #### Type of change - Script fix (non-breaking change which fixes an issue) ## Testing #### How Has This Been Tested? - [X] Cypress CI runs ## Checklist: #### QA activity: - [X] Added `Test Plan Approved` label after changes were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **Tests** - Enhanced test flexibility by dynamically constructing API URLs. - Improved test setup and flow in onboarding and regression suites. - Added new test spec files for dynamic height, onboarding, bug tests, login failure, and starting from scratch scenarios. - **Refactor** - Updated function calls and parameters across various test files for consistency and efficiency. - Removed redundant code and streamlined test actions. - **Chores** - Updated intercepted HTTP methods and added new utility functions to support test operations. - **Bug Fixes** - Fixed issues related to element visibility assertions in test scripts. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
117 lines
3.5 KiB
TypeScript
117 lines
3.5 KiB
TypeScript
import { LICENSE_FEATURE_FLAGS } from "../Constants";
|
|
import { ObjectsRegistry } from "./Registry";
|
|
import produce from "immer";
|
|
|
|
export const featureFlagIntercept = (
|
|
flags: Record<string, boolean> = {},
|
|
reload = true,
|
|
) => {
|
|
getConsolidatedDataApi(flags, false);
|
|
const response = {
|
|
responseMeta: {
|
|
status: 200,
|
|
success: true,
|
|
},
|
|
data: {
|
|
...flags,
|
|
release_app_sidebar_enabled: true,
|
|
release_show_new_sidebar_pages_pane_enabled: true,
|
|
rollout_consolidated_page_load_fetch_enabled: true,
|
|
},
|
|
errorDisplay: "",
|
|
};
|
|
cy.intercept("GET", "/api/v1/users/features", response);
|
|
|
|
if (reload) ObjectsRegistry.AggregateHelper.CypressReload();
|
|
};
|
|
|
|
export const getConsolidatedDataApi = (
|
|
flags: Record<string, boolean> = {},
|
|
reload = true,
|
|
) => {
|
|
cy.intercept("GET", "/api/v1/consolidated-api/*?*", (req) => {
|
|
req.reply((res: any) => {
|
|
if (
|
|
res.statusCode === 200 ||
|
|
res.statusCode === 401 ||
|
|
res.statusCode === 500
|
|
) {
|
|
const originalResponse = res?.body;
|
|
const updatedResponse = produce(originalResponse, (draft: any) => {
|
|
draft.data.featureFlags.data = { ...flags };
|
|
draft.data.featureFlags.data["release_app_sidebar_enabled"] = true;
|
|
draft.data.featureFlags.data[
|
|
"release_show_new_sidebar_pages_pane_enabled"
|
|
] = true;
|
|
draft.data.featureFlags.data[
|
|
"rollout_consolidated_page_load_fetch_enabled"
|
|
] = true;
|
|
});
|
|
return res.send(updatedResponse);
|
|
}
|
|
});
|
|
}).as("getConsolidatedData");
|
|
if (reload) ObjectsRegistry.AggregateHelper.CypressReload();
|
|
};
|
|
|
|
export const featureFlagInterceptForLicenseFlags = () => {
|
|
cy.intercept(
|
|
{
|
|
method: "GET",
|
|
url: "/api/v1/users/features",
|
|
},
|
|
(req) => {
|
|
req.reply((res) => {
|
|
if (res) {
|
|
const originalResponse = res.body;
|
|
let modifiedResponse: any = {};
|
|
Object.keys(originalResponse.data).forEach((flag) => {
|
|
if (LICENSE_FEATURE_FLAGS.includes(flag)) {
|
|
modifiedResponse[flag] = originalResponse.data[flag];
|
|
}
|
|
});
|
|
modifiedResponse = {
|
|
...modifiedResponse,
|
|
release_app_sidebar_enabled: true,
|
|
rollout_consolidated_page_load_fetch_enabled: true,
|
|
};
|
|
res.send({
|
|
responseMeta: {
|
|
status: 200,
|
|
success: true,
|
|
},
|
|
data: { ...modifiedResponse },
|
|
errorDisplay: "",
|
|
});
|
|
}
|
|
});
|
|
},
|
|
).as("getLicenseFeatures");
|
|
|
|
cy.intercept("GET", "/api/v1/consolidated-api/*?*", (req) => {
|
|
req.reply((res: any) => {
|
|
if (res.statusCode === 200) {
|
|
const originalResponse = res?.body;
|
|
const updatedResponse = produce(originalResponse, (draft: any) => {
|
|
draft.data.featureFlags.data = {};
|
|
Object.keys(originalResponse.data.featureFlags.data).forEach(
|
|
(flag) => {
|
|
if (LICENSE_FEATURE_FLAGS.includes(flag)) {
|
|
draft.data.featureFlags.data[flag] =
|
|
originalResponse.data.featureFlags.data[flag];
|
|
}
|
|
},
|
|
);
|
|
draft.data.featureFlags.data["release_app_sidebar_enabled"] = true;
|
|
draft.data.featureFlags.data[
|
|
"rollout_consolidated_page_load_fetch_enabled"
|
|
] = true;
|
|
});
|
|
return res.send(updatedResponse);
|
|
}
|
|
});
|
|
}).as("getConsolidatedData");
|
|
|
|
ObjectsRegistry.AggregateHelper.CypressReload();
|
|
};
|