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 DS test and common method #36204

Closed
wants to merge 2 commits into from

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Sep 9, 2024

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of data source schema tests by ensuring correct UI interactions and logical flow.
    • Enhanced verification process by checking for the absence of loading spinners before data verification.
  • New Features

    • Updated search functionality in data sources to clear existing text before inputting new search terms, improving search accuracy.

Warning

Tests have not run on the HEAD 7e15730 yet


Mon, 09 Sep 2024 14:43:48 UTC

Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

The pull request implements changes to the DatasourceSchema_spec.ts file, refining the logic for data source schema verification. Key updates include improved navigation to UI elements and a more structured sequence of operations that checks the UI state before verification. Additionally, the DataSources class in DataSources.ts has been modified to replace the TypeText method with ClearNType, ensuring the search input is cleared prior to new entries. These modifications are aimed at enhancing the reliability and accuracy of the tests.

Changes

File Path Change Summary
app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts Enhanced schema verification logic with improved UI navigation and control flow adjustments.
app/client/cypress/support/Pages/DataSources.ts Modified text input method from TypeText to ClearNType for more accurate search functionality.

Possibly related PRs

Suggested labels

ok-to-test, Anvil team

Poem

In the realm of tests, where logic flows,
Changes made to help the schema grow.
Clear and type, a method refined,
Ensuring accuracy, all aligned.
With each new line, our tests take flight,
A brighter future, in code's soft light! ✨

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

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 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 9, 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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1cf452f and 2e377ee.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts (3 hunks)
  • app/client/cypress/support/Pages/DataSources.ts (1 hunks)
Additional context used
Path-based instructions (2)
app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_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/Pages/DataSources.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.
Additional comments not posted (4)
app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts (4)

6-6: Use of locator variables is approved.

The addition of locators to the import list aligns with best practices for Cypress tests, ensuring that selectors are managed centrally and not hardcoded throughout the test cases.


75-75: Good use of data attributes for selectors.

Using data-testid attributes for selectors is a best practice in testing because it decouples the test selectors from CSS classes and IDs that may change with CSS changes. This practice enhances the maintainability of the tests.

Also applies to: 93-93


80-81: Ensure multiple assertions per test case.

It's good to see multiple assertions being used in the test cases. This practice helps ensure that the tests are robust and can catch multiple issues in one run. However, make sure that the assertions are not overly dependent on each other, which could lead to cascading test failures if one assertion fails.

Also applies to: 98-98


74-74: Avoid using explicit waits like agHelper.Sleep(1500).

Using explicit waits can lead to brittle tests that may fail unpredictably depending on external factors like network latency or processing speed. Instead, consider using Cypress's built-in wait mechanisms to wait for specific conditions or elements to be ready.

Here's a suggested refactor to use a more reliable waiting mechanism:

- agHelper.Sleep(1500);
+ cy.wait('@getDatasourceStructure');

Also applies to: 92-92

Skipped due to learnings
Learnt from: sagar-qa007
PR: appsmithorg/appsmith#35412
File: app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/TableWidget/mysql_spec.ts:99-99
Timestamp: 2024-08-06T05:59:19.000Z
Learning: In Cypress tests within the `app/client/cypress` directory, avoid using `agHelper.Sleep`, `this.Sleep`, and other related sleep functions to prevent non-deterministic behaviors and ensure tests are more reliable and maintainable. Instead, use Cypress methods like `cy.get()`, `cy.contains()`, and `cy.intercept()` to wait for specific conditions.
Learnt from: ApekshaBhosale
PR: appsmithorg/appsmith#35412
File: app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/TableWidget/mysql_spec.ts:99-99
Timestamp: 2024-08-06T05:39:47.929Z
Learning: In Cypress tests, avoid using `agHelper.Sleep` as it can lead to flaky tests and unnecessary delays. Instead, use Cypress methods like `cy.get()`, `cy.contains()`, and `cy.intercept()` to wait for specific conditions.
Learnt from: sagar-qa007
PR: appsmithorg/appsmith#34955
File: app/client/cypress/e2e/Regression/ClientSide/ActionExecution/General_settingsTe_Spec.ts:33-33
Timestamp: 2024-07-16T08:25:23.799Z
Learning: Avoid using sleep functions like `agHelper.Sleep` and `this.Sleep` in Cypress tests within the `app/client/cypress` directory to prevent non-deterministic behaviors and ensure tests are more reliable and maintainable.
Learnt from: sagar-qa007
PR: appsmithorg/appsmith#34955
File: app/client/cypress/e2e/Regression/ClientSide/ActionExecution/General_settings_Spec.ts:14-56
Timestamp: 2024-07-16T06:44:55.263Z
Learning: Avoid using sleep functions like `agHelper.Sleep`, `this.Sleep` in Cypress tests within the `app/client/cypress` directory to prevent non-deterministic behaviors and ensure tests are more reliable and maintainable.
Learnt from: sagar-qa007
PR: appsmithorg/appsmith#34955
File: app/client/cypress/e2e/Regression/ClientSide/ActionExecution/General_settings_Spec.ts:14-56
Timestamp: 2024-07-16T06:48:43.110Z
Learning: Learnt from: sagar-qa007
PR: appsmithorg/appsmith#34955
File: app/client/cypress/e2e/Regression/ClientSide/ActionExecution/General_settings_Spec.ts:14-56
Timestamp: 2024-07-16T06:44:55.118Z
Learning: Avoid using sleep functions like `agHelper.Sleep`, `this.Sleep`, and other related sleep functions in Cypress tests within the `app/client/cypress` directory to prevent non-deterministic behaviors and ensure tests are more reliable and maintainable.

@@ -1373,7 +1373,7 @@ export class DataSources {
expectedTableName = search,
) {
this.agHelper.Sleep(2500); //for query editor to load
this.agHelper.TypeText(this._datasourceStructureSearchInput, search);
this.agHelper.ClearNType(this._datasourceStructureSearchInput, search);
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 to replace explicit waits with conditional waits.

Using explicit waits like agHelper.Sleep(1000) can lead to non-deterministic test behaviors and longer than necessary test times. Consider using Cypress's conditional waiting features to wait for specific conditions or elements to be ready.

Here's a suggested refactor:

- agHelper.Sleep(1000); //for search result to load
+ cy.wait('@searchResults'); // Assuming an alias for the search network call

Committable suggestion was skipped due to low confidence.

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

Copy link

github-actions bot commented Sep 9, 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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2e377ee and 7e15730.

Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts (3 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Pages/DataSources.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/cypress/limited-tests.txt
Files skipped from review as they are similar to previous changes (2)
  • app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts
  • app/client/cypress/support/Pages/DataSources.ts

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit runId=10775575341

4 similar comments
@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit runId=10775575341

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit runId=10775575341

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit runId=10775575341

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit runId=10775575341

Copy link

github-actions bot commented Sep 9, 2024

Copy link

github-actions bot commented Sep 9, 2024

Copy link

github-actions bot commented Sep 9, 2024

Copy link

github-actions bot commented Sep 9, 2024

Copy link

github-actions bot commented Sep 9, 2024

Copy link

github-actions bot commented Sep 9, 2024

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

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 Sep 16, 2024
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Sep 24, 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