-
Notifications
You must be signed in to change notification settings - Fork 4.6k
test: Add cypress tests for Hubspot Datasource functionalities #39383
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
Changes from 11 commits
29619e1
f394f6d
f8dc3d0
e90393c
2a27174
21b87cc
07086b7
d68d838
d73ccc7
d294197
0ff2337
e96cdde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| import { | ||
| agHelper, | ||
| appSettings, | ||
| dataSources, | ||
| deployMode, | ||
| draggableWidgets, | ||
| entityExplorer, | ||
| entityItems, | ||
| locators, | ||
| propPane, | ||
| } from "../../../../support/Objects/ObjectsCore"; | ||
| import EditorNavigation, { | ||
| EntityType, | ||
| PageLeftPane, | ||
| PagePaneSegment, | ||
| } from "../../../../support/Pages/EditorNavigation"; | ||
| const myDsName = "HubspotDS"; | ||
|
|
||
| describe( | ||
| "Hubspot Basic Tests", | ||
| { | ||
| tags: ["@tag.Datasource", "@tag.Git", "@tag.AccessControl", "@tag.Hubspot"], | ||
| }, | ||
| () => { | ||
| it("1. Validate the configuration of Hubspot datasource", () => { | ||
| dataSources.NavigateToDSCreateNew(); | ||
| dataSources.CreatePlugIn("HubSpot"); | ||
| agHelper.AssertElementVisibility(dataSources._imgHubspotLogo, true, 0); // Ensure the Hubspot logo is visible | ||
| agHelper.GetNAssertContains(locators._dsName, "Untitled datasource 1"); | ||
|
|
||
| // Attempt to rename the datasource with invalid and valid names | ||
| agHelper.GetNClick(locators._dsName); | ||
| agHelper.ClearTextField(locators._dsNameTxt, true); | ||
| agHelper.AssertTooltip("Please enter a valid name"); | ||
| agHelper.PressEnter(); | ||
| agHelper.ValidateToastMessage("Invalid name"); | ||
| agHelper.GetNClick(locators._dsName); | ||
| agHelper.TypeText(locators._dsNameTxt, myDsName); | ||
| agHelper.PressEnter(); | ||
| agHelper.AssertElementVisibility(dataSources._datasourceCard, true); | ||
| // Fill out the Hubspot configuration form and save the datasource | ||
| dataSources.FillHubspotDSForm(); | ||
| dataSources.SaveDatasource(); | ||
| }); | ||
|
|
||
| it("2. Validate creating & running queries for the datasource", () => { | ||
| // Create and run a SELECT query, validating the response views | ||
| dataSources.CreateQueryForDS("HubspotDS"); | ||
| dataSources.ValidateNSelectDropdown( | ||
| "Commands", | ||
| "Please select an option", | ||
| "HubDB - get details of a published table", | ||
| ); | ||
| agHelper.EnterValue("appsmith1", { | ||
| propFieldName: "", | ||
| directInput: false, | ||
| inputFieldName: "Table ID or name", | ||
| }); | ||
| dataSources.RunQuery(); | ||
| dataSources.RunQuery(); | ||
| dataSources.RunQuery(); | ||
| 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) => { | ||
| 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 | ||
| }); | ||
| }); | ||
|
|
||
| it("3. Validate widget binding with queries & deploying the app", () => { | ||
| PageLeftPane.switchSegment(PagePaneSegment.UI); | ||
| entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT); | ||
| propPane.EnterJSContext("Text", "{{Api1.data}}"); | ||
| deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.TEXT)); | ||
| agHelper.AssertElementVisibility(appSettings.locators._header); | ||
| //agHelper.RefreshPage(); // Refreshing the page due to frequent connection reset from Hubspot | ||
| // Assert that the text widget contains the expected data | ||
| cy.get(locators._widgetInDeployed(draggableWidgets.TEXT)).should( | ||
| "contain.text", | ||
| "appsmith1", | ||
| ); | ||
| // agHelper | ||
| // .GetElement(locators._widgetInDeployed(draggableWidgets.TEXT)) | ||
| // .then(($elements) => { | ||
| // const values = $elements | ||
| // .map((_, el) => Cypress.$(el).text().trim()) | ||
| // .get(); | ||
| // expect(values).to.include("appsmith1"); | ||
| // }); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("Api1", EntityType.Query); | ||
| }); | ||
|
|
||
| it("4. Validate deleting the datasource", () => { | ||
| // Delete all queries associated with the datasource | ||
| PageLeftPane.selectItem("Api1", { ctrlKey: true, force: true }); | ||
| agHelper.ActionContextMenuWithInPane({ | ||
| action: "Delete", | ||
| entityType: entityItems.Query, | ||
| }); | ||
|
|
||
| // Delete the datasource and verify its removal | ||
| dataSources.DeleteDatasourceFromWithinDS(myDsName, 409); | ||
| deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.TEXT)); | ||
| cy.get(locators._widgetInDeployed(draggableWidgets.TEXT)).should( | ||
| "have.text", | ||
| "", | ||
| ); | ||
| deployMode.NavigateBacktoEditor(); | ||
| dataSources.DeleteDatasourceFromWithinDS(myDsName, 200); | ||
| agHelper.ValidateToastMessage( | ||
| "HubspotDS datasource deleted successfully", | ||
| ); | ||
| }); | ||
| it("5. Validate connection error when misconfiguring datasource", () => { | ||
| dataSources.NavigateToDSCreateNew(); | ||
| dataSources.CreatePlugIn("HubSpot"); | ||
| agHelper.GetNAssertContains(locators._dsName, "Untitled datasource 1"); | ||
| agHelper.AssertElementVisibility(dataSources._datasourceCard, true); | ||
| dataSources.FillHubspotDSForm(undefined, "wrongpassword"); | ||
| dataSources.SaveDatasource(false); | ||
| dataSources.CreateQueryForDS("Untitled datasource 1"); | ||
| agHelper.RefreshPage(); // Refreshing the page due to frequent connection reset from Hubspot | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| dataSources.ValidateNSelectDropdown( | ||
| "Commands", | ||
| "Please select an option", | ||
| "HubDB - get details of a published table", | ||
| ); | ||
| agHelper.EnterValue("appsmith1", { | ||
| propFieldName: "", | ||
| directInput: false, | ||
| inputFieldName: "Table ID or name", | ||
| }); | ||
| dataSources.RunQuery({ | ||
| expectedStatus: false, | ||
| toValidateResponse: true, | ||
| }); | ||
| }); | ||
| }, | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| # To run only limited tests - give the spec names in below format: | ||
| #cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js | ||
| cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts | ||
| # For running all specs - uncomment below: | ||
| #cypress/e2e/**/**/* | ||
| cypress/e2e/Regression/ClientSide/Anvil/Widgets/* | ||
|
|
||
| #ci-test-limit uses this file to run minimum of specs. Do not run entire suite with this command. | ||
| #ci-test-limit uses this file to run minimum of specs. Do not run entire suite with this command. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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')]"; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||
| _dsConfigProperties = (index: number) => | ||||||
| "input[name*='datasourceConfiguration.properties[" + index + "]']"; | ||||||
| _dsConfigAuthType = `[data-testid*='datasourceConfiguration.authentication.authenticationType']`; | ||||||
|
|
@@ -608,6 +609,23 @@ export class DataSources { | |||||
| : password, | ||||||
| ); | ||||||
| } | ||||||
| public FillHubspotDSForm( | ||||||
| environment = this.dataManager.defaultEnviorment, | ||||||
| password = "", | ||||||
| ) { | ||||||
| this.ValidateNSelectDropdown( | ||||||
| "Authentication type", | ||||||
| "Please select an option", | ||||||
| "Bearer token", | ||||||
| ); | ||||||
| this.agHelper.TypeText( | ||||||
| this.locator._inputFieldByName("Bearer token") + | ||||||
| "//" + | ||||||
| this.locator._inputField, | ||||||
| !password ? this.dataManager.dsValues[environment].hubspotBearerToken : password, | ||||||
| ); | ||||||
| this.agHelper.Sleep(); | ||||||
| } | ||||||
|
|
||||||
| public FillMongoDSForm( | ||||||
| environment = this.dataManager.defaultEnviorment, | ||||||
|
|
||||||
There was a problem hiding this comment.
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.