From cdce7ce51a18f5785a76c0ce5286affe2d59db75 Mon Sep 17 00:00:00 2001 From: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Date: Tue, 21 Mar 2023 00:03:10 +0530 Subject: [PATCH] test: Cypress - flaky fix (#21585) ## Description - This PR fixes the below flaky tests: - pagesize_spec.js - List4_spec.js - UpdateWorkspaceTests_spec.js - CodeScanner_spec.js - Entity_Explorer_Query_Datasource_spec.js - DiscardChanges_spec.js ## Type of change - Script fix ## How Has This Been Tested? - Cypress run - local ## Checklist: ### QA activity: - [X] Added Test Plan Approved label after reveiwing all Cypress test --- .../Entity_Explorer_Query_Datasource_spec.js | 5 ++- .../GitDiscardChange/DiscardChanges_spec.js | 41 ++++--------------- .../Widgets/CodeScanner/CodeScanner_spec.js | 1 + .../Widgets/TableV2/pagesize_spec.js | 3 ++ .../Workspace/UpdateWorkspaceTests_spec.js | 11 ++--- .../Datasources/Airtable_Basic_Spec.ts | 34 ++++++++------- .../cypress/support/Pages/DataSources.ts | 4 ++ app/client/cypress/support/widgetCommands.js | 20 +++++---- 8 files changed, 59 insertions(+), 60 deletions(-) diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js index 3f0cb422e7..9e6f2e9d75 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Query_Datasource_spec.js @@ -8,6 +8,8 @@ const pages = require("../../../../locators/Pages.json"); import { ObjectsRegistry } from "../../../../support/Objects/Registry"; let ee = ObjectsRegistry.EntityExplorer; +let agHelper = ObjectsRegistry.AggregateHelper; + const pageid = "MyPage"; let datasourceName; @@ -96,10 +98,11 @@ describe("Entity explorer tests related to query and datasource", function () { expect($lis.eq(3)).to.contain("{{Query1.run()}}"); expect($lis.eq(4)).to.contain("{{Query1.clear()}}"); }); + cy.get(".t--entity-property-close").click(); //closing Bindings overlay ee.ActionContextMenuByEntityName("Query1", "Edit Name"); cy.EditApiNameFromExplorer("MyQuery"); ee.ActionContextMenuByEntityName("MyQuery", "Move to page", pageid); - cy.get(".t--entity-name").contains("MyQuery").click(); + ee.SelectEntityByName("MyQuery"); cy.wait(2000); cy.runQuery(); diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Git/GitDiscardChange/DiscardChanges_spec.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Git/GitDiscardChange/DiscardChanges_spec.js index a03b4eb7ea..547f89e06f 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Git/GitDiscardChange/DiscardChanges_spec.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Git/GitDiscardChange/DiscardChanges_spec.js @@ -16,41 +16,16 @@ describe("Git discard changes:", function () { it("1. Create an app with Query1 and JSObject1, connect it to git", () => { // Create new postgres datasource - cy.NavigateToDatasourceEditor(); - cy.get(datasource.PostgreSQL).click(); - cy.fillPostgresDatasourceForm(); - cy.testSaveDatasource(); - - // go back to active ds list - _.dataSources.NavigateToActiveTab(); - - cy.get("@saveDatasource").then((httpResponse) => { - datasourceName = httpResponse.response.body.data.name; - - cy.get(datasource.datasourceCard) - .contains(datasourceName) - .scrollIntoView() - .should("be.visible") - .closest(datasource.datasourceCard) - .within(() => { - cy.get(datasource.createQuery).click(); - }); + _.dataSources.CreateDataSource("Postgres"); + cy.get("@dsName").then(($dsName) => { + datasourceName = $dsName; + _.dataSources.CreateQueryAfterDSSaved( + "SELECT * FROM users ORDER BY id LIMIT 10;", + query1, + ); + _.dataSources.RunQuery(); }); - // Create new postgres query - cy.get(queryLocators.queryNameField).type(`${query1}`); - cy.get(queryLocators.switch).last().click({ force: true }); - cy.get(queryLocators.templateMenu).click(); - cy.get(queryLocators.query).click({ force: true }); - cy.get(".CodeMirror textarea") - .first() - .focus() - .type("SELECT * FROM users ORDER BY id LIMIT 10;", { - force: true, - parseSpecialCharSequences: false, - }); - cy.WaitAutoSave(); - cy.runQuery(); cy.CheckAndUnfoldEntityItem("Pages"); cy.wait(1000); diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/CodeScanner/CodeScanner_spec.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/CodeScanner/CodeScanner_spec.js index 3e4ad93d8b..a029acafac 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/CodeScanner/CodeScanner_spec.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/CodeScanner/CodeScanner_spec.js @@ -49,6 +49,7 @@ describe("Code Scanner widget's functionality", () => { it("3.1.1.2 => Scanner should not be scanning and streaming video", () => { // Video should NOT be streaming + cy.wait(2000); //for deployed page to laod completey cy.get(codeScannerVideoOnPublishPage).should("not.exist"); // Back to editor diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/TableV2/pagesize_spec.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/TableV2/pagesize_spec.js index d05a6dbdbf..d2feaf062e 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/TableV2/pagesize_spec.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Widgets/TableV2/pagesize_spec.js @@ -11,7 +11,10 @@ describe("Table widget v2", function () { cy.openPropertyPane("tablewidgetv2"); cy.moveToStyleTab(); + cy.wait(1000); //for style tab to settle + cy.get(".t--button-group-SHORT").should("be.visible"); cy.get(".t--button-group-SHORT").click(); + cy.wait(1000); //for table to-align to Short click cy.get(".t--widget-textwidget .bp3-ui-text").should("contain", "7"); cy.get(".t--button-group-DEFAULT").click({ force: true }); diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Workspace/UpdateWorkspaceTests_spec.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Workspace/UpdateWorkspaceTests_spec.js index c05fd4b846..bd107b2bae 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Workspace/UpdateWorkspaceTests_spec.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Workspace/UpdateWorkspaceTests_spec.js @@ -1,4 +1,5 @@ import homePage from "../../../../locators/HomePage"; +import * as _ from "../../../../support/Objects/ObjectsCore"; describe("Update Workspace", function () { let workspaceId; @@ -38,12 +39,12 @@ describe("Update Workspace", function () { }); it("2. Open the workspace general settings and update workspace email. The update should reflect in the workspace.", function () { - cy.createWorkspace(); - cy.wait("@createWorkspace").then((interception) => { - newWorkspaceName = interception.response.body.data.name; - cy.renameWorkspace(newWorkspaceName, workspaceId); - cy.get(homePage.workspaceSettingOption).click({ force: true }); + _.agHelper.GenerateUUID(); + cy.get("@guid").then((uid) => { + newWorkspaceName = "SettingsUpdate" + uid; + _.homePage.CreateNewWorkspace(newWorkspaceName); }); + cy.get(homePage.workspaceSettingOption).click({ force: true }); cy.get(homePage.workspaceEmailInput).clear(); cy.get(homePage.workspaceEmailInput).type(Cypress.env("TESTUSERNAME2")); cy.wait("@updateWorkspace").should( diff --git a/app/client/cypress/integration/Regression_TestSuite/ServerSideTests/Datasources/Airtable_Basic_Spec.ts b/app/client/cypress/integration/Regression_TestSuite/ServerSideTests/Datasources/Airtable_Basic_Spec.ts index 1d771d9cc9..4975ab5f6b 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ServerSideTests/Datasources/Airtable_Basic_Spec.ts +++ b/app/client/cypress/integration/Regression_TestSuite/ServerSideTests/Datasources/Airtable_Basic_Spec.ts @@ -38,7 +38,7 @@ describe("Validate Airtable Ds", () => { jsonSpecies.records.forEach((record: { fields: any }) => { specieslist.push(record.fields.Species_ID); }); - expect(specieslist.length).eq(53); //making sure all fields are returned + expect(specieslist.length).to.be.at.least(53); //making sure all fields are returned }); //Filter Species_ID & Species fields only @@ -51,7 +51,7 @@ describe("Validate Airtable Ds", () => { }, ); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); const hasOnlyAllowedKeys = jsonSpecies.records.every((record: any) => { @@ -77,7 +77,7 @@ describe("Validate Airtable Ds", () => { directInput: false, inputFieldName: "Page Size", }); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); expect(jsonSpecies.records.length).to.eq(11); //making sure only 11 record fields are returned @@ -89,8 +89,7 @@ describe("Validate Airtable Ds", () => { directInput: false, inputFieldName: "Page Size", }); - - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); expect(jsonSpecies.records.length).to.eq(6); //making sure only 6 record fields are returned, honouring the PageSize @@ -102,8 +101,8 @@ describe("Validate Airtable Ds", () => { directInput: false, inputFieldName: "Offset", }); + _.dataSources.RunQuery(); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); expect(jsonSpecies.records.length).to.eq(5); //making sure only remaining records are returned @@ -122,8 +121,8 @@ describe("Validate Airtable Ds", () => { directInput: false, inputFieldName: "Filter by Formula", }); + _.dataSources.RunQuery(); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); const allRecordsWithRodentTaxa = jsonSpecies.records.filter( @@ -156,7 +155,8 @@ describe("Validate Airtable Ds", () => { inputFieldName: "Sort", }); //Sort by default ascending, descneding is thrown error, checking with Felix - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); + cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); const sorted = jsonSpecies.records.every( @@ -190,7 +190,8 @@ describe("Validate Airtable Ds", () => { }, ); //Sort by descending - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); + cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); const sorted = jsonSpecies.records.every( @@ -228,7 +229,8 @@ describe("Validate Airtable Ds", () => { inputFieldName: "View", }); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); + cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); const isJSONValid = jsonSpecies.records.every( @@ -264,7 +266,8 @@ describe("Validate Airtable Ds", () => { }); _.agHelper.Sleep(500); // for the Records field to settle - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); + cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); //cy.log("jsonSpecies is"+ jsonSpecies) @@ -283,7 +286,8 @@ describe("Validate Airtable Ds", () => { inputFieldName: "Record ID ", }); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); + cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); const hasOnlyInsertedRecord = () => { @@ -318,7 +322,8 @@ describe("Validate Airtable Ds", () => { }, ); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); + cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); const hasOnlyUpdatedRecord = () => { @@ -340,7 +345,8 @@ describe("Validate Airtable Ds", () => { "Delete A Record", ); - _.dataSources.RunQuery({ waitTimeInterval: 2000 }); + _.dataSources.RunQuery(); + cy.get("@postExecute").then((resObj: any) => { jsonSpecies = JSON.parse(resObj.response.body.data.body); expect(jsonSpecies.deleted).to.be.true; diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index f80b4efb54..07e514d598 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -654,6 +654,10 @@ export class DataSources { }: Partial = {}) { this.agHelper.GetNClick(this._runQueryBtn, 0, true, waitTimeInterval); if (toValidateResponse) { + this.agHelper.AssertElementAbsence( + this.locator._cancelActionExecution, + 10000, + ); //For the run to give response this.agHelper.Sleep(); this.agHelper.ValidateNetworkExecutionSuccess( "@postExecute", diff --git a/app/client/cypress/support/widgetCommands.js b/app/client/cypress/support/widgetCommands.js index f13c88098e..fc55e74374 100644 --- a/app/client/cypress/support/widgetCommands.js +++ b/app/client/cypress/support/widgetCommands.js @@ -1199,9 +1199,12 @@ Cypress.Commands.add("copyWidget", (widget, widgetLocator) => { .last() .invoke("text") .then((x) => { - cy.log(x); - let originalWidget = x.replaceAll("x", ""); - originalWidget = originalWidget.replaceAll(/\u200B/g, ""); + //cy.log(x); + let originalWidget = x + .replaceAll("x", "") + .replaceAll(/\u200B/g, "") + .replaceAll("\n", "") + .replaceAll("/Type / to access quick commands", ""); cy.log(originalWidget); cy.get(widgetsPage.copyWidget).click({ force: true }); cy.wait(3000); @@ -1217,11 +1220,14 @@ Cypress.Commands.add("copyWidget", (widget, widgetLocator) => { .last() .invoke("text") .then((y) => { - cy.log(y); - let copiedWidget = y.replaceAll("x", ""); - copiedWidget = copiedWidget.replaceAll(/\u200B/g, ""); + //cy.log(y); + let copiedWidget = y + .replaceAll("x", "") + .replaceAll(/\u200B/g, "") + .replaceAll("\n", "") + .replaceAll("/Type / to access quick commands", ""); cy.log(copiedWidget); - expect(originalWidget).to.be.equal(copiedWidget); + expect(originalWidget).to.equal(copiedWidget); }); }); });