PromucFlow_constructor/app/client/cypress/support/Objects/FeatureFlags.ts
Vemparala Surya Vamsi 96701c343d
feat: Frontend changes for consolidated-api (#29933)
## Description
Our objective in this pr is to improve the page load time of our
application by calling a consolidated-api which contains all the
resources to load our pages. This PR contains all the client side
changes to call the consolidated-api as well as feature flag related
changes.
Fixes #29650 & #29939
#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## Testing
>
#### How Has This Been Tested?
- [x] 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
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] 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**
- Updated network request aliases and response handling in end-to-end
tests.
- **New Features**
- Introduced a new API class `ConsolidatedPageLoadApi` for fetching
consolidated page load data.
- **Tests**
	- Enhanced testing for application URL navigation and data retrieval.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-01-15 10:00:29 +05:30

45 lines
1.3 KiB
TypeScript

import produce from "immer";
export const featureFlagIntercept = (
flags: Record<string, boolean> = {},
reload = true,
) => {
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);
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 = { ...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) {
cy.reload();
cy.wait(2000); //for the page to re-load finish for CI runs
}
};