## 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>
413 lines
10 KiB
TypeScript
413 lines
10 KiB
TypeScript
import type { DataTree } from "entities/DataTree/dataTreeFactory";
|
|
import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
|
|
import type { MetaWidgetsReduxState } from "reducers/entityReducers/metaWidgetsReducer";
|
|
import { buildChildWidgetTree } from "./widgetRenderUtils";
|
|
|
|
describe("test EditorUtils methods", () => {
|
|
describe("should test buildChildWidgetTree method", () => {
|
|
const metaWidgets = {
|
|
"1_meta": {
|
|
children: ["2_meta"],
|
|
type: "CANVAS",
|
|
widgetId: "1_meta",
|
|
parentId: "2",
|
|
topRow: 0,
|
|
bottomRow: 100,
|
|
widgetName: "meta_one",
|
|
},
|
|
"2_meta": {
|
|
children: [],
|
|
type: "INPUT_WIDGET",
|
|
widgetId: "2_meta",
|
|
parentId: "1_meta",
|
|
topRow: 0,
|
|
bottomRow: 10,
|
|
widgetName: "meta_two",
|
|
},
|
|
} as unknown as MetaWidgetsReduxState;
|
|
const canvasWidgets = {
|
|
"1": {
|
|
children: ["2"],
|
|
type: "FORM_WIDGET",
|
|
widgetId: "1",
|
|
parentId: "0",
|
|
topRow: 0,
|
|
bottomRow: 10,
|
|
widgetName: "one",
|
|
},
|
|
"2": {
|
|
children: ["3", "4", "1_meta"],
|
|
type: "CANVAS",
|
|
widgetId: "2",
|
|
parentId: "1",
|
|
topRow: 0,
|
|
bottomRow: 100,
|
|
widgetName: "two",
|
|
},
|
|
"3": {
|
|
children: [],
|
|
type: "TEXT",
|
|
widgetId: "3",
|
|
parentId: "2",
|
|
topRow: 4,
|
|
bottomRow: 5,
|
|
widgetName: "three",
|
|
},
|
|
"4": {
|
|
children: [],
|
|
type: "BUTTON",
|
|
widgetId: "4",
|
|
parentId: "2",
|
|
topRow: 6,
|
|
bottomRow: 18,
|
|
widgetName: "four",
|
|
},
|
|
} as unknown as CanvasWidgetsReduxState;
|
|
|
|
const dataTree = {
|
|
one: {
|
|
children: ["2"],
|
|
type: "FORM_WIDGET",
|
|
widgetId: "1",
|
|
parentId: "0",
|
|
topRow: 0,
|
|
bottomRow: 10,
|
|
widgetName: "one",
|
|
skipForFormWidget: "test",
|
|
value: "test",
|
|
isDirty: true,
|
|
isValid: true,
|
|
},
|
|
two: {
|
|
children: ["3", "4", "1_meta"],
|
|
type: "CANVAS",
|
|
widgetId: "2",
|
|
parentId: "1",
|
|
topRow: 0,
|
|
bottomRow: 100,
|
|
widgetName: "two",
|
|
skipForFormWidget: "test",
|
|
value: "test",
|
|
isDirty: true,
|
|
isValid: true,
|
|
},
|
|
three: {
|
|
children: [],
|
|
type: "TEXT",
|
|
widgetId: "3",
|
|
parentId: "2",
|
|
topRow: 4,
|
|
bottomRow: 5,
|
|
widgetName: "three",
|
|
skipForFormWidget: "test",
|
|
value: "test",
|
|
isDirty: true,
|
|
isValid: true,
|
|
},
|
|
four: {
|
|
children: [],
|
|
type: "BUTTON",
|
|
widgetId: "4",
|
|
parentId: "2",
|
|
topRow: 6,
|
|
bottomRow: 18,
|
|
widgetName: "four",
|
|
skipForFormWidget: "test",
|
|
value: "test",
|
|
isDirty: true,
|
|
isValid: true,
|
|
},
|
|
meta_one: {
|
|
skipForFormWidget: "test",
|
|
children: ["1_meta"],
|
|
type: "CANVAS",
|
|
widgetId: "1_meta",
|
|
parentId: "2",
|
|
topRow: 0,
|
|
bottomRow: 100,
|
|
widgetName: "meta_one",
|
|
},
|
|
meta_two: {
|
|
children: [],
|
|
type: "INPUT_WIDGET",
|
|
widgetId: "meta_two",
|
|
parentId: "meta_1",
|
|
topRow: 0,
|
|
bottomRow: 10,
|
|
widgetName: "two",
|
|
skipForFormWidget: "test",
|
|
value: "test",
|
|
isDirty: true,
|
|
isValid: true,
|
|
},
|
|
} as unknown as DataTree;
|
|
|
|
it("should return a complete childwidgets Tree", () => {
|
|
const childWidgetTree = [
|
|
{
|
|
bottomRow: 5,
|
|
children: [],
|
|
skipForFormWidget: "test",
|
|
isDirty: true,
|
|
isLoading: false,
|
|
isValid: true,
|
|
parentId: "2",
|
|
topRow: 4,
|
|
type: "TEXT",
|
|
value: "test",
|
|
widgetId: "3",
|
|
widgetName: "three",
|
|
},
|
|
{
|
|
bottomRow: 18,
|
|
children: [],
|
|
skipForFormWidget: "test",
|
|
isDirty: true,
|
|
isLoading: false,
|
|
isValid: true,
|
|
parentId: "2",
|
|
topRow: 6,
|
|
type: "BUTTON",
|
|
value: "test",
|
|
widgetId: "4",
|
|
widgetName: "four",
|
|
},
|
|
{
|
|
type: "CANVAS",
|
|
isLoading: false,
|
|
widgetId: "1_meta",
|
|
parentId: "2",
|
|
topRow: 0,
|
|
bottomRow: 100,
|
|
widgetName: "meta_one",
|
|
skipForFormWidget: "test",
|
|
children: [
|
|
{
|
|
isDirty: true,
|
|
isLoading: false,
|
|
isValid: true,
|
|
value: "test",
|
|
children: [],
|
|
type: "INPUT_WIDGET",
|
|
widgetId: "2_meta",
|
|
parentId: "1_meta",
|
|
topRow: 0,
|
|
bottomRow: 10,
|
|
widgetName: "meta_two",
|
|
skipForFormWidget: "test",
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
expect(
|
|
buildChildWidgetTree(
|
|
canvasWidgets,
|
|
metaWidgets,
|
|
dataTree,
|
|
new Set<string>("one"),
|
|
{},
|
|
"2",
|
|
),
|
|
).toEqual(childWidgetTree);
|
|
});
|
|
|
|
it("should return a partial childwidgets Tree with properties specified", () => {
|
|
const childWidgetTree = [
|
|
{
|
|
bottomRow: 100,
|
|
children: [
|
|
{
|
|
bottomRow: 5,
|
|
children: [],
|
|
isDirty: true,
|
|
isLoading: false,
|
|
isValid: true,
|
|
parentId: "2",
|
|
topRow: 4,
|
|
type: "TEXT",
|
|
value: "test",
|
|
widgetId: "3",
|
|
widgetName: "three",
|
|
},
|
|
{
|
|
bottomRow: 18,
|
|
children: [],
|
|
isDirty: true,
|
|
isLoading: false,
|
|
isValid: true,
|
|
parentId: "2",
|
|
topRow: 6,
|
|
type: "BUTTON",
|
|
value: "test",
|
|
widgetId: "4",
|
|
widgetName: "four",
|
|
},
|
|
{
|
|
isLoading: false,
|
|
parentId: "2",
|
|
topRow: 0,
|
|
type: "CANVAS",
|
|
widgetId: "1_meta",
|
|
bottomRow: 100,
|
|
widgetName: "meta_one",
|
|
children: [
|
|
{
|
|
isDirty: true,
|
|
isLoading: false,
|
|
isValid: true,
|
|
value: "test",
|
|
children: [],
|
|
type: "INPUT_WIDGET",
|
|
widgetId: "2_meta",
|
|
parentId: "1_meta",
|
|
topRow: 0,
|
|
bottomRow: 10,
|
|
widgetName: "meta_two",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
isDirty: true,
|
|
isLoading: false,
|
|
isValid: true,
|
|
parentId: "1",
|
|
topRow: 0,
|
|
type: "CANVAS",
|
|
value: "test",
|
|
widgetId: "2",
|
|
widgetName: "two",
|
|
},
|
|
];
|
|
|
|
expect(
|
|
buildChildWidgetTree(
|
|
canvasWidgets,
|
|
metaWidgets,
|
|
dataTree,
|
|
new Set<string>("two"),
|
|
{},
|
|
"1",
|
|
),
|
|
).toEqual(childWidgetTree);
|
|
});
|
|
|
|
it("should return a partial childwidgets Tree with just loading widgets", () => {
|
|
const childWidgetTree = [
|
|
{
|
|
ENTITY_TYPE: "WIDGET",
|
|
bindingPaths: {},
|
|
bottomRow: 100,
|
|
children: [
|
|
{
|
|
ENTITY_TYPE: "WIDGET",
|
|
bindingPaths: {},
|
|
bottomRow: 5,
|
|
children: [],
|
|
isLoading: false,
|
|
logBlackList: {},
|
|
meta: {},
|
|
overridingPropertyPaths: {},
|
|
parentId: "2",
|
|
privateWidgets: {},
|
|
propertyOverrideDependency: {},
|
|
reactivePaths: {},
|
|
topRow: 4,
|
|
triggerPaths: {},
|
|
type: undefined,
|
|
validationPaths: {},
|
|
widgetId: "3",
|
|
widgetName: "three",
|
|
},
|
|
{
|
|
ENTITY_TYPE: "WIDGET",
|
|
bindingPaths: {},
|
|
bottomRow: 18,
|
|
children: [],
|
|
isLoading: false,
|
|
logBlackList: {},
|
|
meta: {},
|
|
overridingPropertyPaths: {},
|
|
parentId: "2",
|
|
privateWidgets: {},
|
|
propertyOverrideDependency: {},
|
|
reactivePaths: {},
|
|
topRow: 6,
|
|
triggerPaths: {},
|
|
type: undefined,
|
|
validationPaths: {},
|
|
widgetId: "4",
|
|
widgetName: "four",
|
|
},
|
|
{
|
|
ENTITY_TYPE: "WIDGET",
|
|
bindingPaths: {},
|
|
bottomRow: 100,
|
|
isLoading: false,
|
|
logBlackList: {},
|
|
meta: {},
|
|
overridingPropertyPaths: {},
|
|
parentId: "2",
|
|
privateWidgets: {},
|
|
propertyOverrideDependency: {},
|
|
reactivePaths: {},
|
|
topRow: 0,
|
|
triggerPaths: {},
|
|
type: undefined,
|
|
validationPaths: {},
|
|
widgetId: "1_meta",
|
|
widgetName: "meta_one",
|
|
children: [
|
|
{
|
|
ENTITY_TYPE: "WIDGET",
|
|
bindingPaths: {},
|
|
bottomRow: 10,
|
|
children: [],
|
|
isLoading: false,
|
|
logBlackList: {},
|
|
meta: {},
|
|
overridingPropertyPaths: {},
|
|
parentId: "1_meta",
|
|
privateWidgets: {},
|
|
propertyOverrideDependency: {},
|
|
reactivePaths: {},
|
|
topRow: 0,
|
|
triggerPaths: {},
|
|
type: undefined,
|
|
validationPaths: {},
|
|
widgetId: "2_meta",
|
|
widgetName: "meta_two",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
isLoading: false,
|
|
logBlackList: {},
|
|
meta: {},
|
|
overridingPropertyPaths: {},
|
|
parentId: "1",
|
|
privateWidgets: {},
|
|
propertyOverrideDependency: {},
|
|
reactivePaths: {},
|
|
topRow: 0,
|
|
triggerPaths: {},
|
|
type: undefined,
|
|
validationPaths: {},
|
|
widgetId: "2",
|
|
widgetName: "two",
|
|
},
|
|
];
|
|
expect(
|
|
buildChildWidgetTree(
|
|
canvasWidgets,
|
|
metaWidgets,
|
|
{},
|
|
new Set<string>("one"),
|
|
{},
|
|
"1",
|
|
),
|
|
).toEqual(childWidgetTree);
|
|
});
|
|
});
|
|
});
|