-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add cypress tests for Hubspot Datasource functionalities (#39419)
## Description This PR introduces cypress tests to ensure the functionality of the Hubspot datasource integration. 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="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/13516494494> > Commit: c0dbcc5 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13516494494&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Tue, 25 Feb 2025 08:50:28 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced HubSpot integration in the application with an improved configuration form supporting Bearer token authentication. - **Tests** - Added comprehensive end-to-end tests covering HubSpot datasource setup, query execution, widget data binding, deletion, and error handling scenarios. - **Chores** - Updated test specifications to include the new HubSpot tests and introduced a dedicated tag for easier test grouping. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Laveena Enid <[email protected]>
- Loading branch information
1 parent
5f3b6b8
commit 53223f9
Showing
4 changed files
with
198 additions
and
1 deletion.
There are no files selected for viewing
173 changes: 173 additions & 0 deletions
173
app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
import { | ||
agHelper, | ||
appSettings, | ||
dataSources, | ||
deployMode, | ||
draggableWidgets, | ||
entityExplorer, | ||
entityItems, | ||
locators, | ||
propPane, | ||
assertHelper, | ||
} 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", | ||
}); | ||
|
||
const fireApi = (retries = 5, responseTimeout = 100000) => { | ||
if (retries === 0) { | ||
throw new Error("Max retries reached, API did not return success."); | ||
} | ||
|
||
dataSources.RunQuery({ | ||
toValidateResponse: false, | ||
}); | ||
cy.wait(assertHelper.GetAliasName("@postExecute"), { | ||
timeout: responseTimeout, | ||
}) | ||
.then((interceptions) => { | ||
return cy | ||
.get(assertHelper.GetAliasName("@postExecute"), { | ||
timeout: responseTimeout, | ||
}) | ||
.its("response"); | ||
}) | ||
.then((response) => { | ||
const { isExecutionSuccess } = response.body.data; | ||
|
||
if (!isExecutionSuccess) { | ||
cy.log(`Retrying... Attempts left: ${retries - 1}`); | ||
assertHelper.Sleep(); | ||
fireApi(retries - 1); | ||
} else { | ||
expect(isExecutionSuccess).to.eq(true); | ||
} | ||
}); | ||
}; | ||
|
||
fireApi(5); | ||
// 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 | ||
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, | ||
}); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters