From cda8131e97f277f9c95bcbbe178df8b6e6ceea3f Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Thu, 10 Oct 2024 17:06:11 +0530 Subject: [PATCH] fix: Add inverse dependencies to default response in evaluateAndGenerateResponse (#36780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Problem Table loader was not coming up when relaod was linked to any event other than page reload. Root cause Upon debugging we found that in one of the paths that generates `inverseDependecyMap` the object was always empty(for milliseconds only). It led to table not knowing that the query/api linked is in loading state. More details here on [slack thread](https://theappsmith.slack.com/archives/C05M5CTRHM3/p1728455111179839?thread_ts=1728455103.864849&cid=C05M5CTRHM3) Solution This pull request adds the inverse dependencies to the default response in the `evaluateAndGenerateResponse` function. It ensures that the `dependencies` property in the `defaultResponse` object includes the inverse dependencies from the `dataTreeEvaluator`. This change improves the accuracy and completeness of the default response. Fixes #36538 _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 > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 675e0f29ad24c86156c66920ae664727c2a5c86a > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Thu, 10 Oct 2024 10:32:29 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No ## Summary by CodeRabbit - **New Features** - Enhanced evaluation and response generation for widget updates in data trees. - Improved dependency mapping in evaluation responses. - **Bug Fixes** - Added tests to ensure correct handling of widget updates and dependencies. - **Refactor** - Improved clarity and organization of test cases for better maintainability. --- .../src/workers/Evaluation/evalTreeWithChanges.test.ts | 5 +++++ app/client/src/workers/Evaluation/evalTreeWithChanges.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/app/client/src/workers/Evaluation/evalTreeWithChanges.test.ts b/app/client/src/workers/Evaluation/evalTreeWithChanges.test.ts index 3227e290ec..929aa0a363 100644 --- a/app/client/src/workers/Evaluation/evalTreeWithChanges.test.ts +++ b/app/client/src/workers/Evaluation/evalTreeWithChanges.test.ts @@ -277,6 +277,11 @@ describe("evaluateAndGenerateResponse", () => { [], [], ); + + expect(webworkerResponse.workerResponse.dependencies).toEqual({ + "Text1.text": ["Text2.text", "Text1"], + "Text2.text": ["Text2"], + }); const parsedUpdates = getParsedUpdatesFromWebWorkerResp(webworkerResponse); diff --git a/app/client/src/workers/Evaluation/evalTreeWithChanges.ts b/app/client/src/workers/Evaluation/evalTreeWithChanges.ts index 8b75815c5b..bc561de0df 100644 --- a/app/client/src/workers/Evaluation/evalTreeWithChanges.ts +++ b/app/client/src/workers/Evaluation/evalTreeWithChanges.ts @@ -139,6 +139,7 @@ export const evaluateAndGenerateResponse = ( ); defaultResponse.staleMetaIds = updateResponse.staleMetaIds; + defaultResponse.dependencies = dataTreeEvaluator.inverseDependencies; // when additional paths are required to be added as updates, we extract the updates from the data tree using these paths. const additionalUpdates = getNewDataTreeUpdates(