fix: fixed auto indent in fields that contains JSON inside mustache binding (#26245)

## Description
Fixes auto indent on save in field that contains JS objects

#### PR fixes following issue(s)
Fixes #25325

#### Media
> A video or a GIF is preferred. when using Loom, don’t embed because it
looks like it’s a GIF. instead, just link to the video
>
>
#### Type of change
- Bug fix (non-breaking change which fixes an issue)
>
>
## Testing
>
#### How Has This Been Tested?
- [x] Manual
- [x] Cypress
>
>
#### Test Plan
1. Verified query and api parameter for indentation after command +S 
2. Verified code editor for object and array indentation and cmd+s
3. Verified chrome and firefox browser for cmd+s

#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [x] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
This commit is contained in:
arunvjn 2023-08-11 15:50:13 +05:30 committed by GitHub
parent fac044d34d
commit 42ea9938fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 0 deletions

View File

@ -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");
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -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 = "",

View File

@ -90,6 +90,7 @@ Object.keys(MULTIPLEXING_MODE_CONFIGS).forEach((key) => {
delimStyle: "binding-brackets",
mode: CodeMirror.getMode(config, {
name: "javascript",
json: true,
}),
})),
);