Skip to content

Commit

Permalink
test: Cypress | Flaky fixes (appsmithorg#25083)
Browse files Browse the repository at this point in the history
## Description
- This PR adds new method - WaitForNetworkCall()
- Trail fix for flaky spec ClientSide/AppNavigation/TopStacked_spec.ts

#### Type of change
- Script fix (non-breaking change which fixes an issue)
## Testing
>
#### How Has This Been Tested?
- [X] Cypress local runs

## Checklist:
#### QA activity:
- [X] Added `Test Plan Approved` label after changes were reviewed
  • Loading branch information
Aishwarya-U-R authored Jul 4, 2023
1 parent b4a883c commit b15087a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
29 changes: 16 additions & 13 deletions app/client/cypress/e2e/Regression/Apps/CommunityIssues_Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
propPane,
entityExplorer,
locators,
assertHelper,
} from "../../../support/Objects/ObjectsCore";

describe("AForce - Community Issues page validations", function () {
Expand All @@ -27,19 +28,21 @@ describe("AForce - Community Issues page validations", function () {
it("1. Import application json and validate headers", () => {
homePage.NavigateToHome();
homePage.ImportApp("CommunityIssuesExport.json");
cy.wait("@importNewApplication").then((interception: any) => {
agHelper.Sleep();
const { isPartialImport } = interception.response.body.data;
if (isPartialImport) {
// should reconnect modal
dataSources.ReconnectDataSource("AForceDB", "PostgreSQL");
homePage.AssertNCloseImport();
} else {
homePage.AssertImportToast();
}
//Validate table is not empty!
table.WaitUntilTableLoad(0, 0, "v2");
});
assertHelper
.WaitForNetworkCall("importNewApplication")
.then((interception: any) => {
agHelper.Sleep();
const { isPartialImport } = interception.response.body.data;
if (isPartialImport) {
// should reconnect modal
dataSources.ReconnectDataSource("AForceDB", "PostgreSQL");
homePage.AssertNCloseImport();
} else {
homePage.AssertImportToast();
}
//Validate table is not empty!
table.WaitUntilTableLoad(0, 0, "v2");
});

//Validating order of header columns!
table.AssertTableHeaderOrder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const commonLocators = require("../../../../locators/commonlocators.json");

import {
agHelper,
assertHelper,
deployMode,
homePage,
} from "../../../../support/Objects/ObjectsCore";
Expand All @@ -12,16 +13,17 @@ describe("Test Top + Stacked navigation style", function () {
// Import an application
homePage.NavigateToHome();
homePage.ImportApp("appNavigationTestingAppWithLongPageNamesAndTitle.json");

cy.wait("@importNewApplication").then((interception) => {
agHelper.Sleep();
const { isPartialImport } = interception.response.body.data;
if (isPartialImport) {
homePage.AssertNCloseImport();
} else {
homePage.AssertImportToast(0);
}
});
assertHelper
.WaitForNetworkCall("importNewApplication")
.then((interception: any) => {
agHelper.Sleep();
const { isPartialImport } = interception.response.body.data;
if (isPartialImport) {
homePage.AssertNCloseImport();
} else {
homePage.AssertImportToast(0);
}
});
});

it("1. In an app with 15 pages, the navbar should be scrollable", () => {
Expand Down Expand Up @@ -89,7 +91,7 @@ describe("Test Top + Stacked navigation style", function () {
.GetElement(appNavigationLocators.scrollArrows)
.last()
.trigger("mousedown");
agHelper.Sleep(500);
agHelper.Sleep(1500);
agHelper
.GetElement(appNavigationLocators.scrollArrows)
.last()
Expand All @@ -100,15 +102,11 @@ describe("Test Top + Stacked navigation style", function () {
.should("not.be.visible");

// Scroll to the left again and page 1 should be visible
agHelper
.GetElement(appNavigationLocators.navigationMenuItem)
.contains(pageName)
.should("not.be.visible");
agHelper
.GetElement(appNavigationLocators.scrollArrows)
.first()
.trigger("mousedown");
agHelper.Sleep(500);
agHelper.Sleep(1500);
agHelper
.GetElement(appNavigationLocators.scrollArrows)
.first()
Expand Down
8 changes: 6 additions & 2 deletions app/client/cypress/support/Pages/AssertHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class AssertHelper extends ReusableHelper {
}
}

public AssertNetworkStatus(aliasName: string, expectedStatus = 200) {
public WaitForNetworkCall(aliasName: string, expectedStatus = 200) {
// cy.wait(aliasName).then(($apiCall: any) => {
// expect($apiCall.response.body.responseMeta.status).to.eq(expectedStatus);
// });
Expand All @@ -71,7 +71,11 @@ export class AssertHelper extends ReusableHelper {
// );
this.Sleep(); //Wait a bit for call to finish!
aliasName = aliasName.startsWith("@") ? aliasName : "@" + aliasName;
cy.wait(aliasName);
return cy.wait(aliasName);
}

public AssertNetworkStatus(aliasName: string, expectedStatus = 200) {
this.WaitForNetworkCall(aliasName);
cy.get(aliasName)
.its("response.body.responseMeta.status")
.should("eq", expectedStatus);
Expand Down

0 comments on commit b15087a

Please sign in to comment.