PromucFlow_constructor/app/client/src/reducers/entityReducers/metaReducer/metaReducer.test.ts

129 lines
3.3 KiB
TypeScript
Raw Normal View History

import metaReducer, { initialState } from "./index";
import { updateMetaState } from "actions/metaActions";
import type { ReduxAction } from "ee/constants/ReduxActionConstants";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
let currentMetaState = initialState;
const inputWidget = {
widgetId: "incwlne",
propertyName: "selectedValues",
propertyValue: ["GREEN", "BLUE", "YELLOW"],
};
const noAction = (): ReduxAction<unknown> => {
return {
type: "NO_ACTION",
payload: {},
};
};
test("should return the initial state", () => {
expect(metaReducer(undefined, noAction())).toEqual(currentMetaState);
});
test("Add a widget meta values", () => {
currentMetaState = initialState;
expect(
metaReducer(currentMetaState, {
type: ReduxActionTypes.SET_META_PROP,
payload: {
widgetId: inputWidget.widgetId,
propertyName: inputWidget.propertyName,
propertyValue: inputWidget.propertyValue,
},
}),
).toEqual({
incwlne: {
selectedValues: ["GREEN", "BLUE", "YELLOW"],
},
});
});
test("Update widget meta state using evalMetaUpdates", () => {
const evalMetaUpdates = [
{ widgetId: "incwlne", metaPropertyPath: ["text"], value: "test123" },
{
widgetId: "incwlne",
metaPropertyPath: ["selectedValues"],
value: ["YELLOW"],
},
];
chore: add blank line eslint rule (#36369) ## Description Added ESLint rule to force blank lines between statements. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > 🔴 🔴 🔴 Some tests have failed. > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10924926728> > Commit: 34f57714a1575ee04e94e03cbcaf95e57a96c86c > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10924926728&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail" target="_blank">Cypress dashboard</a>. > Tags: @tag.All > Spec: > The following are new failures, please fix them before merging the PR: <ol> > <li>cypress/e2e/Regression/ClientSide/Anvil/AnvilModal_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCheckboxGroupWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCurrencyInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilIconButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInlineButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilParagraphWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilPhoneInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilStatsWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchGroupWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilToolbarButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilZoneSectionWidgetSnapshot_spec.ts</ol> > <a href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master" target="_blank">List of identified flaky tests</a>. > <hr>Wed, 18 Sep 2024 16:33:36 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No --------- Co-authored-by: Valera Melnikov <valera@appsmith.com>
2024-09-18 16:35:28 +00:00
currentMetaState = metaReducer(
currentMetaState,
updateMetaState(evalMetaUpdates),
);
expect(currentMetaState).toEqual({
incwlne: {
text: "test123",
selectedValues: ["YELLOW"],
},
});
});
describe("Reset widget meta action", () => {
test("Reset widget with only widgetId", () => {
currentMetaState = metaReducer(currentMetaState, {
type: ReduxActionTypes.RESET_WIDGET_META,
payload: {
widgetId: inputWidget.widgetId,
},
});
expect(currentMetaState).toEqual({
incwlne: {},
});
});
currentMetaState = initialState;
expect(
metaReducer(currentMetaState, {
type: ReduxActionTypes.SET_META_PROP,
payload: {
widgetId: inputWidget.widgetId,
propertyName: inputWidget.propertyName,
propertyValue: inputWidget.propertyValue,
},
}),
).toEqual({
incwlne: {
selectedValues: ["GREEN", "BLUE", "YELLOW"],
},
});
test("Reset widget with evaluated values", () => {
expect(
metaReducer(currentMetaState, {
type: ReduxActionTypes.RESET_WIDGET_META,
payload: {
widgetId: inputWidget.widgetId,
evaluatedWidget: {
defaultSelectedValues: ["GREEN"],
selectedValues: ["GREEN", "BLUE", "YELLOW"],
widgetId: inputWidget.widgetId,
propertyOverrideDependency: {
selectedValues: {
DEFAULT: "defaultSelectedValues",
META: "meta.selectedValues",
},
},
},
fix: Improving performance of JS evaluations by splitting the data tree (#21547) ## Description This is the second phase of the split data tree. In the previous version, we collected all config paths in each entity and put them in the `__config__` property. All those config properties do get inserted into final data tree which we don't need at all. As part of this change, we will be creating another tree i.e **'configTree'** which will contain all config of each entity. unEvalTree is split into 2 trees => 1. unEvalTree 2. configTree Example: previous unEvalTree Api1 content <img width="1766" alt="image" src="https://user-images.githubusercontent.com/7846888/215990868-0b095421-e7b8-44bc-89aa-065b35e237d6.png"> After this change unEvalTree Api1 content <img width="1758" alt="image" src="https://user-images.githubusercontent.com/7846888/215991045-506fb10a-645a-4aad-8e77-0f3786a86977.png"> Note- above example doesn't have '__config__' property configTree Api1 content <img width="1760" alt="image" src="https://user-images.githubusercontent.com/7846888/215991169-a2e03443-5d6a-4ff1-97c5-a12593e46395.png"> ## Type of change - Chore (housekeeping or task changes that don't impact user perception) - #11351 ## How Has This Been Tested? - Manual - Jest - 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: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2023-03-20 11:04:02 +00:00
evaluatedWidgetConfig: {
widgetId: inputWidget.widgetId,
propertyOverrideDependency: {
selectedValues: {
DEFAULT: "defaultSelectedValues",
META: "meta.selectedValues",
},
},
},
},
}),
).toEqual({
incwlne: {
selectedValues: ["GREEN"],
},
});
});
});