Skip to content
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

test: validate 'Show Bindings' menu for queries & JS Objects in split-pane #38577

Open
wants to merge 3 commits into
base: release
Choose a base branch
from

Conversation

shadabbuchh
Copy link
Contributor

@shadabbuchh shadabbuchh commented Jan 10, 2025

Description

This PR introduces test cases to validate the visibility and correctness of the "Show Bindings" menu when working with JavaScript Objects and API queries in the split-pane mode. It ensures that the bindings are displayed as expected.

Tests: #38547

Automation

/ok-to-test tags="@tag.Datasource, @tag.Sanity, @tag.JS"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12708509894
Commit: 91840c0
Cypress dashboard.
Tags: @tag.Datasource, @tag.Sanity, @tag.JS
Spec:


Fri, 10 Jan 2025 12:29:18 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Added automated tests for validating the "Show Bindings" menu in split pane mode.
    • Introduced new locators for list toggle and bindings menu.
  • Tests

    • Created test cases for checking "Show Bindings" functionality for JavaScript Objects and API queries.
  • Chores

    • Updated test configurations to focus on specific test cases and modified locator references in support files.

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

This pull request introduces a new Cypress test suite focusing on validating the "Show Bindings" menu functionality for JavaScript Objects and API queries in split pane mode. The changes include a new test file, updates to common locators, and a minor enhancement to the ApiPage class. The tests aim to ensure the correct visibility and interaction of the bindings menu across different application contexts.

Changes

File Change Summary
app/client/cypress/e2e/Regression/ClientSide/ExplorerTests/Show_Bindings_Menu_Bug38547_spec.ts Added new test suite with two test cases for validating "Show Bindings" menu for JS Objects and API queries
app/client/cypress/locators/commonlocators.json Added new locators for list toggle and bindings menu, removed one download file type entry
app/client/cypress/support/Pages/ApiPage.ts Added splitPaneContextMenuTrigger property for context menu selector
app/client/cypress/limited-tests.txt Updated limited tests to focus on the new bindings menu test file

Sequence Diagram

sequenceDiagram
    participant User
    participant App
    participant JSObject/API
    participant BindingsMenu

    User->>App: Create JS Object/API
    User->>App: Switch to Split View
    App->>JSObject/API: Display in Left Pane
    User->>JSObject/API: Click "Show Bindings"
    JSObject/API->>BindingsMenu: Trigger Bindings Menu
    BindingsMenu->>User: Display Bindings
Loading

Possibly related PRs

Suggested Labels

Bug, ok-to-test, Enhancement

Suggested Reviewers

  • ApekshaBhosale
  • sagar-qa007
  • NandanAnantharamu

Poem

🔍 In the realm of code, a test takes flight,
Bindings dancing left and right,
Cypress clicks with gentle grace,
Revealing secrets in each test case!
Bug hunting with a playful might! 🕵️‍♀️


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e663523 and 4770195.

📒 Files selected for processing (1)
  • app/client/cypress/limited-tests.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/limited-tests.txt (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (2)
app/client/cypress/limited-tests.txt (2)

2-2: LGTM! Test spec path aligns with PR objectives.

The specified test path correctly targets the new test file for validating the "Show Bindings" menu functionality.


5-5: Verify the scope of excluded Widget tests.

Please confirm that commenting out the Widget tests doesn't exclude any relevant test cases for the "Show Bindings" menu functionality in Widget contexts.

Run this script to check for any Show Bindings related tests in the Widgets directory:

✅ Verification successful

Excluding Anvil Widget tests does not impact Show Bindings test coverage

The Show Bindings menu functionality tests are maintained in the main Widgets test suite, not in the Anvil-specific widget tests being excluded.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Show Bindings related tests in Widgets directory
rg -l "Show.?Bindings" "cypress/e2e/Regression/ClientSide/Anvil/Widgets/"

Length of output: 162


Script:

#!/bin/bash
# Find the correct Widgets directory structure
fd -t d widgets -i

# Search for Show Bindings related tests in the entire cypress directory
fd -t f . -e cy.js -e spec.js -e test.js | xargs rg -l "Show.?Bindings"

Length of output: 2760


Script:

#!/bin/bash
# Search for binding-related tests with broader patterns
rg -l -i "binding|property.?pane|widget.?propert" "app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/" "app/client/cypress/e2e/Regression/ClientSide/Widgets/" || true

# List all test files in these directories to understand test coverage
fd -e cy.js -e spec.js -e test.js . "app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/" "app/client/cypress/e2e/Regression/ClientSide/Widgets/"

Length of output: 28216


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Jan 10, 2025
@shadabbuchh
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/ExplorerTests/Show_Bindings_Menu_Bug38547_spec.ts

Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e12f1bc and e663523.

📒 Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/ExplorerTests/Show_Bindings_Menu_Bug38547_spec.ts (1 hunks)
  • app/client/cypress/locators/commonlocators.json (1 hunks)
  • app/client/cypress/support/Pages/ApiPage.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
app/client/cypress/support/Pages/ApiPage.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
app/client/cypress/locators/commonlocators.json (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
app/client/cypress/e2e/Regression/ClientSide/ExplorerTests/Show_Bindings_Menu_Bug38547_spec.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (1)
app/client/cypress/e2e/Regression/ClientSide/ExplorerTests/Show_Bindings_Menu_Bug38547_spec.ts (1)

19-26: Well-structured utility function for validating bindings.

The validateBindings utility function is well-implemented with proper assertions.

Comment on lines +62 to +92
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);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

  • Replace agHelper.GetNClick
  • Use data-* attributes for selectors

Comment on lines +28 to +60
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);
});
*/
});
Copy link
Contributor

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:

  1. agHelper.GetNClick implicitly uses cy.wait
  2. Using xpath selector commonLocators.showBindingsMenu

Consider:

  • Replace agHelper.GetNClick with proper assertions or intercepts
  • Use data-* attributes instead of xpath for showBindingsMenu
-cy.xpath(commonLocators.showBindingsMenu).should("be.visible");
+cy.get("[data-testid='entity-properties-container']").should("be.visible");

Committable suggestion skipped: line range outside the PR's diff.

@@ -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";
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public splitPaneContextMenuTrigger = ".entity-context-menu";
public splitPaneContextMenuTrigger = "[data-testid='entity-context-menu']";

Comment on lines +248 to +250
"downloadFileType": "button[class*='t--open-dropdown-Select-file-type'] > span:first-of-type",
"listToggle": "[data-testid='t--list-toggle']",
"showBindingsMenu": "//*[@id='entity-properties-container']"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace xpath with data- attribute.*

The showBindingsMenu locator uses xpath which violates the coding guidelines.

Update the locator to use a data-* attribute:

-"showBindingsMenu": "//*[@id='entity-properties-container']",
+"showBindingsMenu": "[data-testid='entity-properties-container']",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"downloadFileType": "button[class*='t--open-dropdown-Select-file-type'] > span:first-of-type",
"listToggle": "[data-testid='t--list-toggle']",
"showBindingsMenu": "//*[@id='entity-properties-container']"
"downloadFileType": "button[class*='t--open-dropdown-Select-file-type'] > span:first-of-type",
"listToggle": "[data-testid='t--list-toggle']",
"showBindingsMenu": "[data-testid='entity-properties-container']"

@shadabbuchh
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/ExplorerTests/Show_Bindings_Menu_Bug38547_spec.ts

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12707774911.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 40 Total Passed: 40 Total Failed: 0 Total Skipped: 0 *****************************

@shadabbuchh shadabbuchh added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jan 10, 2025
@shadabbuchh shadabbuchh added the ok-to-test Required label for CI label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant