diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Logs_spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Logs_spec.ts index 54335b648c..0653090e3a 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Logs_spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/OtherUIFeatures/Logs_spec.ts @@ -373,11 +373,32 @@ describe("Debugger logs", function() { debuggerHelper.Assert_Consecutive_Console_Log_Count(5); }); - // it("Api headers need to be shown as headers in logs", function() { - // // TODO - // }); - - // it("Api body needs to be shown as JSON when possible", function() { - // // TODO - // }); + it("18. Console log should not mutate the passed object", function() { + ee.NavigateToSwitcher("explorer"); + jsEditor.CreateJSObject( + `export default { + myFun1: () => { + let data = []; + console.log("start:", data); + for(let i=0; i<5; i++) + data.push(i); + console.log("end:", JSON.stringify(data)); + return data; + }, + myFun2: () => { + return 1; + } + }`, + { + paste: true, + completeReplace: true, + toRun: true, + shouldCreateNewJSObj: true, + prettify: false, + }, + ); + agHelper.GetNClick(jsEditor._logsTab); + debuggerHelper.DoesConsoleLogExist("start: []"); + debuggerHelper.DoesConsoleLogExist("end: [0,1,2,3,4]"); + }); }); diff --git a/app/client/src/workers/UserLog.ts b/app/client/src/workers/UserLog.ts index 716cd8aad3..db6a972c02 100644 --- a/app/client/src/workers/UserLog.ts +++ b/app/client/src/workers/UserLog.ts @@ -1,6 +1,7 @@ import { uuid4 } from "@sentry/utils"; import { EventType } from "constants/AppsmithActionConstants/ActionConstants"; import { LogObject, Methods, Severity } from "entities/AppsmithConsole"; +import { klona } from "klona/lite"; import moment from "moment"; import { TriggerMeta } from "sagas/ActionExecution/ActionExecutionSagas"; import { _internalClearTimeout, _internalSetTimeout } from "./TimeoutOverride"; @@ -131,7 +132,7 @@ class UserLog { return { method, id, - data: output, + data: klona(output), timestamp, severity, };