From dd6e3185f8b6f319236666894b54b794029a017b Mon Sep 17 00:00:00 2001 From: Vemparala Surya Vamsi Date: Thu, 5 Dec 2024 13:12:42 +0530 Subject: [PATCH 1/2] changed klonaJSON --- app/client/src/workers/common/DataTreeEvaluator/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/src/workers/common/DataTreeEvaluator/index.ts b/app/client/src/workers/common/DataTreeEvaluator/index.ts index d874741e483b..095d9bd25798 100644 --- a/app/client/src/workers/common/DataTreeEvaluator/index.ts +++ b/app/client/src/workers/common/DataTreeEvaluator/index.ts @@ -1059,7 +1059,7 @@ export default class DataTreeEvaluator { staleMetaIds: string[]; contextTree: DataTree; } { - const safeTree = klona(unEvalTree); + const safeTree = klonaJSON(unEvalTree); const dataStore = DataStore.getDataStore(); const dataStoreClone = klonaJSON(dataStore); From 326c1df82308460634f38e2b546228bba2efe1dd Mon Sep 17 00:00:00 2001 From: Vemparala Surya Vamsi Date: Fri, 6 Dec 2024 23:37:40 +0530 Subject: [PATCH 2/2] test case fix --- .../Evaluation/__tests__/evaluation.test.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/client/src/workers/Evaluation/__tests__/evaluation.test.ts b/app/client/src/workers/Evaluation/__tests__/evaluation.test.ts index dd25e57bb1e9..ad1a2936e742 100644 --- a/app/client/src/workers/Evaluation/__tests__/evaluation.test.ts +++ b/app/client/src/workers/Evaluation/__tests__/evaluation.test.ts @@ -18,6 +18,7 @@ import WidgetFactory from "WidgetProvider/factory"; import { generateDataTreeWidget } from "entities/DataTree/dataTreeWidget"; import { sortObjectWithArray } from "../../../utils/treeUtils"; import klona from "klona"; + import { APP_MODE } from "entities/App"; const klonaFullSpy = jest.fn(); @@ -31,6 +32,17 @@ jest.mock("klona/full", () => ({ return klona.klona(arg); }, })); +const klonaJsonSpy = jest.fn(); + +jest.mock("klona/json", () => ({ + // TODO: Fix this the next time the file is edited + // eslint-disable-next-line @typescript-eslint/no-explicit-any + klona: (arg: any) => { + klonaJsonSpy(arg); + + return klona.klona(arg); + }, +})); export const WIDGET_CONFIG_MAP: WidgetTypeConfigMap = { CONTAINER_WIDGET: { @@ -581,7 +593,8 @@ describe("DataTreeEvaluator", () => { ); evaluator.evalAndValidateFirstTree(); // Hard check to not regress on the number of clone operations. Try to improve this number. - expect(klonaFullSpy).toBeCalledTimes(41); + expect(klonaFullSpy).toBeCalledTimes(40); + expect(klonaJsonSpy).toBeCalledTimes(3); }); it("Evaluates a binding in first run", () => { @@ -1102,6 +1115,7 @@ describe("DataTreeEvaluator", () => { unEvalUpdates, ); // Hard check to not regress on the number of clone operations. Try to improve this number. - expect(klonaFullSpy).toBeCalledTimes(7); + expect(klonaFullSpy).toBeCalledTimes(6); + expect(klonaJsonSpy).toBeCalledTimes(2); }); });