From 29619e137a96689a23dd8c89ed2abc95dde74572 Mon Sep 17 00:00:00 2001 From: Laveena Enid Date: Tue, 14 Jan 2025 16:34:36 +0530 Subject: [PATCH 1/7] change username to create PR for testing Signed-off-by: Laveena Enid --- app/client/cypress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress.config.ts b/app/client/cypress.config.ts index abe2c52c9fb1..c32bca4bc7fd 100644 --- a/app/client/cypress.config.ts +++ b/app/client/cypress.config.ts @@ -27,7 +27,7 @@ export default defineConfig({ e2e: { baseUrl: "https://dev.appsmith.com/", env: { - USERNAME: "xxxx", + USERNAME: "laveena@appsmith.com", PASSWORD: "xxx", grepFilterSpecs: true, grepOmitFiltered: true, From 2a271745be04dbd0e50215557e9802dd93eb961a Mon Sep 17 00:00:00 2001 From: Laveena Enid Date: Thu, 20 Feb 2025 13:56:41 +0530 Subject: [PATCH 2/7] added hubspot cypress tests Signed-off-by: Laveena Enid --- .../ServerSide/Datasources/Hubspot_Spec.ts | 130 ++++++++++++++++++ .../cypress/support/Objects/DataManager.ts | 4 + .../cypress/support/Pages/DataSources.ts | 18 +++ app/client/cypress/tags.js | 1 + 4 files changed, 153 insertions(+) create mode 100644 app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts diff --git a/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts new file mode 100644 index 000000000000..b154f722cc03 --- /dev/null +++ b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts @@ -0,0 +1,130 @@ +import { + agHelper, + 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(); + 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)); + + // Assert that the text widget contains the expected data + cy.get(locators._widgetInDeployed(draggableWidgets.TEXT)).should( + "contain.text", + "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, + }); + }); + }, +); diff --git a/app/client/cypress/support/Objects/DataManager.ts b/app/client/cypress/support/Objects/DataManager.ts index 87c02ae51a72..78b1e2242cd8 100644 --- a/app/client/cypress/support/Objects/DataManager.ts +++ b/app/client/cypress/support/Objects/DataManager.ts @@ -116,6 +116,8 @@ export class DataManager { Snowflake_role: "SYSADMIN", Snowflake_username: Cypress.env("SNOWFLAKE_USERNAME"), Snowflake_password: Cypress.env("SNOWFLAKE_PASSWORD"), + + hubspotBearerToken: Cypress.env("HUBSPOT_TOKEN"), }, Staging: { @@ -216,6 +218,8 @@ export class DataManager { Snowflake_role: "SYSADMIN", Snowflake_username: Cypress.env("SNOWFLAKE_USERNAME"), Snowflake_password: Cypress.env("SNOWFLAKE_PASSWORD"), + + hubspotBearerToken: Cypress.env("HUBSPOT_TOKEN"), }, }; diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index 8eb08005eae7..bd738b3c01c6 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -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')]"; _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, diff --git a/app/client/cypress/tags.js b/app/client/cypress/tags.js index e37aec5dd5e6..d40eb2e43e29 100644 --- a/app/client/cypress/tags.js +++ b/app/client/cypress/tags.js @@ -26,6 +26,7 @@ module.exports = { "@tag.GSheet", "@tag.GenerateCRUD", "@tag.Git", + "@tag.Hubspot", "@tag.IDE", "@tag.IconButton", "@tag.Iframe", From d68d83863a7cc18aa42f0a4ee30672f41492d3bb Mon Sep 17 00:00:00 2001 From: Laveena Enid Date: Thu, 20 Feb 2025 21:59:06 +0530 Subject: [PATCH 3/7] reverted config file Signed-off-by: Laveena Enid --- app/client/cypress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress.config.ts b/app/client/cypress.config.ts index c32bca4bc7fd..abe2c52c9fb1 100644 --- a/app/client/cypress.config.ts +++ b/app/client/cypress.config.ts @@ -27,7 +27,7 @@ export default defineConfig({ e2e: { baseUrl: "https://dev.appsmith.com/", env: { - USERNAME: "laveena@appsmith.com", + USERNAME: "xxxx", PASSWORD: "xxx", grepFilterSpecs: true, grepOmitFiltered: true, From d73ccc7e791dda32cd04292eb0deb8a8785d5af0 Mon Sep 17 00:00:00 2001 From: Laveena Enid Date: Fri, 21 Feb 2025 11:16:11 +0530 Subject: [PATCH 4/7] updated limited-tests.txt Signed-off-by: Laveena Enid --- app/client/cypress/limited-tests.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/client/cypress/limited-tests.txt b/app/client/cypress/limited-tests.txt index 8b8460be7ddb..8ff57793c176 100644 --- a/app/client/cypress/limited-tests.txt +++ b/app/client/cypress/limited-tests.txt @@ -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. \ No newline at end of file +#ci-test-limit uses this file to run minimum of specs. Do not run entire suite with this command. From d2941972d4f232a0922ca1dffc28fb6c5baeabbe Mon Sep 17 00:00:00 2001 From: Laveena Enid Date: Fri, 21 Feb 2025 12:56:17 +0530 Subject: [PATCH 5/7] added refresh due to hubspot connection being lost Signed-off-by: Laveena Enid --- .../e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts index b154f722cc03..100425d0c61e 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts +++ b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts @@ -71,7 +71,7 @@ describe( entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT); propPane.EnterJSContext("Text", "{{Api1.data}}"); deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.TEXT)); - + 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", From 0ff2337aa75d84f09b26a62bbfeff4eff4ab54f7 Mon Sep 17 00:00:00 2001 From: Laveena Enid Date: Fri, 21 Feb 2025 14:18:48 +0530 Subject: [PATCH 6/7] Updated the code to account for hubspot connection timeout Signed-off-by: Laveena Enid --- .../ServerSide/Datasources/Hubspot_Spec.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts index 100425d0c61e..4f657a8f5d7b 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts +++ b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts @@ -1,5 +1,6 @@ import { agHelper, + appSettings, dataSources, deployMode, draggableWidgets, @@ -56,6 +57,8 @@ describe( 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) => { @@ -71,12 +74,21 @@ describe( entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT); propPane.EnterJSContext("Text", "{{Api1.data}}"); deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.TEXT)); - agHelper.RefreshPage(); // Refreshing the page due to frequent connection reset from Hubspot + 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); }); From e96cdde9dee8287cff6f62d54be262c98258fb1e Mon Sep 17 00:00:00 2001 From: Laveena Enid Date: Fri, 21 Feb 2025 22:03:29 +0530 Subject: [PATCH 7/7] Updated the code to account for hubspot connection timeout Signed-off-by: Laveena Enid --- .../e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts index 4f657a8f5d7b..c1a26f083c06 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts +++ b/app/client/cypress/e2e/Regression/ServerSide/Datasources/Hubspot_Spec.ts @@ -59,6 +59,8 @@ describe( dataSources.RunQuery(); dataSources.RunQuery(); 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) => {