diff --git a/app/client/cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js b/app/client/cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js index a95ee658fe..0d50efea49 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js @@ -4,6 +4,8 @@ import { entityExplorer, homePage, jsEditor, + apiPage, + dataSources, } from "../../../../support/Objects/ObjectsCore"; describe("JSEditor Indendation - Visual tests", () => { @@ -341,4 +343,21 @@ myFun2: async () => { cy.get("div.CodeMirror").type("{cmd+leftArrow}"); cy.get("div.CodeMirror").matchImageSnapshot("jsObjAfterGoLineStartSmart5"); }); + + it("5. Bug 25325 Check if the JS Object in body field is formatted properly on save", () => { + apiPage.CreateApi("FirstAPI"); + apiPage.SelectPaneTab("Body"); + apiPage.SelectSubTab("JSON"); + dataSources.EnterQuery( + `{{ + { + "title": this.params.title, + "due": this.params.due, + assignee: this.params.assignee + } + }}`, + ); + cy.get("body").type(agHelper.isMac ? "{meta}S" : "{ctrl}S"); + cy.get(apiPage.jsonBody).matchImageSnapshot("formattedJSONBodyAfterSave"); + }); }); diff --git a/app/client/cypress/snapshots/JSEditorIndent_spec.js/formattedJSONBodyAfterSave.snap.png b/app/client/cypress/snapshots/JSEditorIndent_spec.js/formattedJSONBodyAfterSave.snap.png new file mode 100644 index 0000000000..1f9afa4c18 Binary files /dev/null and b/app/client/cypress/snapshots/JSEditorIndent_spec.js/formattedJSONBodyAfterSave.snap.png differ diff --git a/app/client/cypress/support/Pages/ApiPage.ts b/app/client/cypress/support/Pages/ApiPage.ts index 8cce371591..c15da6cbcc 100644 --- a/app/client/cypress/support/Pages/ApiPage.ts +++ b/app/client/cypress/support/Pages/ApiPage.ts @@ -79,6 +79,7 @@ export class ApiPage { _addMore = ".t--addApiHeader"; public _editorDS = ".t--datasource-editor"; public _addMoreHeaderFieldButton = ".t--addApiHeader"; + public jsonBody = `.t--apiFormPostBody`; CreateApi( apiName = "", diff --git a/app/client/src/components/editorComponents/CodeEditor/modes.ts b/app/client/src/components/editorComponents/CodeEditor/modes.ts index b107e29162..ab3d6bb07a 100644 --- a/app/client/src/components/editorComponents/CodeEditor/modes.ts +++ b/app/client/src/components/editorComponents/CodeEditor/modes.ts @@ -90,6 +90,7 @@ Object.keys(MULTIPLEXING_MODE_CONFIGS).forEach((key) => { delimStyle: "binding-brackets", mode: CodeMirror.getMode(config, { name: "javascript", + json: true, }), })), );