Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: changed evaluateTree to use klonaJSON #37976

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app/client/src/workers/Evaluation/__tests__/evaluation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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: {
Expand Down Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion app/client/src/workers/common/DataTreeEvaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading