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: updated API edit spec #37262

Closed
wants to merge 1 commit into from

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Nov 6, 2024

Updated Confirm button click part where there was flaky behaviour noticed

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced robustness of the API edit test case by improving error handling for the confirmation dialog.
  • Chores

    • Updated test specification path to focus on server-side API edit tests instead of client-side template tests.

Copy link
Contributor

coderabbitai bot commented Nov 6, 2024

Walkthrough

The changes in this pull request involve updates to the Cypress end-to-end test suite for API functionality, specifically enhancing the robustness of a test case related to the confirmation dialog. Additionally, the path for a test specification in the limited-tests.txt file has been modified to reflect a shift from client-side to server-side API tests. The overall structure and logic of the remaining test cases remain unchanged.

Changes

File Path Change Summary
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js Updated the second test case to check for the confirmation dialog's existence before clicking.
app/client/cypress/limited-tests.txt Changed test specification path from Fork_Template_spec.js to API_Edit_spec.js.

Possibly related PRs

Suggested labels

Bug, ok-to-test, Test, Query & JS Pod, Integrations Product, Integrations Pod General

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

🌟 In the realm of code where tests do dwell,
A dialog's fate, we handle so well.
From client to server, the paths we align,
In Cypress we trust, our tests will shine!
Robust and ready, let errors take flight,
With each little change, our code feels just right! 🌟


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 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.

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=100

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Nov 6, 2024
Copy link

github-actions bot commented Nov 6, 2024

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

🧹 Outside diff range and nitpick comments (1)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js (1)

Line range hint 1-140: General test suite improvements needed

Several areas in the test suite need attention to align with Cypress best practices:

  1. Replace hardcoded wait in the last test:
-        .wait(3000)
+        .should('have.value', 'http://host.docker.internal:5001/{{Button2.text}}?key=test&val={{Button2.text}}')
  1. Consider using data-* attributes instead of class selectors:
-      cy.get(".CodeMirror-placeholder")
+      cy.get('[data-cy="code-editor-placeholder"]')
  1. Replace jQuery-style selectors:
-      cy.get(".ads-v2-modal__content").find("button")
+      cy.get('[data-cy="confirmation-modal-button"]')
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1898478 and 5ff7123.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js (1 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js (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/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.
🔇 Additional comments (1)
app/client/cypress/limited-tests.txt (1)

2-2: LGTM! Verifying the test file path.

The updated path aligns with the PR's focus on API edit specifications.

Let's verify the existence of the specified test file:

✅ Verification successful

Let me search for the test file in case it's in a different location.


The test file path in limited-tests.txt is correct

The test file exists at app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js. The path in limited-tests.txt correctly references this file using the Cypress convention of starting from the cypress/e2e/ directory.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of the specified test file
test_file="cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js"
if [ -f "$test_file" ]; then
    echo "Test file exists: $test_file"
    # Show the first few lines of the file for context
    head -n 5 "$test_file"
else
    echo "Warning: Test file not found: $test_file"
fi

Length of output: 333


Script:

#!/bin/bash
# Search for API_Edit_spec.js file in the repository
fd "API_Edit_spec.js"

# Search for any file containing API_Edit in the name
fd "API_Edit"

# Let's also check the content of limited-tests.txt to see the context
cat app/client/cypress/limited-tests.txt

Length of output: 510

Comment on lines +59 to +66
cy.get("body").then((body) => {
if (body.find(apiwidget.confirmBeforeExecute).length > 0) {
cy.get(apiwidget.confirmBeforeExecute).click({ force: true });
} else {
cy.get(apiwidget.settings).click({ force: true });
cy.get(apiwidget.confirmBeforeExecute).click({ force: true });
}
});
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

Improve element interaction strategy

The current implementation uses jQuery-style DOM checks and forced clicks, which can lead to flaky tests. Consider using Cypress's built-in retry-ability and assertions instead.

Here's a more robust approach:

-      cy.get("body").then((body) => {
-        if (body.find(apiwidget.confirmBeforeExecute).length > 0) {
-          cy.get(apiwidget.confirmBeforeExecute).click({ force: true });
-        } else {
-          cy.get(apiwidget.settings).click({ force: true });
-          cy.get(apiwidget.confirmBeforeExecute).click({ force: true });
-        }
-      });
+      cy.get(apiwidget.settings).click();
+      cy.get(apiwidget.confirmBeforeExecute)
+        .should('be.visible')
+        .click();

Key improvements:

  1. Removes force: true clicks which bypass Cypress's actionability checks
  2. Uses Cypress's built-in retry-ability with should('be.visible')
  3. Simplifies the flow by letting Cypress handle the element's visibility

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

Copy link

github-actions bot commented Nov 6, 2024

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11705049286.
Cypress dashboard url: Click here!
All Cypress tests have passed 🎉🎉🎉

***** Repeat Run Summary ***** Total Tests with repeat: 500 Total Passed: 489 Total Failed: 11 Total Skipped: 0 *****************************

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Nov 14, 2024
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Adding this label to a PR prevents it from being listed in the changelog Stale Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant