-
Notifications
You must be signed in to change notification settings - Fork 4.6k
test: validate 'Show Bindings' menu for queries & JS Objects in split-pane #38577
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import commonLocators from "../../../../locators/commonlocators.json"; | ||
| import { | ||
| agHelper, | ||
| apiPage, | ||
| jsEditor, | ||
| } from "../../../../support/Objects/ObjectsCore"; | ||
| import EditorNavigation, { | ||
| EditorViewMode, | ||
| PageLeftPane, | ||
| } from "../../../../support/Pages/EditorNavigation"; | ||
| import apiWidgetLocator from "../../../../locators/apiWidgetslocator.json"; | ||
|
|
||
| describe( | ||
| // https://github.com/appsmithorg/appsmith/issues/38547 | ||
| "Validate if Show Bindings menu shows up in split pane mode for queries & JS Objects", | ||
| { tags: ["@tag.IDE", "@tag.JS"] }, | ||
| () => { | ||
| // Utility function to validate the bindings list against expected bindings | ||
| const validateBindings = (bindingsList, expectedBindings) => { | ||
| // Assert that the number of bindings matches the expected count | ||
| expect(bindingsList).to.have.length(expectedBindings.length); | ||
| expectedBindings.forEach((binding, index) => { | ||
| const element = bindingsList.eq(index); // Get the binding element by index | ||
| expect(element).to.contain(binding); // Assert the binding content matches the expected value | ||
| }); | ||
| }; | ||
|
|
||
| it("1. Validate 'Show bindings' gets displayed for JS Objects in split pane view", () => { | ||
| jsEditor.CreateJSObject("", { prettify: false, toRun: false }); | ||
|
|
||
| // Switch to split view | ||
| EditorNavigation.SwitchScreenMode(EditorViewMode.SplitScreen); | ||
|
|
||
| // Switch to list view | ||
| cy.get(commonLocators.listToggle).click(); | ||
| PageLeftPane.assertPresence("JSObject1"); | ||
| agHelper.GetNClick(jsEditor._jsPageActions, 0, true); | ||
| cy.contains("Show bindings").click(); | ||
|
|
||
| // Assert that the bindings menu is visible | ||
| cy.xpath(commonLocators.showBindingsMenu).should("be.visible"); | ||
|
|
||
| /* | ||
| // There is a bug in which the order of bindings is incorrectly shown for JS Objects. Will enable the below validation once that is fixed. | ||
| // Expected bindings for the JavaScript Object | ||
| const expectedJSBindings = [ | ||
| "{{JSObject1.myVar1}}", | ||
| "{{JSObject1.myVar2}}", | ||
| "{{JSObject1.myFun1()}}", | ||
| "{{JSObject1.myFun1.data}}", | ||
| "{{JSObject1.myFun2()}}", | ||
| "{{JSObject1.myFun2.data}}", | ||
| ]; | ||
|
|
||
| // Validate that the bindings in the menu match the expected bindings | ||
| cy.get(jsEditor._propertyList).then(($lis) => { | ||
| validateBindings($lis, expectedJSBindings); | ||
| }); | ||
| */ | ||
| }); | ||
|
|
||
| it("2. Validate 'Show bindings' gets displayed for queries in split pane view", () => { | ||
| // Switch to standard view | ||
| EditorNavigation.SwitchScreenMode(EditorViewMode.FullScreen); | ||
| apiPage.CreateAndFillApi("www.google.com"); | ||
|
|
||
| // Switch back to split view | ||
| EditorNavigation.SwitchScreenMode(EditorViewMode.SplitScreen); | ||
|
|
||
| // Switch to list view | ||
| cy.get(commonLocators.listToggle).click(); | ||
| PageLeftPane.assertPresence("Api1"); | ||
| agHelper.GetNClick(apiPage.splitPaneContextMenuTrigger, 0, true); | ||
| cy.contains("Show bindings").click(); | ||
|
|
||
| // Assert that the bindings menu is visible | ||
| cy.xpath(commonLocators.showBindingsMenu).should("be.visible"); | ||
|
|
||
| // Expected bindings for the API | ||
| const expectedApiBindings = [ | ||
| "{{Api1.isLoading}}", | ||
| "{{Api1.data}}", | ||
| "{{Api1.responseMeta}}", | ||
| "{{Api1.run()}}", | ||
| "{{Api1.clear()}}", | ||
| ]; | ||
|
|
||
| // Validate that the bindings in the menu match the expected bindings | ||
| cy.get(apiWidgetLocator.propertyList).then(($lis) => { | ||
| validateBindings($lis, expectedApiBindings); | ||
| }); | ||
| }); | ||
|
Comment on lines
+62
to
+92
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Similar issues with cy.wait and xpath selectors. The second test case has the same violations of Cypress best practices. Apply the same fixes as suggested for the first test case:
|
||
| }, | ||
| ); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -245,5 +245,7 @@ | |||||||||||||
| "enableClientSideSearch": ".t--property-control-enableclientsidesearch input[type='checkbox']", | ||||||||||||||
| "fixedFooterInput": ".t--property-control-fixedfooter input", | ||||||||||||||
| "tostifyIcon": ".Toastify--animate-icon > span", | ||||||||||||||
| "downloadFileType": "button[class*='t--open-dropdown-Select-file-type'] > span:first-of-type" | ||||||||||||||
| "downloadFileType": "button[class*='t--open-dropdown-Select-file-type'] > span:first-of-type", | ||||||||||||||
| "listToggle": "[data-testid='t--list-toggle']", | ||||||||||||||
| "showBindingsMenu": "//*[@id='entity-properties-container']" | ||||||||||||||
|
Comment on lines
+248
to
+250
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace xpath with data- attribute.* The Update the locator to use a data-* attribute: -"showBindingsMenu": "//*[@id='entity-properties-container']",
+"showBindingsMenu": "[data-testid='entity-properties-container']",📝 Committable suggestion
Suggested change
|
||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -103,6 +103,7 @@ export class ApiPage { | |||||
| private runOnPageLoadJSObject = | ||||||
| "input[name^='execute-on-page-load'][type='checkbox']"; | ||||||
| public settingsTriggerLocator = "[data-testid='t--js-settings-trigger']"; | ||||||
| public splitPaneContextMenuTrigger = ".entity-context-menu"; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use data- attribute for selector.* The selector uses a class which violates the coding guidelines. Replace with a data-* attribute: -public splitPaneContextMenuTrigger = ".entity-context-menu";
+public splitPaneContextMenuTrigger = "[data-testid='entity-context-menu']";📝 Committable suggestion
Suggested change
|
||||||
|
|
||||||
| CreateApi( | ||||||
| apiName = "", | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid using cy.wait and xpath selectors.
The test case violates Cypress best practices:
agHelper.GetNClickimplicitly uses cy.waitcommonLocators.showBindingsMenuConsider:
agHelper.GetNClickwith proper assertions or interceptsshowBindingsMenu