PromucFlow_constructor/app/client/cypress/support/Objects/FeatureFlags.ts
Sagar Khalasi 445880f5a5
chore: Remove dependancy (#39389)
## Description
Remove immer library


Fixes #
https://theappsmith.slack.com/archives/C0134BAVDB4/p1740028929478969?thread_ts=1738822154.732719&cid=C0134BAVDB4

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13455561224>
> Commit: f695cd9f06e06c23a2a6ead401149045f2ac4bec
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13455561224&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Fri, 21 Feb 2025 12:20:17 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


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

- **Chores**
	- Refined error logging for improved troubleshooting clarity.
	- Removed an unnecessary dependency to streamline project maintenance.
- Updated state management implementation in the reducer for enhanced
performance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Vemparala Surya Vamsi <vamsi@appsmith.com>
2025-03-12 03:49:02 +00:00

110 lines
3.2 KiB
TypeScript

import { LICENSE_FEATURE_FLAGS } from "../Constants";
import { ObjectsRegistry } from "./Registry";
const defaultFlags = {
rollout_remove_feature_walkthrough_enabled: false, // remove this flag from here when it's removed from code
release_git_modularisation_enabled: true,
};
export const featureFlagIntercept = (
flags: Record<string, boolean> = {},
reload = true,
) => {
getConsolidatedDataApi({ ...flags, ...defaultFlags }, false);
const response = {
responseMeta: {
status: 200,
success: true,
},
data: {
...flags,
...defaultFlags,
},
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) => {
delete req.headers["if-none-match"];
req.reply((res: any) => {
if (
res.statusCode === 200 ||
res.statusCode === 401 ||
res.statusCode === 500
) {
const originalResponse = res?.body;
try {
const updatedResponse = JSON.parse(JSON.stringify(originalResponse));
updatedResponse.data.featureFlags.data = { ...flags };
return res.send(updatedResponse);
} catch (e) {
cy.log(`Featureflags.ts error `, e);
}
}
});
}).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,
};
res.send({
responseMeta: {
status: 200,
success: true,
},
data: { ...modifiedResponse },
errorDisplay: "",
});
}
});
},
).as("getLicenseFeatures");
cy.intercept("GET", "/api/v1/consolidated-api/*?*", (req) => {
req.reply((res: any) => {
delete req.headers["if-none-match"];
if (res.statusCode === 200) {
const originalResponse = res?.body;
const updatedResponse = JSON.parse(JSON.stringify(originalResponse));
updatedResponse.data.featureFlags.data = {};
Object.keys(originalResponse.data.featureFlags.data).forEach((flag) => {
if (LICENSE_FEATURE_FLAGS.includes(flag)) {
updatedResponse.data.featureFlags.data[flag] =
originalResponse.data.featureFlags.data[flag];
}
});
updatedResponse.data.featureFlags.data["release_app_sidebar_enabled"] =
true;
return res.send(updatedResponse);
}
});
}).as("getConsolidatedData");
ObjectsRegistry.AggregateHelper.CypressReload();
};