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

fix: API multipart spec flakiness #35927

Merged
merged 11 commits into from
Aug 28, 2024
Merged

Conversation

AmanAgarwal041
Copy link
Contributor

@AmanAgarwal041 AmanAgarwal041 commented Aug 28, 2024

Description

  • This PR fixes the flakiness of the app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_Spec.ts spec file.
  • It removes the dependency on external library cloudinary for multipart upload test
  • It removes the test step where the cloudinary api was expecting error if the array type was selected for multipart form data key instead of file type.
  • Moved the cloudinary api to ted api
  • Fixes the issue of the None type selection which goes out of the view port after the multipart form data is selected in the dropdown.

Fixes #35137
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Datasource, @tag.Binding, @tag.Visual"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10594951475
Commit: 65218a2
Cypress dashboard.
Tags: @tag.Datasource, @tag.Binding, @tag.Visual
Spec:


Wed, 28 Aug 2024 11:58:03 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new multipart API for image uploads, replacing the previous Cloudinary upload functionality.
    • Enhanced the DataManager with a new property for the multipart API endpoint, expanding API interaction capabilities.
  • Bug Fixes

    • Updated success and error handling messages in the API test cases to reflect the new multipart API.
  • Documentation

    • Adjusted the testing focus from client-side templates to server-side API multipart tests in the configuration.
  • Refactor

    • Simplified API interaction methods by removing unnecessary visibility checks in the UI interactions.

@github-actions github-actions bot added cypress-flaky-fix This label is auto-added when a PR which only has Cypress fixes are merged to release Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Query & JS Pod Issues related to the query & JS Pod Stability Pod For all issues/tasks to be prioritized under Stability pod Task A simple Todo labels Aug 28, 2024
Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Warning

Rate limit exceeded

@AmanAgarwal041 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 49 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 99e0865 and 65218a2.

Walkthrough

The recent changes focus on enhancing API testing functionality by transitioning from the CloudinaryUploadApi to a new MultipartAPI. This adjustment impacts test cases, error handling, and the data structure utilized for image uploads. Additionally, the configuration of limited tests has been updated to emphasize server-side API testing. A new property for multipartAPI has been added to the DataManager, further expanding its capabilities.

Changes

Files Change Summary
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_Spec.ts Replaced CloudinaryUploadApi with MultipartAPI, updated API call setups, success messages, and property fields. Removed a test case for array type uploads.
app/client/cypress/limited-tests.txt Updated the test specification path from client-side to server-side API multipart tests.
app/client/cypress/support/Objects/DataManager.ts Added a new property multipartAPI to provide a multipart echo API endpoint.
app/client/cypress/support/Pages/ApiPage.ts Simplified someMethod by removing the visibility check when clicking an element.

Assessment against linked issues

Objective Addressed Explanation
Fix flakiness of tests related to Cloudinary API (#35137)
Address failures caused by external API dependencies (#35137) The dependency on external APIs remains.

🌟 In the realm of code, changes take flight,
Multipart API now shines so bright.
Tests once flaky, now steadier stand,
With new paths and updates, all well planned.
A dance of functions, a seamless embrace,
In the world of APIs, we find our place! 🎉


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 the Bug Something isn't working label Aug 28, 2024
@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit

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

Outside diff range, codebase verification and nitpick comments (2)
app/client/cypress/support/Pages/ApiPage.ts (2)

Line range hint 69-101: Refactor to avoid direct XPath usage and ensure best practices.

The method CreateApi uses direct XPath selectors and potentially flaky commands like cy.wait. Consider refactoring to use data attributes for selectors and avoid using cy.wait as it can lead to non-deterministic behavior. Here's a suggested refactor:

- this.agHelper.GetNClick(this._blankAPI, 0, true);
+ this.agHelper.GetNClick(this.locator.blankAPI, 0, true); // Assume `locator.blankAPI` is defined with a data attribute

This change promotes the use of data attributes for selectors, which is more maintainable and less prone to errors. Additionally, review the use of cy.wait and replace it with more deterministic wait mechanisms, such as waiting for specific network calls or UI states.


Line range hint 155-164: Replace non-deterministic sleep with more reliable wait mechanisms.

The use of agHelper.Sleep() in the EnterURL method can lead to non-deterministic test behavior. Consider replacing it with more reliable wait mechanisms, such as waiting for specific network responses or UI changes:

- this.agHelper.Sleep(); //Is needed for the entered url value to be registered, else failing locally & CI
+ cy.wait('@networkCall'); // Replace with an appropriate alias for a network call

This change ensures that the test waits for a specific condition to be met, which is more reliable and maintainable than a fixed-duration sleep.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4885337 and 99e0865.

Files selected for processing (4)
  • app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_Spec.ts (6 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Objects/DataManager.ts (2 hunks)
  • app/client/cypress/support/Pages/ApiPage.ts (1 hunks)
Additional context used
Path-based instructions (4)
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.
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_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.
app/client/cypress/support/Objects/DataManager.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/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.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4885337 and 99e0865.

Files selected for processing (4)
  • app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_Spec.ts (6 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Objects/DataManager.ts (2 hunks)
  • app/client/cypress/support/Pages/ApiPage.ts (1 hunks)
Additional context used
Path-based instructions (4)
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.
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_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.
app/client/cypress/support/Objects/DataManager.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/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.

@@ -303,7 +303,7 @@ export class ApiPage {
| "RAW",
) {
this.agHelper.GetNClick(this._bodyTypeSelect);
cy.xpath(this._bodyTypeToSelect(subTabName)).should("be.visible").click();
this.agHelper.GetNClick(this._bodyTypeToSelect(subTabName));
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider restoring visibility checks for robustness.

Dear student, it appears you've removed the visibility check before clicking on elements. While this simplifies the code, it might lead to issues where clicks fail because elements are not yet visible. In the world of testing, especially with asynchronous UI operations, it's prudent to ensure elements are visible and interactable before performing actions on them. This helps in making the tests more reliable and less flaky.

Consider the following adjustment to maintain the robustness of your test interactions:

- this.agHelper.GetNClick(this._bodyTypeToSelect(subTabName));
+ cy.xpath(this._bodyTypeToSelect(subTabName)).should('be.visible').click();

This change ensures that the element is visible before we attempt to click on it, thus reducing the likelihood of encountering errors during test execution.

Committable suggestion was skipped due to low confidence.

Copy link

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

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit runId=10592758486

5 similar comments
@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit runId=10592758486

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit runId=10592758486

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit runId=10592758486

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit runId=10592758486

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit runId=10592758486

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

@AmanAgarwal041 AmanAgarwal041 added the ok-to-test Required label for CI label Aug 28, 2024
@AmanAgarwal041 AmanAgarwal041 merged commit d79bad4 into release Aug 28, 2024
42 checks passed
@AmanAgarwal041 AmanAgarwal041 deleted the fix/api-multipart-spec branch August 28, 2024 12:17
ashit-rath pushed a commit that referenced this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working cypress-flaky-fix This label is auto-added when a PR which only has Cypress fixes are merged to release Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration ok-to-test Required label for CI Query & JS Pod Issues related to the query & JS Pod Stability Pod For all issues/tasks to be prioritized under Stability pod Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Fix flakiness of cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_Spec.ts
2 participants