diff --git a/app/client/cypress/e2e/Regression/ClientSide/BugTests/Bug28764_Spec.ts b/app/client/cypress/e2e/Regression/ClientSide/BugTests/Bug28764_Spec.ts new file mode 100644 index 0000000000..d2759c4ae6 --- /dev/null +++ b/app/client/cypress/e2e/Regression/ClientSide/BugTests/Bug28764_Spec.ts @@ -0,0 +1,74 @@ +import { + agHelper, + locators, + entityExplorer, + jsEditor, +} from "../../../../support/Objects/ObjectsCore"; + +describe("JS Function Execution", function () { + before(() => { + entityExplorer.NavigateToSwitcher("Explorer"); + }); + + it("Retains lint errors after navigation", function () { + // JS Object 1 + jsEditor.CreateJSObject( + `export default { + myVar1: [], + myVar2: {}, + myFun1 () { + // write code here + // this.myVar1 = [1,2,3] + }, + async myFun2 () { + // use async-await or promises + // Lint Error + fff + } + }`, + { + paste: true, + completeReplace: true, + toRun: false, + shouldCreateNewJSObj: true, + prettify: false, + }, + ); + // JS Object 2 + jsEditor.CreateJSObject( + `export default { + myVar1: [], + myVar2: {}, + myFun1 () { + // write code here + // this.myVar1 = [1,2,3] + }, + async myFun2 () { + // use async-await or promises + } + }`, + { + paste: true, + completeReplace: true, + toRun: false, + shouldCreateNewJSObj: true, + prettify: false, + }, + ); + + entityExplorer.SelectEntityByName("JSObject1", "Queries/JS"); + // Assert lint error + agHelper.AssertElementLength(locators._lintErrorElement, 1); + agHelper.HoverElement(locators._lintErrorElement); + agHelper.AssertContains(`'fff' is not defined`); + + entityExplorer.SelectEntityByName("JSObject2", "Queries/JS"); + agHelper.AssertElementAbsence(locators._lintErrorElement); + + entityExplorer.SelectEntityByName("JSObject1", "Queries/JS"); + // Assert lint error + agHelper.AssertElementLength(locators._lintErrorElement, 1); + agHelper.HoverElement(locators._lintErrorElement); + agHelper.AssertContains(`'fff' is not defined`); + }); +}); diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index fedf143147..ebd5c8273c 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -594,10 +594,6 @@ class CodeEditor extends Component { } this.editor.operation(() => { - if (prevProps.lintErrors !== this.props.lintErrors) { - this.lintCode(this.editor); - } - const editorValue = this.editor.getValue(); // Safe update of value of the editor when value updated outside the editor const inputValue = getInputValue(this.props.input.value); @@ -643,6 +639,9 @@ class CodeEditor extends Component { this.props.entitiesForNavigation, ); } + if (prevProps.lintErrors !== this.props.lintErrors) { + this.lintCode(this.editor); + } if (this.props.datasourceTableKeys !== prevProps.datasourceTableKeys) { sqlHint.setDatasourceTableKeys(this.props.datasourceTableKeys); }