test: Cypress - Flaky test fix (#23917)

## Description

**Fixed below flaky tests**

- Button_Text_WithRecaptcha_spec.js
- Fork_Template_Existing_app_spec.js
- Listv2_BasicServerSideData_spec.js

## Type of change

- Flaky test fix

## How Has This Been Tested?
- Cypress test runs

## Checklist:
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
This commit is contained in:
Vijetha-Kaja 2023-06-02 17:15:21 +05:30 committed by GitHub
parent eac743ff6d
commit 1f94651784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 109 additions and 155 deletions

View File

@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
job: [0, 1, 2, 3, 4]
job: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
# Service containers to run with this job. Required for running tests
services:

View File

@ -22,10 +22,7 @@ describe("Shopping cart App", function () {
});
it("1. Create MongoDB datasource and add Insert, Find, Update and Delete queries", function () {
cy.NavigateToDatasourceEditor();
cy.get(datasource.MongoDB).click();
cy.fillMongoDatasourceForm();
cy.testSaveDatasource();
_.dataSources.CreateDataSource("Mongo");
cy.get("@saveDatasource").then((httpResponse) => {
datasourceName = httpResponse.response.body.data.name;
});
@ -125,27 +122,29 @@ describe("Shopping cart App", function () {
_.deployMode.DeployApp(appPage.bookname);
});
it.skip("2. Perform CRUD operations and validate data", function () {
it("2. Perform CRUD operations and validate data", function () {
// Adding the books to the Add cart form
_.agHelper.GetNClick(appPage.bookname);
//Wait for element to be in DOM
_.agHelper.Sleep(3000);
_.agHelper.UpdateInput(appPage.bookname, "Atomic habits", true);
_.agHelper.UpdateInput(appPage.bookgenre, "Self help", true);
_.agHelper.UpdateInput(appPage.bookprice, 200, true);
_.agHelper.UpdateInput(appPage.bookquantity, 2, true);
cy.get("span:contains('Submit')").closest("div").eq(1).click();
cy.assertPageSave();
cy.wait(8000);
_.agHelper.GetNClick(appPage.addButton, 0, true);
cy.wait("@postExecute");
cy.wait(3000);
_.agHelper.UpdateInput(appPage.bookname, "A man called ove", true);
_.agHelper.UpdateInput(appPage.bookgenre, "Fiction", true);
_.agHelper.UpdateInput(appPage.bookprice, 100, true);
_.agHelper.UpdateInput(appPage.bookquantity, 1, true);
cy.get("span:contains('Submit')").closest("div").eq(1).click();
cy.assertPageSave();
_.agHelper.GetNClick(appPage.addButton, 0, true);
cy.wait("@postExecute");
// Deleting the book from the cart
cy.get(".tableWrap")
.children()
.within(() => {
cy.get("span:contains('Delete')").closest("div").eq(1).click();
_.agHelper.GetNClick(appPage.deleteButton, 1, false);
cy.wait("@postExecute");
cy.wait(5000);
@ -156,14 +155,19 @@ describe("Shopping cart App", function () {
});
// Updating the book quantity from edit cart
_.agHelper.UpdateInput(appPage.editbookquantity, 3, true);
cy.get("span:contains('Submit')").closest("div").eq(0).click();
cy.assertPageSave();
cy.wait(5000);
_.agHelper.GetNClick(appPage.editButton, 0, true);
_.agHelper.AssertAutoSave();
_.agHelper.ValidateNetworkExecutionSuccess("@postExecute");
cy.get("@postExecute.last")
.its("response.body")
.then((user) => {
expect(user.data.body[0].quantity).to.equal("3");
});
// validating updated value in the cart
cy.get(".selected-row").children().eq(3).should("have.text", "3");
});
it.skip("3. Connect the appplication to git and validate data in deploy mode and edit mode", function () {
it("3. Connect the appplication to git and validate data in deploy mode and edit mode", function () {
cy.get(".t--back-to-editor").click();
_.gitSync.CreateNConnectToGit(repoName);
cy.get("@gitRepoName").then((repName) => {
@ -185,6 +189,6 @@ describe("Shopping cart App", function () {
after(() => {
//clean up
// _.gitSync.DeleteTestGithubRepo(repoName);
_.gitSync.DeleteTestGithubRepo(repoName);
});
});

View File

@ -1,25 +1,20 @@
const queryLocators = require("../../../../locators/QueryEditor.json");
const datasource = require("../../../../locators/DatasourcesEditor.json");
import { ObjectsRegistry } from "../../../../support/Objects/Registry";
import * as _ from "../../../../support/Objects/ObjectsCore";
const locator = ObjectsRegistry.CommonLocators;
let datasourceName;
describe("SQL Autocompletion", function () {
it("Shows autocompletion hints", function () {
cy.NavigateToDatasourceEditor();
cy.get(datasource.PostgreSQL).click({ force: true });
cy.fillPostgresDatasourceForm();
_.dataSources.CreateDataSource("Postgres");
cy.generateUUID().then((uid) => {
datasourceName = `Postgres CRUD ds ${uid}`;
cy.renameDatasource(datasourceName);
cy.testSaveDatasource();
cy.NavigateToActiveDSQueryPane(datasourceName);
});
cy.get(queryLocators.templateMenu).click({ force: true });
cy.get(".CodeMirror textarea").focus().type("S");
cy.get(locator._hints).should("exist");
cy.get(_.locators._hints).should("exist");
cy.deleteQueryUsingContext();
});
});

View File

@ -98,10 +98,20 @@ describe(
_.agHelper.SelectDropdownList("Google reCAPTCHA version", "reCAPTCHA v3");
_.agHelper.ClickButton("Submit");
_.agHelper.Sleep();
_.agHelper.AssertElementAbsence(
_.locators._specificToast("Google Re-Captcha token generation failed!"),
5000,
);
cy.get("body").then(($ele) => {
if (
$ele.find(
_.locators._specificToast(
"Google Re-Captcha token generation failed!",
),
).length ||
$ele
.find(_.locators._widgetInCanvas("textwidget") + " span")
.text() == ""
) {
_.agHelper.ClickButton("Submit");
}
});
_.agHelper
.GetText(_.locators._widgetInCanvas("textwidget") + " span")
.should("not.be.empty");

View File

@ -1,5 +1,6 @@
import * as _ from "../../../../support/Objects/ObjectsCore";
import { Widgets } from "../../../../support/Pages/DataSources";
import datasourceFormData from "../../../../fixtures/datasources.json";
import {
ERROR_ACTION_EXECUTE_FAIL,
@ -8,7 +9,7 @@ import {
describe("API Bugs", function () {
it("1. Bug 14037: User gets an error even when table widget is added from the API page successfully", function () {
_.apiPage.CreateAndFillApi("https://mock-api.appsmith.com/users", "Api1");
_.apiPage.CreateAndFillApi(datasourceFormData.mockApiUrl, "Api1");
_.apiPage.RunAPI();
_.dataSources.AddSuggesstedWidget(Widgets.Table);

View File

@ -1,9 +1,7 @@
const queryLocators = require("../../../../locators/QueryEditor.json");
const datasource = require("../../../../locators/DatasourcesEditor.json");
const apiwidget = require("../../../../locators/apiWidgetslocator.json");
import { ObjectsRegistry } from "../../../../support/Objects/Registry";
let ee = ObjectsRegistry.EntityExplorer;
import * as _ from "../../../../support/Objects/ObjectsCore";
const pageid = "MyPage";
let updatedName;
@ -22,11 +20,8 @@ describe("Entity explorer tests related to copy query", function () {
it("1. Create a query with dataSource in explorer, Create new Page", function () {
cy.Createpage(pageid);
ee.SelectEntityByName("Page1");
cy.NavigateToDatasourceEditor();
cy.get(datasource.PostgreSQL).click();
cy.fillPostgresDatasourceForm();
cy.testSaveDatasource();
_.entityExplorer.SelectEntityByName("Page1");
_.dataSources.CreateDataSource("Postgres");
cy.get("@saveDatasource").then((httpResponse) => {
datasourceName = httpResponse.response.body.data.name;
@ -47,8 +42,8 @@ describe("Entity explorer tests related to copy query", function () {
cy.get(".t--action-name-edit-field").click({ force: true });
cy.get("@saveDatasource").then((httpResponse) => {
datasourceName = httpResponse.response.body.data.name;
ee.ExpandCollapseEntity("Queries/JS");
ee.ActionContextMenuByEntityName("Query1", "Show bindings");
_.entityExplorer.ExpandCollapseEntity("Queries/JS");
_.entityExplorer.ActionContextMenuByEntityName("Query1", "Show bindings");
cy.get(apiwidget.propertyList).then(function ($lis) {
expect($lis).to.have.length(5);
expect($lis.eq(0)).to.contain("{{Query1.isLoading}}");
@ -61,12 +56,16 @@ describe("Entity explorer tests related to copy query", function () {
});
it("2. Copy query in explorer to new page & verify Bindings are copied too", function () {
ee.SelectEntityByName("Query1", "Queries/JS");
ee.ActionContextMenuByEntityName("Query1", "Copy to page", pageid);
ee.ExpandCollapseEntity("Queries/JS");
ee.SelectEntityByName("Query1");
_.entityExplorer.SelectEntityByName("Query1", "Queries/JS");
_.entityExplorer.ActionContextMenuByEntityName(
"Query1",
"Copy to page",
pageid,
);
_.entityExplorer.ExpandCollapseEntity("Queries/JS");
_.entityExplorer.SelectEntityByName("Query1");
cy.runQuery();
ee.ActionContextMenuByEntityName("Query1", "Show bindings");
_.entityExplorer.ActionContextMenuByEntityName("Query1", "Show bindings");
cy.get(apiwidget.propertyList).then(function ($lis) {
expect($lis.eq(0)).to.contain("{{Query1.isLoading}}");
expect($lis.eq(1)).to.contain("{{Query1.data}}");
@ -77,18 +76,22 @@ describe("Entity explorer tests related to copy query", function () {
});
it("3. Rename datasource in explorer, Delete query and try to Delete datasource", function () {
ee.SelectEntityByName("Page1");
_.entityExplorer.SelectEntityByName("Page1");
cy.generateUUID().then((uid) => {
updatedName = uid;
cy.log("complete uid :" + updatedName);
updatedName = uid.replace(/-/g, "_").slice(1, 15);
cy.log("sliced id :" + updatedName);
ee.ExpandCollapseEntity("Queries/JS");
ee.ExpandCollapseEntity("Datasources");
ee.RenameEntityFromExplorer(datasourceName, updatedName);
_.entityExplorer.ExpandCollapseEntity("Queries/JS");
_.entityExplorer.ExpandCollapseEntity("Datasources");
_.entityExplorer.RenameEntityFromExplorer(datasourceName, updatedName);
//cy.EditEntityNameByDoubleClick(datasourceName, updatedName);
cy.wait(1000);
ee.ActionContextMenuByEntityName(updatedName, "Delete", "Are you sure?");
_.entityExplorer.ActionContextMenuByEntityName(
updatedName,
"Delete",
"Are you sure?",
);
cy.wait(1000);
//This is check to make sure if a datasource is active 409
cy.wait("@deleteDatasource").should(
@ -97,7 +100,11 @@ describe("Entity explorer tests related to copy query", function () {
409,
);
});
ee.SelectEntityByName("Query1", "Queries/JS");
ee.ActionContextMenuByEntityName("Query1", "Delete", "Are you sure?");
_.entityExplorer.SelectEntityByName("Query1", "Queries/JS");
_.entityExplorer.ActionContextMenuByEntityName(
"Query1",
"Delete",
"Are you sure?",
);
});
});

View File

@ -125,12 +125,10 @@ describe("1. CommandClickNavigation", function () {
_.agHelper.Sleep();
cy.get(`[${NAVIGATION_ATTRIBUTE}="JSObject1.myFun1"]`).click(
{
ctrlKey: true,
},
{ force: true },
);
cy.get(`[${NAVIGATION_ATTRIBUTE}="JSObject1.myFun1"]`).click({
cmdKey: true,
force: true,
});
cy.assertCursorOnCodeInput(".js-editor", { ch: 1, line: 3 });
_.agHelper.Sleep();

View File

@ -11,7 +11,7 @@ describe("Undo/Redo functionality", function () {
let postgresDatasourceName;
it("1. Checks undo/redo in datasource forms", () => {
cy.NavigateToDatasourceEditor();
_.dataSources.NavigateToDSCreateNew();
cy.get(datasource.PostgreSQL).click({ force: true });
cy.generateUUID().then((uid) => {
postgresDatasourceName = uid;

View File

@ -35,6 +35,9 @@ describe(
.scrollIntoView()
.wait(500)
.click();
_.agHelper.WaitUntilEleDisappear(
"//*[text()='Loading template details']",
);
cy.wait(1000);
_.agHelper.CheckForErrorToast(
"Internal server error while processing request",

View File

@ -1,3 +1,5 @@
import * as _ from "../../../../support/Objects/ObjectsCore";
describe("Visual tests for datasources", () => {
// for any changes in UI, update the screenshot in snapshot folder, to do so:
// 1. Delete the required screenshot which you want to update.
@ -11,8 +13,7 @@ describe("Visual tests for datasources", () => {
const newWorkspaceName = interception.response.body.data.name;
cy.CreateAppForWorkspace(newWorkspaceName, newWorkspaceName);
});
cy.NavigateToDatasourceEditor();
cy.NavigateToActiveTab();
_.dataSources.NavigateToActiveTab();
cy.get(".t--integrationsHomePage").matchImageSnapshot(
"emptydatasourcepage",
);

View File

@ -1,7 +1,9 @@
const dsl = require("../../../../../fixtures/ChartLoadingDsl.json");
const datasource = require("../../../../../locators/DatasourcesEditor.json");
const queryLocators = require("../../../../../locators/QueryEditor.json");
import * as _ from "../../../../../support/Objects/ObjectsCore";
let dsname;
describe("Chart Widget Skeleton Loading Functionality", function () {
before(() => {
cy.addDsl(dsl);
@ -30,31 +32,11 @@ describe("Chart Widget Skeleton Loading Functionality", function () {
//Step1
cy.wait(2000);
cy.NavigateToDatasourceEditor();
//Step2
cy.get(datasource.mockUserDatabase).click();
//Step3 & 4
cy.get(`${datasource.datasourceCard}`)
.filter(":contains('Users')")
.last()
.within(() => {
cy.get(`${datasource.createQuery}`).click({ force: true });
});
//Step5.1: Click the editing field
cy.get(".t--action-name-edit-field").click({ force: true });
//Step5.2: Click the editing field
cy.get(queryLocators.queryNameField).type("Query1");
// switching off Use Prepared Statement toggle
cy.get(queryLocators.switch).last().click({ force: true });
//Step 6.1: Click on Write query area
cy.get(queryLocators.templateMenu).click();
cy.xpath(queryLocators.query).click({ force: true });
_.dataSources.CreateMockDB("Users").then((dbName) => {
_.dataSources.CreateQueryFromActiveTab(dbName, false);
_.agHelper.GetNClick(_.dataSources._templateMenuOption("Select"));
_.dataSources.ToggleUsePreparedStatement(false);
});
// Step6.2: writing query to get the schema
cy.get(".CodeMirror textarea")
@ -124,11 +106,7 @@ describe("Chart Widget Skeleton Loading Functionality", function () {
"1. Test case while reloading and on submission - airgap",
function () {
cy.wait(2000);
cy.NavigateToDatasourceEditor();
cy.get(datasource.PostgreSQL).click();
cy.fillPostgresDatasourceForm();
cy.testSaveDatasource();
_.dataSources.CreateDataSource("Postgres");
cy.get("@saveDatasource").then((httpResponse) => {
dsname = httpResponse.response.body.data.name;
});

View File

@ -4,7 +4,7 @@ const commonlocators = require("../../../../../locators/commonlocators.json");
const datasource = require("../../../../../locators/DatasourcesEditor.json");
const queryLocators = require("../../../../../locators/QueryEditor.json");
import { ObjectsRegistry } from "../../../../../support/Objects/Registry";
import * as _ from "../../../../../support/Objects/ObjectsCore";
const listData = [
{
@ -85,19 +85,17 @@ const listData = [
},
];
let agHelper = ObjectsRegistry.AggregateHelper;
describe("List widget V2 page number and page size", () => {
before(() => {
cy.addDsl(dsl);
});
beforeEach(() => {
agHelper.RestoreLocalStorageCache();
_.agHelper.RestoreLocalStorageCache();
});
afterEach(() => {
agHelper.SaveLocalStorageCache();
_.agHelper.SaveLocalStorageCache();
});
it("1. List widget V2 with client side pagination", () => {
@ -164,32 +162,11 @@ describe("List widget V2 page number and page size", () => {
cy.addDsl(dslWithServerSide);
// Open Datasource editor
cy.wait(2000);
cy.NavigateToDatasourceEditor();
// Click on sample(mock) user database.
cy.get(datasource.mockUserDatabase).click();
// Choose the first data source which consists of users keyword & Click on the "New query +"" button
cy.get(`${datasource.datasourceCard}`)
.filter(":contains('Users')")
.first()
.within(() => {
cy.get(`${datasource.createQuery}`).click({ force: true });
});
// Click the editing field
cy.get(".t--action-name-edit-field").click({ force: true });
// Click the editing field
cy.get(queryLocators.queryNameField).type("Query1");
// switching off Use Prepared Statement toggle
cy.get(queryLocators.switch).last().click({ force: true });
//.1: Click on Write query area
cy.get(queryLocators.templateMenu).click();
cy.xpath(queryLocators.query).click({ force: true });
_.dataSources.CreateMockDB("Users").then((dbName) => {
_.dataSources.CreateQueryFromActiveTab(dbName, false);
_.agHelper.GetNClick(_.dataSources._templateMenuOption("Select"));
_.dataSources.ToggleUsePreparedStatement(false);
});
// writing query to get the schema
cy.get(".CodeMirror textarea")
.first()
@ -232,12 +209,7 @@ describe("List widget V2 page number and page size", () => {
cy.addDsl(dslWithServerSide);
// Open Datasource editor
cy.wait(2000);
cy.NavigateToDatasourceEditor();
cy.get(datasource.PostgreSQL).click();
cy.fillPostgresDatasourceForm();
cy.testSaveDatasource();
cy.wait(1000);
_.dataSources.CreateDataSource("Postgres");
cy.get(datasource.createQuery).click();
// Click the editing field

View File

@ -395,11 +395,7 @@ describe("List widget v2 - Basic server side data tests", () => {
"airgap",
"6. no of items rendered should be equal to page size - airgap",
() => {
cy.NavigateToDatasourceEditor();
cy.get(datasource.PostgreSQL).click();
cy.fillPostgresDatasourceForm();
cy.testSaveDatasource();
_.dataSources.CreateDataSource("Postgres");
cy.wait(1000);
cy.get(datasource.createQuery).click();
// Click the editing field

View File

@ -54,11 +54,8 @@ describe("Cyclic Dependency Informational Error Messages", function () {
"airgap",
"1. Create Users Sample DB Query & Simulate cyclic depedency - airgap",
() => {
//Step1 : Create Users DB
cy.NavigateToDatasourceEditor();
cy.get(datasource.PostgreSQL).click();
cy.fillPostgresDatasourceForm();
cy.testSaveDatasource();
//Step1 : Create postgres DB
_.dataSources.CreateDataSource("Postgres");
cy.get("@saveDatasource").then((httpResponse) => {
dsname = httpResponse.response.body.data.name;
});

View File

@ -372,17 +372,12 @@ describe("Validate Mongo query commands", function () {
"response.body.responseMeta.status",
201,
);
cy.NavigateToDatasourceEditor();
cy.get(datasource.MongoDB).click({ force: true });
cy.fillMongoDatasourceForm();
cy.CheckAndUnfoldEntityItem("Datasources");
_.dataSources.CreateDataSource("Mongo");
cy.generateUUID().then((uid) => {
datasourceName = `Mongo Documents ${uid}`;
cy.renameDatasource(datasourceName);
cy.wrap(datasourceName).as("dSName");
});
cy.testSaveDatasource();
//Insert documents
cy.get("@dSName").then((dbName) => {

View File

@ -1,7 +1,5 @@
const datasource = require("../../../locators/DatasourcesEditor.json");
import { ObjectsRegistry } from "../../../support/Objects/Registry";
let dataSource = ObjectsRegistry.DataSources;
import * as _ from "../../../support/Objects/ObjectsCore";
let datasourceName;
describe("Postgres datasource test cases", function () {
@ -10,13 +8,10 @@ describe("Postgres datasource test cases", function () {
});
it("1. Create, test, save then delete a postgres datasource", function () {
cy.NavigateToDatasourceEditor();
cy.get(datasource.PostgreSQL).click({ force: true });
cy.fillPostgresDatasourceForm();
cy.testSaveDatasource();
_.dataSources.CreateDataSource("Postgres");
cy.get("@saveDatasource").then((httpResponse) => {
datasourceName = JSON.stringify(httpResponse.response.body.data.name);
dataSource.DeleteDatasouceFromActiveTab(
_.dataSources.DeleteDatasouceFromActiveTab(
datasourceName.replace(/['"]+/g, ""),
);
});

View File

@ -205,7 +205,7 @@
],
"leftColumn": 22,
"dynamicBindingPathList": [],
"text": "Submit",
"text": "Edit",
"key": "kjr7tyw06m",
"rightColumn": 40,
"isDefaultClickDisabled": true,
@ -750,7 +750,7 @@
],
"leftColumn": 23,
"dynamicBindingPathList": [],
"text": "Submit",
"text": "Add",
"key": "kjr7tyw06m",
"rightColumn": 39,
"isDefaultClickDisabled": true,

View File

@ -21,5 +21,7 @@
"bookquantity": "(//div[@class='bp3-input-group'])[8]",
"addtoCart": "//span[@class='bp3-button-text' and text()='Submit']",
"deletefromCart": "//span[@class='bp3-button-text' and text()='Delete']",
"editbookquantity": "(//div[@class='bp3-input-group'])[4]"
"editbookquantity": "(//div[@class='bp3-input-group'])[4]",
"addButton":"//span[text()='Add']/parent::button",
"editButton":"//span[text()='Edit']/parent::button"
}