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: replaced 3rd party apit in treeSelect #36598

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Sep 29, 2024

Replaced 3rd Party API with TED
/ok-to-test tags="@tag.Select"

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11102740010
Commit: 692dd28
Cypress dashboard.
Tags: @tag.Select
Spec:


Mon, 30 Sep 2024 09:21:05 UTC

Copy link
Contributor

coderabbitai bot commented Sep 29, 2024

Walkthrough

The pull request introduces significant changes to the Cypress testing framework for the TreeSelect widget. It updates the API endpoint from a mock to a local Docker host, modifies data processing methods, and changes the image file format for the onOptionChange property. Additionally, it updates the path for a limited test specification, ensuring the correct test file is executed.

Changes

File(s) Change Summary
app/client/cypress/e2e/Regression/ClientSide/Widgets/TreeSelect/Tree_Select_2_spec.ts Updated API endpoint to a local Docker host, modified data processing logic, and changed image file format for onOptionChange.
app/client/cypress/limited-tests.txt Changed the test specification path from Fork_Template_spec.js to Tree_Select_2_spec.ts.

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test, Test

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

Poem

In the land of tests, a change took flight,
From mock to Docker, oh what a sight!
Data now dances, images anew,
TreeSelect shines bright, with a fresh view.
Paths updated, all in a row,
Testing's a journey, and off we go! 🌳✨


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=25

@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 29, 2024
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5995e42 and 26c35c2.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TreeSelect/Tree_Select_2_spec.ts (3 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TreeSelect/Tree_Select_2_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 (4)
app/client/cypress/limited-tests.txt (2)

2-2: Well done, class! Let's examine this change.

I'm pleased to see that you've updated the test specification path. This change aligns perfectly with our lesson on replacing the 3rd party API in treeSelect. Moreover, you've made an excellent decision to switch from JavaScript to TypeScript. Can anyone tell me why this is beneficial?


Line range hint 1-7: Excellent work on maintaining the file structure!

Class, I want you to notice how well-organized this file is. The comments clearly explain its purpose and how to use it. Remember, good documentation is just as important as good code. Keep up the good work!

app/client/cypress/e2e/Regression/ClientSide/Widgets/TreeSelect/Tree_Select_2_spec.ts (2)

Line range hint 1-438: Let's take a step back and look at the bigger picture of our test file.

I've noticed a few areas where we can improve our coding practices:

  1. I see you're using cy.wait in some places. Remember, we want to avoid using cy.wait in our Cypress tests. Instead, try using Cypress's built-in retry-ability and assertions to wait for elements or states.

  2. There are some hardcoded selectors in the test. We should be using data-* attributes for selectors to make our tests more robust and easier to maintain.

  3. I don't see any use of LoginFromAPI, LogOutviaAPI, or SignupFromAPI. If these are applicable to our test scenario, we should consider using them to improve test efficiency.

Let's work on refactoring these areas to align with our best practices. It will make our tests more reliable and easier to maintain in the long run.

Let's run a quick check to see how many times we're using cy.wait:

#!/bin/bash
# Count occurrences of cy.wait
grep -c "cy.wait" app/client/cypress/e2e/Regression/ClientSide/Widgets/TreeSelect/Tree_Select_2_spec.ts

This will give us an idea of how many instances we need to refactor.


173-175: Class, let's examine the changes in our API setup and data handling.

I see you've updated the API endpoint to use a local Docker host. While this might work for your current setup, it's important to consider the portability of our tests. Remember, good tests should be able to run in various environments!

As for the data mapping, you've made it more specific to the expected data structure. That's a step in the right direction, but let's make sure we're not making our tests too brittle. Can you explain your reasoning behind this change?

Let's run a quick check to see if this API is accessible:

This will help us understand if the new endpoint is reliable for our tests.

Also applies to: 186-186

Comment on lines +313 to 316
`{{download('http://host.docker.internal:4200/photo-1503469432756-4aae2e18d881.jpeg', 'flower.svg', 'image/svg+xml').then(() => {
showAlert('Download Success', '');
});}}`,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Now, let's turn our attention to the onOptionChange function, specifically the download part.

I notice you've changed the download URL to a JPEG image. That's fine, but your success message still talks about an SVG file. Remember, consistency is key in coding! Let's make sure our messages accurately reflect what we're doing.

Also, I'd like you to think about error handling here. What happens if the download fails? It's always good to plan for different scenarios!

Let's update the success message to match the file type:

-        `{{download('http://host.docker.internal:4200/photo-1503469432756-4aae2e18d881.jpeg', 'flower.svg', 'image/svg+xml').then(() => {
+        `{{download('http://host.docker.internal:4200/photo-1503469432756-4aae2e18d881.jpeg', 'flower.jpeg', 'image/jpeg').then(() => {
            showAlert('Download Success', '');
          });}}`,

This change ensures our message matches the actual file being downloaded.

📝 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
`{{download('http://host.docker.internal:4200/photo-1503469432756-4aae2e18d881.jpeg', 'flower.svg', 'image/svg+xml').then(() => {
showAlert('Download Success', '');
});}}`,
);
`{{download('http://host.docker.internal:4200/photo-1503469432756-4aae2e18d881.jpeg', 'flower.jpeg', 'image/jpeg').then(() => {
showAlert('Download Success', '');
});}}`,
);

Copy link

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

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=25

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11094221108.
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: 300 Total Passed: 300 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