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: replace 3rd party API1 CE #36518

Merged
merged 2 commits into from
Sep 27, 2024
Merged

test: replace 3rd party API1 CE #36518

merged 2 commits into from
Sep 27, 2024

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Sep 24, 2024

Replacing the 3rd party API with TED API

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

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11027894410
Commit: 0446747
Cypress dashboard.
Tags: @tag.Datasource
Spec:


Wed, 25 Sep 2024 07:37:49 UTC

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

This pull request introduces changes to two files related to Cypress testing. The URL in the API_Edit_spec.js test script has been updated from a Facebook link to a local host address, ensuring that tests can run in a local environment. Additionally, the limited-tests.txt file has been modified to focus limited tests on the API_Edit_spec.js file instead of a client-side template test. These adjustments streamline the testing process by aligning it with local development needs.

Changes

File Change Summary
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js Updated URL from Facebook to local host for API edit tests, reflecting changes in validation checks.
app/client/cypress/limited-tests.txt Changed specified test file for limited tests from client-side to server-side API edit tests.

Possibly related PRs

Suggested labels

Task, ok-to-test, Test

Suggested reviewers

  • subrata71
  • mohanarpit

🌟 In the land of code where tests do dwell,
A URL changed, all is well!
From Facebook's domain to local we steer,
For smoother testing, let’s give a cheer!
With limited tests now focused and bright,
Our server-side API shines a new light! 🌟


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.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Sep 24, 2024
@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=25

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

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

Line range hint 99-103: Good job updating the API endpoint, class! Let's make it even better!

I see you've successfully replaced the Facebook API with a local Docker host. That's a gold star for following the PR objectives! However, let's take this opportunity to improve our code a bit more.

Consider extracting the base URL into a constant or environment variable. This will make our tests more flexible and easier to maintain. Here's how you could do it:

const API_BASE_URL = Cypress.env('API_BASE_URL') || 'http://host.docker.internal:5001';

// Then use it in your test
`${API_BASE_URL}/{{Button2.text}}?key=test&val={{Button2.text}}`

This way, we can easily change the base URL for different environments without modifying the test code. Remember, good developers always think about maintainability!


109-111: Excellent work on updating the validation, students! Let's make it even more robust!

You've done a splendid job ensuring that the validation matches the new API endpoint. That's very important for maintaining the integrity of our tests.

To make our test even more robust, let's consider using dynamic values for validation instead of hardcoded ones. Here's an example of how we could improve this:

const expectedText = 'Cancel';
const expectedUrl = `http://host.docker.internal:5001/${expectedText}?key=test&val=${expectedText}`;

cy.validateEvaluatedValue(expectedUrl);

By using variables, we make our test more flexible and easier to update if the expected values change. It's also a good practice to avoid repeating literal values in our code. Remember, DRY (Don't Repeat Yourself) is not just for staying hydrated during long coding sessions!


Line range hint 1-114: Class, let's review our overall test structure and practices!

While we've made good progress with our recent changes, there are a few areas where we can improve our test suite to align better with Cypress best practices:

  1. Avoid using cy.wait(): I noticed we're using cy.wait(3000) on line 102. Instead of hard-coded waits, let's use Cypress's built-in retry-ability and cy.intercept() for network requests.

  2. Use data attributes for selectors: Our test is using class selectors like .CodeMirror textarea. It's better to use data attributes like data-cy="api-textarea" for more stable selectors.

  3. Avoid using force: true: We're using this in several places. It's generally a sign that our app's state management could be improved. Let's review why these are necessary and see if we can make our app more testable.

  4. Group related tests: Consider using describe blocks to group related tests together. This improves readability and organization.

  5. Use before or beforeEach for setup: Move common setup steps (like creating an API) into a before or beforeEach block to reduce repetition.

Remember, writing good tests is just as important as writing good application code. It's an art that we're all continually perfecting!

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ea2803 and 6e54324.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js (2 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 not posted (1)
app/client/cypress/limited-tests.txt (1)

2-2: Well done, class! This change looks good.

Now, let's take a moment to appreciate the importance of this modification. By switching from a client-side template test to a server-side API test, we're focusing our limited tests on the area that's most relevant to our current lesson plan - replacing the 3rd party API.

Remember, children, in the world of software development, it's crucial to adapt our tests to match the changes we're making. Just like how we update our lesson plans when we introduce new topics!

However, I'd like to assign a bit of homework. While we're focusing on API tests now, don't forget the value of comprehensive testing. When you have time, consider running the full test suite to ensure all areas of our application are still functioning correctly. It's like checking all the chapters in your textbook, not just the one we're currently studying!

Verification successful

Action Required: The cypress/e2e directory was not found. Let's locate the correct Cypress test files and verify API references.


Verification Successful: No Additional Test Updates Required

Excellent work! We've confirmed that there are no other tests mentioning either the old API (API1 CE) or the new API (API_Edit). Your changes are appropriately isolated, ensuring that our test suite remains accurate and maintainable.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if there are other tests that might need updating

echo "Let's see if there are any other tests mentioning our old API:"
rg --type js "API1 CE" cypress/e2e

echo "And now, let's check if our new API is mentioned in other tests:"
rg --type js "API_Edit" cypress/e2e

Length of output: 456


Script:

#!/bin/bash
# Description: Locate Cypress test files and search for API mentions

echo "Locating all Cypress test directories and files:"
fd --type d cypress || echo "No Cypress directories found."

echo "Searching for 'API1 CE' in Cypress test files:"
rg --type js "API1 CE" || echo "No occurrences of 'API1 CE' found."

echo "Searching for 'API_Edit' in Cypress test files:"
rg --type js "API_Edit" || echo "No occurrences of 'API_Edit' found."

Length of output: 589

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11017196827.
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: 125 Total Passed: 125 Total Failed: 0 Total Skipped: 0 *****************************

@NandanAnantharamu NandanAnantharamu added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Sep 25, 2024
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.

2 participants