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: Add cypress tests for Hubspot Datasource functionalities #39383

Open
wants to merge 12 commits into
base: release
Choose a base branch
from

Conversation

laveena-en
Copy link
Contributor

@laveena-en laveena-en commented Feb 20, 2025

Signed-off-by: Laveena Enid [email protected]## Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
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=""

🔍 Cypress test results

Warning

Tests have not run on the HEAD e96cdde yet


Fri, 21 Feb 2025 16:34:19 UTC

Communication

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

Summary by CodeRabbit

  • New Features

    • Enhanced HubSpot datasource integration with support for bearer token authentication and visual cues.
  • Tests

    • Added comprehensive end-to-end tests to validate datasource configuration, query execution, widget binding, deletion, and error handling.
    • Introduced a dedicated HubSpot test tag for targeted test management.
    • Included HubSpot tests in the limited test run specifications.

Copy link
Contributor

coderabbitai bot commented Feb 20, 2025

Walkthrough

This pull request introduces a new Cypress test suite for validating Hubspot datasource functionality. The tests cover datasource configuration, query creation and execution, widget binding and deployment, datasource deletion, and error handling. Additionally, the changes add a new Hubspot API token property in the DataManager, extend the DataSources class with a new method for filling out Hubspot forms, and include a new tag for Hubspot tests.

Changes

File(s) Change Summary
app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts Adds a complete suite of E2E tests covering Hubspot datasource configuration, query execution, widget binding/deployment, datasource deletion, and misconfiguration error handling.
app/client/cypress/support/Objects/DataManager.ts Introduces a new property hubspotBearerToken to the dsValues object for both Production and Staging environments, using Cypress.env("HUBSPOT_TOKEN").
app/client/cypress/support/Pages/DataSources.ts Adds a new public method FillHubspotDSForm to automate filling the Hubspot datasource form, and introduces a new private variable _imgHubspotLogo that stores the XPath locator for the HubSpot logo.
app/client/cypress/tags.js Includes a new tag @tag.Hubspot in the Tag array for marking Hubspot-related tests.
app/client/cypress/limited-tests.txt Adds a new test specification for Hubspot in the limited tests context.

Possibly related PRs

Suggested labels

ok-to-test, Bug

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • NandanAnantharamu

Poem

In the realm of tests so bright,
Hubspot checks take flight,
From config to query’s call,
Widgets bound, errors fall,
A token added in the mix,
Cheers to seamless written clicks!
🚀🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ff2337 and e96cdde.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 Feb 20, 2025
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: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b07bb97 and d68d838.

📒 Files selected for processing (4)
  • app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts (1 hunks)
  • app/client/cypress/support/Objects/DataManager.ts (2 hunks)
  • app/client/cypress/support/Pages/DataSources.ts (2 hunks)
  • app/client/cypress/tags.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test ...

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
  • app/client/cypress/tags.js
  • app/client/cypress/support/Pages/DataSources.ts
  • app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
🔇 Additional comments (4)
app/client/cypress/tags.js (1)

29-29: LGTM! Tag added in correct alphabetical order.

app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts (1)

18-129: Well-structured test suite with comprehensive coverage!

The test suite effectively covers:

  • Datasource configuration validation
  • Query creation and execution
  • Widget binding and deployment
  • Datasource deletion
  • Error handling
app/client/cypress/support/Objects/DataManager.ts (1)

120-120: LGTM! Secure token handling using environment variables.

The Hubspot bearer token is properly managed using Cypress environment variables for both Production and Staging environments.

Also applies to: 222-222

app/client/cypress/support/Pages/DataSources.ts (1)

612-628: LGTM! Well-structured form fill method.

The FillHubspotDSForm method follows the established pattern and properly handles authentication type and bearer token.

dataSources.FillHubspotDSForm(undefined, "wrongpassword");
dataSources.SaveDatasource(false);
dataSources.CreateQueryForDS("Untitled datasource 1");
agHelper.RefreshPage(); // Refreshing the page due to frequent connection reset from Hubspot
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

Remove agHelper.RefreshPage() call.

Consider using proper wait conditions or retry mechanisms instead of refreshing the page to handle connection reset from Hubspot.

Comment on lines +59 to +61
PageLeftPane.switchSegment(PagePaneSegment.UI); // Switching the tab to ensure connection reset from Hubspot platform gets refreshed
PageLeftPane.switchSegment(PagePaneSegment.Queries);
cy.get("@postExecute").then((resObj: any) => {
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

Replace tab switching with proper wait conditions.

Instead of switching tabs to refresh connection, implement proper wait conditions or retry mechanisms.

-PageLeftPane.switchSegment(PagePaneSegment.UI); // Switching the tab to ensure connection reset from Hubspot platform gets refreshed
-PageLeftPane.switchSegment(PagePaneSegment.Queries);
+// Add proper wait condition for connection reset
+cy.wait("@hubspotConnection").its("response.statusCode").should("eq", 200);

Committable suggestion skipped: line range outside the PR's diff.

@@ -317,6 +317,7 @@ export class DataSources {
private _entityTriggerElement = ".t--template-menu-trigger";
_dsSchemaTableResponse = ".t--table-response";
_imgSnowflakeLogo = "//img[contains(@src, 'snowflake.svg')]";
_imgHubspotLogo = "//img[contains(@src, 'hubspot.png')]";
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

Replace XPath selector with data- attribute.*

Using XPath selectors is not recommended. Use data-* attributes instead.

-_imgHubspotLogo = "//img[contains(@src, 'hubspot.png')]";
+_imgHubspotLogo = "[data-testid='hubspot-logo-img']";
📝 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
_imgHubspotLogo = "//img[contains(@src, 'hubspot.png')]";
_imgHubspotLogo = "[data-testid='hubspot-logo-img']";

Signed-off-by: Laveena Enid <[email protected]>
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

🧹 Nitpick comments (1)
app/client/cypress/limited-tests.txt (1)

8-8: Comment Formatting Suggestion
The comment on this line could be slightly improved for clarity. For example, consider changing it to:
#ci-test-limit uses this file to run a minimal set of specs. Do not run the entire suite with this command.
This minor tweak improves readability.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~8-~8: Possible missing article found.
Context: ...ile to run minimum of specs. Do not run entire suite with this command.

(AI_HYDRA_LEO_MISSING_THE)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d68d838 and d73ccc7.

📒 Files selected for processing (1)
  • app/client/cypress/limited-tests.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test ...

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
🪛 LanguageTool
app/client/cypress/limited-tests.txt

[uncategorized] ~8-~8: Possible missing article found.
Context: ...ile to run minimum of specs. Do not run entire suite with this command.

(AI_HYDRA_LEO_MISSING_THE)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
🔇 Additional comments (1)
app/client/cypress/limited-tests.txt (1)

3-3: Hubspot Test Spec Inclusion
The new test specification for Hubspot is correctly added. Please ensure that the corresponding spec file (Hubspot_Spec.ts) adheres to Cypress best practices (e.g., using data-* attributes for selectors, avoiding cy.wait, etc.) in its implementation.

@laveena-en
Copy link
Contributor Author

/ci-test-limit-count run_count=1

Copy link

Copy link

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

@laveena-en
Copy link
Contributor Author

/ci-test-limit-count run_count=1

Copy link

Copy link

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

@laveena-en
Copy link
Contributor Author

/ci-test-limit-count run_count=1 update_snapshot=false specs_to_run=cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts

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

🧹 Nitpick comments (4)
app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts (4)

22-22: Remove unnecessary tags.

The tags @tag.Git and @tag.AccessControl seem unrelated to Hubspot datasource testing. Consider removing them to maintain accurate test categorization.

-    tags: ["@tag.Datasource", "@tag.Git", "@tag.AccessControl", "@tag.Hubspot"],
+    tags: ["@tag.Datasource", "@tag.Hubspot"],

84-91: Remove commented code block.

Remove the commented code block as it's no longer needed and can cause confusion.

-      // agHelper
-      //   .GetElement(locators._widgetInDeployed(draggableWidgets.TEXT))
-      //   .then(($elements) => {
-      //     const values = $elements
-      //       .map((_, el) => Cypress.$(el).text().trim())
-      //       .get();
-      //     expect(values).to.include("appsmith1");
-      //   });

64-69: Improve response validation.

Combine multiple assertions for more comprehensive validation of the response.

       cy.get("@postExecute").then((resObj: any) => {
         const json = resObj.response.body.data.body;
         const name = json.name;
-        cy.log("Name is :" + name);
-        expect(name).to.equal("appsmith1"); //Verify if record contains the table
+        expect(json).to.deep.include({
+          name: "appsmith1",
+          // Add more expected properties
+        });
       });

80-83: Use agHelper methods for widget assertions.

Replace direct cy.get calls with agHelper methods for consistent selector usage across tests.

-      cy.get(locators._widgetInDeployed(draggableWidgets.TEXT)).should(
-        "contain.text",
-        "appsmith1",
-      );
+      agHelper.AssertElementText(
+        locators._widgetInDeployed(draggableWidgets.TEXT),
+        "appsmith1"
+      );

Also applies to: 107-110

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d294197 and 0ff2337.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test ...

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/Datasources/Hubspot_Spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (2)
app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts (2)

125-125: Remove agHelper.RefreshPage() call.

Consider using proper wait conditions or retry mechanisms instead of refreshing the page to handle connection reset from Hubspot.


62-63: Replace tab switching with proper wait conditions.

Instead of switching tabs to refresh connection, implement proper wait conditions or retry mechanisms.

Copy link

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

@laveena-en
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=false runId=13453258787 specs_to_run=cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts

Copy link

Copy link

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

@laveena-en
Copy link
Contributor Author

/ci-test-limit-count run_count=5 update_snapshot=false runId=13453258787 specs_to_run=cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts

Copy link

Copy link

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

@laveena-en
Copy link
Contributor Author

/ci-test-limit-count run_count=1 update_snapshot=false specs_to_run=cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts

Copy link

Copy link

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

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 Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant