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
This commit is contained in:
Aishwarya-U-R 2023-03-21 00:03:10 +05:30 committed by GitHub
parent b2828dfe93
commit cdce7ce51a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 59 additions and 60 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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

View File

@ -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 });

View File

@ -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(

View File

@ -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;

View File

@ -654,6 +654,10 @@ export class DataSources {
}: Partial<RunQueryParams> = {}) {
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",

View File

@ -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);
});
});
});