From d665511c8d001a8bf5f96a1cde7b453762e052d3 Mon Sep 17 00:00:00 2001 From: Favour Ohanekwu Date: Thu, 27 Apr 2023 17:41:40 +0100 Subject: [PATCH] fix: Get default value from entityTree instead of configTree (#22682) ## Description Meta Rehydration got regressed due to Datatree splitting (https://github.com/appsmithorg/appsmith/pull/21547). Default value was getting accessed from configTree instead of entityTree. Fixes #22534 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - 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 - [ ] 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 - [x] 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: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com> Co-authored-by: Tolulope Co-authored-by: Aishwarya UR --- .../Listv2_Meta_Hydration_ServerSide_spec.js | 152 ++++++------------ .../ce/workers/Evaluation/evaluationUtils.ts | 2 +- 2 files changed, 47 insertions(+), 107 deletions(-) diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/ListV2/Listv2_Meta_Hydration_ServerSide_spec.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/ListV2/Listv2_Meta_Hydration_ServerSide_spec.js index 95bb20573b..49fba26bfd 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/ListV2/Listv2_Meta_Hydration_ServerSide_spec.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/ListV2/Listv2_Meta_Hydration_ServerSide_spec.js @@ -1,8 +1,7 @@ const dsl = require("../../../../../fixtures/Listv2/MetaHydrationDSL.json"); const commonlocators = require("../../../../../locators/commonlocators.json"); -const datasource = require("../../../../../locators/DatasourcesEditor.json"); -const queryLocators = require("../../../../../locators/QueryEditor.json"); const publishPage = require("../../../../../locators/publishWidgetspage.json"); +import * as _ from "../../../../../support/Objects/ObjectsCore"; import { ObjectsRegistry } from "../../../../../support/Objects/Registry"; @@ -74,25 +73,7 @@ function testJsontextClear(endp) { .type(`{${modifierKey}}{del}`, { force: true }); } -function verifyMultiDropdownValuesCount(count, page = 1) { - cy.get(".rc-select-selection-overflow").then(($ele) => { - if ( - $ele.find(".rc-select-selection-overflow-item .remove-icon").length == - count - ) { - cy.reload(); - if (page == 2) { - // Go to next page - cy.get(commonlocators.listPaginateNextButton).click({ - force: true, - }); - } - } - }); -} - -// Skipping this test due to regression, issue id to track this regression https://github.com/appsmithorg/appsmith/issues/22534 -describe.skip("List widget v2 - meta hydration tests", () => { +describe("List widget v2 - meta hydration tests", () => { before(() => { agHelper.AddDsl(dsl); }); @@ -105,51 +86,12 @@ describe.skip("List widget v2 - meta hydration tests", () => { }); it("1. setup serverside data", () => { - cy.wait(1000); - cy.NavigateToDatasourceEditor(); - - // // Click on sample(mock) user database. - // cy.get(datasource.mockUserDatabase).click(); - - // Choose the first data source which consists of users keyword & Click on the "New Query +"" button - // Choose the first data source which consists of users keyword & Click on the "New Query +"" button - cy.get(`${datasource.datasourceCard}`) - .filter(":contains('Users')") - .first() - .within(() => { - cy.get(`${datasource.createQuery}`).click({ force: true }); - }); - // Click the editing field - cy.get(".t--action-name-edit-field").click({ force: true }); - - // Click the editing field - cy.get(queryLocators.queryNameField).type("Query1"); - - // switching off Use Prepared Statement toggle - cy.get(queryLocators.switch).last().click({ force: true }); - - //.1: Click on Write query area - cy.get(queryLocators.templateMenu).click(); - cy.get(queryLocators.query).click({ - force: true, - }); - - // writing query to get the schema - cy.get(".CodeMirror textarea") - .first() - .focus() - .type( - "SELECT * FROM users OFFSET {{List1.pageNo * List1.pageSize}} LIMIT {{List1.pageSize}};", - { - force: true, - parseSpecialCharSequences: false, - }, - ); - cy.WaitAutoSave(); - - cy.runQuery(); - - cy.get('.t--entity-name:contains("Page1")').click({ force: true }); + cy.createAndFillApi( + "http://host.docker.internal:5001/v1/mock-api?records=20&page={{List1.pageNo}}&size={{List1.pageSize}}", + "", + ); + cy.RunAPI(); + cy.SearchEntityandOpen("List1"); cy.wait(1000); @@ -157,18 +99,17 @@ describe.skip("List widget v2 - meta hydration tests", () => { testJsontextClear("items"); - cy.testJsontext("items", "{{Query1.data}}"); + cy.testJsontext("items", "{{Api1.data}}"); cy.togglebar(commonlocators.serverSidePaginationCheckbox); cy.get(toggleJSButton("onpagechange")).click({ force: true }); - cy.testJsontext("onpagechange", "{{Query1.run()}}"); + cy.testJsontext("onpagechange", "{{Api1.run()}}"); cy.get(`${widgetSelector("List1")} ${containerWidgetSelector}`).should( "have.length", 3, ); - verifyMultiDropdownValuesCount(6); }); it("2. using server side data", () => { @@ -215,7 +156,6 @@ describe.skip("List widget v2 - meta hydration tests", () => { ); }); - verifyMultiDropdownValuesCount(6, 2); // SecondPage // First Row cy.get(`${widgetSelector("List1")}`).scrollIntoView(); @@ -251,15 +191,15 @@ describe.skip("List widget v2 - meta hydration tests", () => { .should("have.length", 3), ); - cy.get(`${widgetSelector("List1")} ${containerWidgetSelector}`) - .eq(0) - .within(() => { - cy.waitUntil(() => - cy - .get(".rc-select-selection-overflow-item .remove-icon") - .should("exist"), - ); - }); + cy.waitUntil(() => + cy + .get( + `${widgetSelector( + "List1", + )} ${containerWidgetSelector} .rc-select-selection-overflow-item .remove-icon`, + ) + .should("have.length", 3), + ); cy.waitUntil( () => @@ -311,15 +251,15 @@ describe.skip("List widget v2 - meta hydration tests", () => { .should("have.length", 3), ); - cy.get(`${widgetSelector("List1")} ${containerWidgetSelector}`) - .eq(0) - .within(() => { - cy.waitUntil(() => - cy - .get(".rc-select-selection-overflow-item .remove-icon") - .should("exist"), - ); - }); + cy.waitUntil(() => + cy + .get( + `${widgetSelector( + "List1", + )} ${containerWidgetSelector} .rc-select-selection-overflow-item .remove-icon`, + ) + .should("have.length", 3), + ); cy.waitUntil( () => @@ -436,15 +376,15 @@ describe.skip("List widget v2 - meta hydration tests", () => { .should("have.length", 3), ); - cy.get(`${widgetSelector("List1")} ${containerWidgetSelector}`) - .eq(0) - .within(() => { - cy.waitUntil(() => - cy - .get(".rc-select-selection-overflow-item .remove-icon") - .should("exist"), - ); - }); + cy.waitUntil(() => + cy + .get( + `${widgetSelector( + "List1", + )} ${containerWidgetSelector} .rc-select-selection-overflow-item .remove-icon`, + ) + .should("have.length", 3), + ); cy.waitUntil( () => @@ -496,15 +436,15 @@ describe.skip("List widget v2 - meta hydration tests", () => { .should("have.length", 3), ); - cy.get(`${widgetSelector("List1")} ${containerWidgetSelector}`) - .eq(0) - .within(() => { - cy.waitUntil(() => - cy - .get(".rc-select-selection-overflow-item .remove-icon") - .should("exist"), - ); - }); + cy.waitUntil(() => + cy + .get( + `${widgetSelector( + "List1", + )} ${containerWidgetSelector} .rc-select-selection-overflow-item .remove-icon`, + ) + .should("have.length", 3), + ); cy.waitUntil( () => diff --git a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts index d9623dda1e..1e66ce44f6 100644 --- a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts +++ b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts @@ -838,7 +838,7 @@ export const overrideWidgetProperties = (params: { const propertyOverridingKeyMap = configEntity.propertyOverrideDependency[propertyPath]; if (propertyOverridingKeyMap.DEFAULT) { - const defaultValue = configEntity[propertyOverridingKeyMap.DEFAULT]; + const defaultValue = entity[propertyOverridingKeyMap.DEFAULT]; const clonedDefaultValue = klona(defaultValue); if (defaultValue !== undefined) { const propertyPathArray = propertyPath.split(".");