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 api with TED #36594

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Sep 28, 2024

replace 3rd party API with TED
/ok-to-test tags="@tag.JS"

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11102666520
Commit: 06354a9
Cypress dashboard.
Tags: @tag.JS
Spec:


Mon, 30 Sep 2024 09:26:01 UTC

Copy link
Contributor

coderabbitai bot commented Sep 28, 2024

Walkthrough

The pull request introduces significant modifications to the test specifications for server-side on-load tests. It updates the API endpoint from a public URL to a local host address, alters the associated JavaScript function names, and changes the verification messages in the tests. Additionally, the specification for limited tests has been redirected to focus on the new server-side tests instead of client-side templates.

Changes

Files Change Summary
app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JsOnLoad3_Spec.ts Updated API endpoint and function names from Quotes to AppsmithTed, modifying related expressions and toast message verifications.
app/client/cypress/limited-tests.txt Changed the specification file for limited tests from a client-side template to a server-side on-load test.

Possibly related PRs

Suggested labels

Bug, ok-to-test, Test

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

Poem

In the land of code where tests do play,
A new API dawns, brightening the day.
From Quotes to AppsmithTed, we now call,
With local hosts guiding, we stand tall.
Limited tests shift, a new path to tread,
In the world of Cypress, new journeys ahead! 🌟


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 28, 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 (4)
app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JsOnLoad3_Spec.ts (4)

40-41: Good job updating the API endpoint, class! Let's make it even better!

I see you've updated the API endpoint to use TED, which is exactly what we wanted. Well done! However, let's think about making our code more flexible. Can you tell me why using an environment variable for the API URL might be a good idea?

Consider using an environment variable for the API URL:

`${Cypress.env('TED_API_URL') || 'http://host.docker.internal:5001'}`

This way, we can easily change the URL for different environments without modifying the code. What do you think about this approach?


57-58: Excellent work updating the function name and call! Let's add a little extra credit!

You've done a great job updating the function to use the new AppsmithTed API. That's exactly what we were looking for! Now, let's think about error handling. What might happen if the API call fails?

Consider adding error handling to make our test more robust:

callAppsmithTed: async () => {
  try {
    return await AppsmithTed.run();
  } catch (error) {
    cy.log('Error calling AppsmithTed:', error);
    throw error;
  }
}

This way, if there's an error, we'll see it in our Cypress logs. What do you think about this addition?


74-74: Nice update to the function name! Let's clarify our intentions.

You've correctly updated the function name here. Good attention to detail! Now, let's think about the comment. How can we make it clearer for our future selves or other developers?

Consider updating the comment to be more specific:

jsEditor.EnableDisableAsyncFuncSettings("callAppsmithTed", false); // Async execution disabled; will be enabled when mapped to widget

This clarifies exactly what's happening and why. What do you think about this change?


79-83: Great job updating the widget and assertions! Let's polish it up a bit more.

You've done well updating the Input1 default value and the toast message assertion. These changes are consistent with our move to the TED API. However, let's think about how we can make our code even better.

  1. For the default value, consider using template literals for better readability:

    `{{${jsObjName}.callAppsmithTed.data}}`
  2. For the assertion, let's make it more specific:

    cy.get(locators._toastMsg)
      .should("contain", "AppsmithTed")
      .and("contain", jsName)
      .and("contain", "will be executed automatically on page load");

What do you think about these changes? How do they improve our code?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5995e42 and 73716f9.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JsOnLoad3_Spec.ts (3 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/client/cypress/e2e/Regression/ServerSide/OnLoadTests/JsOnLoad3_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/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 (2)
app/client/cypress/limited-tests.txt (2)

Line range hint 1-8: Class, let's review the importance of our instructions!

Now, children, I want you all to pay close attention to these instructions in our limited-tests.txt file. They're like the rules of our classroom - very important!

Remember:

  1. We use this file to run a limited set of tests.
  2. If you want to run all the tests, you need to uncomment that special line.
  3. The ci-test-limit command relies on this file, so we must keep it neat and tidy.

Let's all say it together: "We won't run the entire test suite with ci-test-limit!" Very good!


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

I'm pleased to see you've updated the test specification to focus on server-side testing. This aligns nicely with our lesson plan of replacing the 3rd party API with TED. Remember, children, when we make changes like this, it's important to ensure we're not leaving any gaps in our test coverage.

Let's do a quick pop quiz to make sure we haven't forgotten anything:

✅ Verification successful

Excellent work! The changes have been successfully verified.

You've correctly removed the old client-side test and added the new server-side test in the appropriate location. This ensures our test suite remains up-to-date and aligned with our project goals.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the old test file still exists and if the new test file is present

echo "Question 1: Is the old test file still in our project?"
fd --type f "Fork_Template_spec.js" || echo "Correct! The old file is no longer present."

echo "Question 2: Is our new test file where it should be?"
fd --type f "JsOnLoad3_Spec.ts" || echo "Oh dear, we might need to double-check our new file's location."

Length of output: 376

Copy link

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

reverted limited run file
@NandanAnantharamu NandanAnantharamu added the ok-to-test Required label for CI label Sep 30, 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