Skip to content

Commit

Permalink
test: Cypress | Flakyfix + New Scripts (appsmithorg#25085)
Browse files Browse the repository at this point in the history
## Description
- This PR has below:
- improves StubWindowNAssert()
- Adds new test for Bug # 25004
- AssertNetworkStatus() fixed

#### 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 081d417 commit 22dce83
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import {
dataSources,
} from "../../../support/Objects/ObjectsCore";

let repoName;
describe("Shopping cart App", function () {
let datasourceName;
let datasourceName: string, repoName: any;

before(() => {
homePage.NavigateToHome();
Expand All @@ -21,7 +20,7 @@ describe("Shopping cart App", function () {
agHelper.AddDsl("mongoAppdsl");
});
dataSources.CreateDataSource("Mongo");
cy.get("@saveDatasource").then((httpResponse) => {
cy.get("@saveDatasource").then((httpResponse: any) => {
datasourceName = httpResponse.response.body.data.name;
});
});
Expand Down Expand Up @@ -113,7 +112,6 @@ describe("Shopping cart App", function () {
});

agHelper.AssertAutoSave();

deployMode.DeployApp(appPage.bookname);
});

Expand All @@ -125,15 +123,15 @@ describe("Shopping cart App", function () {
agHelper.AssertElementLength(appPage.inputValues, 9);
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);
agHelper.UpdateInput(appPage.bookprice, "200", true);
agHelper.UpdateInput(appPage.bookquantity, "2", true);
agHelper.GetNClick(appPage.addButton, 0, true);
assertHelper.AssertNetworkStatus("@postExecute");
agHelper.GetNClick(appPage.bookname);
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);
agHelper.UpdateInput(appPage.bookprice, "100", true);
agHelper.UpdateInput(appPage.bookquantity, "1", true);
agHelper.GetNClick(appPage.addButton, 0, true);
assertHelper.AssertNetworkStatus("@postExecute");
// Deleting the book from the cart
Expand All @@ -145,7 +143,7 @@ describe("Shopping cart App", function () {
// validating that the book is deleted
agHelper.AssertElementLength(appPage.deleteButton + "/parent::div", 1);
// Updating the book quantity from edit cart
agHelper.UpdateInput(appPage.editbookquantity, 3, true);
agHelper.UpdateInput(appPage.editbookquantity, "3", true);
agHelper.GetNClick(appPage.editButton, 0, true);

//Wait for all post execute calls to finish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ describe("Omnibar functionality test cases", () => {

it("1. Bug #15104 Docs tab opens after clicking on learn more link from property pane", function () {
cy.dragAndDropToCanvas(draggableWidgets.AUDIO, { x: 300, y: 500 });
cy.url().then(($editPageUrl) => {
deployMode.StubWindowNAssert(
'//span[text()="Learn more"]',
"connect-datasource",
$editPageUrl,
"getWorkspace",
);
});
deployMode.StubWindowNAssert(
'//span[text()="Learn more"]',
"connect-datasource",
"getWorkspace",
);
});

it("2.Verify omnibar is present across all pages and validate its fields", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
dataSources,
entityItems,
deployMode,
locators,
} from "../../../../support/Objects/ObjectsCore";

let dsName: any;
Expand All @@ -14,14 +15,11 @@ describe("Check datasource doc links", function () {
cy.get("@dsName").then(($dsName) => {
dsName = $dsName;
dataSources.CreateQueryAfterDSSaved();
cy.url().then(($queryPageUrl) => {
deployMode.StubWindowNAssert(
dataSources._queryDoc,
"querying-postgres#create-crud-queries",
$queryPageUrl,
"getWorkspace",
);
});
deployMode.StubWindowNAssert(
dataSources._queryDoc,
"querying-postgres#create-crud-queries",
"getWorkspace",
);
});
});

Expand All @@ -30,14 +28,11 @@ describe("Check datasource doc links", function () {
cy.get("@dsName").then(($dsName) => {
dsName = $dsName;
dataSources.CreateQueryAfterDSSaved();
cy.url().then(($queryPageUrl) => {
deployMode.StubWindowNAssert(
dataSources._queryDoc,
"querying-mongodb#create-queries",
$queryPageUrl,
"getWorkspace",
);
});
deployMode.StubWindowNAssert(
dataSources._queryDoc,
"querying-mongodb#create-queries",
"getWorkspace",
);
});
});

Expand All @@ -46,14 +41,11 @@ describe("Check datasource doc links", function () {
cy.get("@dsName").then(($dsName) => {
dsName = $dsName;
dataSources.CreateQueryAfterDSSaved();
cy.url().then(($queryPageUrl) => {
deployMode.StubWindowNAssert(
dataSources._queryDoc,
"querying-mysql#create-queries",
$queryPageUrl,
"getWorkspace",
);
});
deployMode.StubWindowNAssert(
dataSources._queryDoc,
"querying-mysql#create-queries",
"getWorkspace",
);
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { ObjectsRegistry } from "../../../../support/Objects/Registry";
import {
dataSources,
deployMode,
locators,
agHelper,
} from "../../../../support/Objects/ObjectsCore";
const datasource = require("../../../../locators/DatasourcesEditor.json");
const explorer = require("../../../../locators/explorerlocators.json");

let dataSources = ObjectsRegistry.DataSources;
let queryName;
let datasourceName;
let pluginName = "Google Sheets";
let placeholderText =
'{\n "name": {{nameInput.text}},\n "dob": {{dobPicker.formattedDate}},\n "gender": {{genderSelect.selectedOptionValue}} \n}';

describe(
"excludeForAirgap",
"Google Sheets datasource row objects placeholder",
function () {
let queryName;
let datasourceName;
let pluginName = "Google Sheets";
let placeholderText =
'{\n "name": {{nameInput.text}},\n "dob": {{dobPicker.formattedDate}},\n "gender": {{genderSelect.selectedOptionValue}} \n}';

//Skiiping due to open bug #18035: Should the Save button be renamed as "Save and Authorise" in case of Google sheets for datasource discard popup?
it.skip("Bug: 16391 - Google Sheets DS, placeholder objects keys should have quotes", function () {
it.skip("1. Bug: 16391 - Google Sheets DS, placeholder objects keys should have quotes", function () {
// create new Google Sheets datasource
dataSources.NavigateToDSCreateNew();
dataSources.CreatePlugIn(pluginName);
Expand Down Expand Up @@ -50,5 +53,19 @@ describe(
// });
//});
});

it("2. Bug # 25004 - Verify Google Sheets documentation opens", function () {
dataSources.NavigateToDSCreateNew();
dataSources.CreatePlugIn(pluginName);
deployMode.StubWindowNAssert(
locators._learnMore,
"querying-google-sheets#create-queries",
"getWorkspace",
);
agHelper.GetNClick(locators._visibleTextSpan("Don't save"));
agHelper.Sleep();
agHelper.GoBack();
agHelper.Sleep();
});
},
);
1 change: 1 addition & 0 deletions app/client/cypress/support/Objects/CommonLocators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export class CommonLocators {
_ds_uppy_upload_btn = ".uppy-StatusBar-actionBtn--upload";

_goBack = this._visibleTextSpan("Back") + "/parent::a";
_learnMore = this._visibleTextSpan("Learn more") + "/parent::a";
_resizeHandles = {
left: "t--resizable-handle-LEFT",
right: "t--resizable-handle-RIGHT",
Expand Down
10 changes: 7 additions & 3 deletions app/client/cypress/support/Pages/AssertHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export class AssertHelper extends ReusableHelper {
}
}

public GetAliasName(aliasName: string) {
aliasName = aliasName.startsWith("@") ? aliasName : "@" + aliasName;
return aliasName;
}

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

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

Expand Down
5 changes: 3 additions & 2 deletions app/client/cypress/support/Pages/DeployModeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ export class DeployMode {
public StubWindowNAssert(
selector: string,
expectedUrl: string,
visitUrl: string,
networkCall: string,
) {
this.StubbingWindow();
this.agHelper.GetNClick(selector, 0, false, 4000); //timeout new url to settle loading
cy.get("@windowStub").should("be.calledOnce");
cy.url().should("contain", expectedUrl);
this.assertHelper.AssertDocumentReady();
cy.visit(visitUrl, { timeout: 60000 });
cy.window({ timeout: 60000 }).then((win) => {
win.history.back();
});
this.assertHelper.AssertNetworkStatus("@" + networkCall);
this.assertHelper.AssertDocumentReady();
}
Expand Down
15 changes: 6 additions & 9 deletions app/client/cypress/support/Pages/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,12 @@ export class Table {
tableVersion: "v1" | "v2" = "v1",
networkCall = "viewPage",
) {
cy.url().then(($currentUrl) => {
this.deployMode.StubWindowNAssert(
this._tableRowColumnData(row, col, tableVersion),
expectedURL,
$currentUrl,
networkCall,
);
this.WaitUntilTableLoad(0, 0, tableVersion);
});
this.deployMode.StubWindowNAssert(
this._tableRowColumnData(row, col, tableVersion),
expectedURL,
networkCall,
);
this.WaitUntilTableLoad(0, 0, tableVersion);
}

public AddColumn(colId: string) {
Expand Down

0 comments on commit 22dce83

Please sign in to comment.