From b5af1a936f3adf27d3cb9c9738bd8526b4bc514c Mon Sep 17 00:00:00 2001 From: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Date: Fri, 4 Aug 2023 09:16:59 +0530 Subject: [PATCH] test: Cypress | CI Stabilize (#26000) ## Description - This pR improves FilterAndVerifyDatasourceSchemaBySearch() method - Alters locator for _datasourceTableSchemaInQueryEditor to narrow down the search result - Hence fixing /BugTests/DatasourceSchema_spec.ts() causing chrome crash in CI runs - Fixes ListV2/Event_Bindings_spec.ts #### Type of change - Script fix (non-breaking change which fixes an issue) - ## Testing > #### How Has This Been Tested? - [ ] Cypress local runs ## Checklist: #### QA activity: - [X] Added `Test Plan Approved` label after changes were reviewed --- .../BugTests/DatasourceSchema_spec.ts | 8 +-- .../Widgets/ListV2/Event_Bindings_spec.ts | 4 +- .../cypress/support/Pages/DataSources.ts | 54 +++++++++---------- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts index 8693f1437d..f43787fca4 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts @@ -72,11 +72,7 @@ describe("Datasource form related tests", function () { dataSources.VerifyTableSchemaOnQueryEditor("public.users"); entityExplorer.ExpandCollapseEntity("public.users"); dataSources.VerifyColumnSchemaOnQueryEditor("id"); - dataSources.FilterAndVerifyDatasourceSchemaBySearch( - "gender", - true, - "column", - ); + dataSources.FilterAndVerifyDatasourceSchemaBySearch("gender", "column"); }, ); @@ -126,10 +122,8 @@ describe("Datasource form related tests", function () { agHelper.RefreshPage(); dataSources.CreateDataSource("S3", true, false); dataSources.CreateQueryAfterDSSaved(); - dataSources.VerifyTableSchemaOnQueryEditor("appsmith-hris"); dataSources.FilterAndVerifyDatasourceSchemaBySearch( "appsmith-hris", - true, "table", ); }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Event_Bindings_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Event_Bindings_spec.ts index ff3f3dc9db..d7c8922273 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Event_Bindings_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Event_Bindings_spec.ts @@ -41,7 +41,9 @@ describe("Listv2 - Event bindings spec", () => { // click the button on inner list 1st row. agHelper.ClickButton("Submit"); - agHelper.ValidateToastMessage("Blue _ 001 _ 0 _ outer input _ inner input"); + agHelper.WaitUntilToastDisappear( + "Blue _ 001 _ 0 _ outer input _ inner input", + ); }); it("2. nested list - inner widget should get updated values of currentView and level_1", () => { diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index 87b874a6ff..e6a16677c2 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -32,7 +32,7 @@ interface RunQueryParams { export class DataSources { private agHelper = ObjectsRegistry.AggregateHelper; private table = ObjectsRegistry.Table; - private ee = ObjectsRegistry.EntityExplorer; + private entityExplorer = ObjectsRegistry.EntityExplorer; private locator = ObjectsRegistry.CommonLocators; private apiPage = ObjectsRegistry.ApiPage; private tedTestConfig = ObjectsRegistry.TEDTestConfigs; @@ -238,8 +238,8 @@ export class DataSources { "//p[contains(text(),'" + ddName + "')]/ancestor::div[@class='form-config-top']/following-sibling::div//div[contains(@class, 'rc-select-multiple')]"; - private _datasourceTableSchemaInQueryEditor = - ".datasourceStructure-query-editor"; + private _datasourceTableSchemaInQueryEditor = (schemaName: string) => + `//div[contains(@class, 'datasourceStructure-query-editor')]//div[contains(@class, 't--entity-name')][text()='${schemaName}']`; private _datasourceSchemaRefreshBtn = ".datasourceStructure-refresh"; private _datasourceStructureHeader = ".datasourceStructure-header"; private _datasourceColumnSchemaInQueryEditor = ".t--datasource-column"; @@ -255,7 +255,7 @@ export class DataSources { } public GeneratePageWithDB(datasourceName: any, tableName: string) { - this.ee.AddNewPage("Generate page with data"); + this.entityExplorer.AddNewPage("Generate page with data"); this.agHelper.GetNClick(this._selectDatasourceDropdown); this.agHelper.GetNClickByContains( this.locator._dropdownText, @@ -271,7 +271,7 @@ export class DataSources { } public GeneratePageWithMockDB() { - this.ee.AddNewPage("Generate page with data"); + this.entityExplorer.AddNewPage("Generate page with data"); this.agHelper.GetNClick(this._selectDatasourceDropdown); this.agHelper.GetNClickByContains( this._dropdownOption, @@ -394,7 +394,7 @@ export class DataSources { } public NavigateToDSCreateNew() { - this.ee.HoverOnEntityItem("Datasources"); + this.entityExplorer.HoverOnEntityItem("Datasources"); Cypress._.times(2, () => { this.agHelper.GetNClick(this._addNewDataSource, 0, true); this.agHelper.Sleep(); @@ -816,8 +816,8 @@ export class DataSources { dsName: string, expectedRes: number | number[] = 200, ) { - this.ee.SelectEntityByName(dsName, "Datasources"); - this.ee.ActionContextMenuByEntityName({ + this.entityExplorer.SelectEntityByName(dsName, "Datasources"); + this.entityExplorer.ActionContextMenuByEntityName({ entityNameinLeftSidebar: dsName, action: "Delete", entityType: EntityItems.Datasource, @@ -884,10 +884,10 @@ export class DataSources { } public AssertDSActive(dsName: string | RegExp) { - this.ee.NavigateToSwitcher("Explorer", 0, true); - this.ee.ExpandCollapseEntity("Datasources", false); - //this.ee.SelectEntityByName(datasourceName, "Datasources"); - //this.ee.ExpandCollapseEntity(datasourceName, false); + this.entityExplorer.NavigateToSwitcher("Explorer", 0, true); + this.entityExplorer.ExpandCollapseEntity("Datasources", false); + //this.entityExplorer.SelectEntityByName(datasourceName, "Datasources"); + //this.entityExplorer.ExpandCollapseEntity(datasourceName, false); this.NavigateToActiveTab(); return this.agHelper.GetNAssertContains(this._datasourceCard, dsName); } @@ -951,8 +951,8 @@ export class DataSources { } DeleteQuery(queryName: string) { - this.ee.ExpandCollapseEntity("Queries/JS"); - this.ee.ActionContextMenuByEntityName({ + this.entityExplorer.ExpandCollapseEntity("Queries/JS"); + this.entityExplorer.ActionContextMenuByEntityName({ entityNameinLeftSidebar: queryName, action: "Delete", entityType: EntityItems.Query, @@ -1245,7 +1245,7 @@ export class DataSources { sleep = 500, ) { this.agHelper.RemoveEvaluatedPopUp(); //to close the evaluated pop-up - this.ee.CreateNewDsQuery(dsName); + this.entityExplorer.CreateNewDsQuery(dsName); if (query) { this.EnterQuery(query, sleep); } @@ -1341,7 +1341,7 @@ export class DataSources { } else { this.SaveDatasource(); } - this.ee.ActionContextMenuByEntityName({ + this.entityExplorer.ActionContextMenuByEntityName({ entityNameinLeftSidebar: dataSourceName, action: "Refresh", }); @@ -1351,9 +1351,9 @@ export class DataSources { } public VerifyTableSchemaOnQueryEditor(schema: string) { - this.agHelper - .GetElement(this._datasourceTableSchemaInQueryEditor) - .contains(schema); + this.agHelper.AssertElementVisible( + this._datasourceTableSchemaInQueryEditor(schema), + ); } public VerifySchemaAbsenceInQueryEditor() { @@ -1381,17 +1381,15 @@ export class DataSources { public FilterAndVerifyDatasourceSchemaBySearch( search: string, - verifySearch = false, - filterBy: "table" | "column" = "column", + filterBy?: "table" | "column", ) { + this.agHelper.Sleep(2500); //for query editor to load this.agHelper.TypeText(this._datasourceStructureSearchInput, search); - - if (verifySearch) { - if (filterBy === "column") { - this.VerifyColumnSchemaOnQueryEditor(search); - } else { - this.VerifyTableSchemaOnQueryEditor(search); - } + this.agHelper.Sleep(); //for search result to load + if (filterBy === "column") { + this.VerifyColumnSchemaOnQueryEditor(search); + } else if (filterBy === "table") { + this.VerifyTableSchemaOnQueryEditor(search); } }