## Description - This PR upgrades cypress from 11.2 to 12.13.0 which fixes the random browser crash issue in CI runs - ValidateNetworkStatus() updates to validate the n/w responses - cy.route() to cy.intercept() - Converting dataSources.json to HostPort.ts - Api responses read - updating to right Cy12 supported format - js inconsistent testJsontext to TS `EnterJSContext` in few failing specs - CI - higher resolution trials - Improves _.agHelper.RefreshPage() - fixing Error: Socket closed before finished writing response - AssertDocumentReady() created - within(()) & .children() - handled for Cy12 - Improved DeployApp(), NavigateBacktoEditor(), RefreshPage(), AddDsl() methods - js inconsistent goToEditFromPublish to TS `NavigateBacktoEditor` in all specs - js inconsistent PublishtheApp to TS `_.agHelper.DeployApp` in all specs - Convert /DynamicHeight/Text_Widget_spec.js to TS with all supporting TS helpers - ToggleJSMode() - COMMIT_INFO_MESSAGE improved - Remove tooltip on the Application Name after rename - js inconsistent cy.addDsl(dsl); to TS helper `_.agHelper.AddDsl(val);` - ++++ Much more improvements.... #### Type of change - Script fixes ## Testing #### How Has This Been Tested? - [X] Cypress ## Checklist: #### QA activity: - [X] Added `Test Plan Approved` label after Cypress tests were reviewed --------- Co-authored-by: Vijetha-Kaja <vijetha@appsmith.com>
93 lines
2.5 KiB
TypeScript
93 lines
2.5 KiB
TypeScript
import "cypress-wait-until";
|
|
import { ObjectsRegistry } from "../Objects/Registry";
|
|
import { ReusableHelper } from "../Objects/ReusableHelper";
|
|
|
|
export enum EntityItems {
|
|
Page,
|
|
Query,
|
|
Api,
|
|
JSObject,
|
|
Widget,
|
|
Datasource,
|
|
}
|
|
export class AssertHelper extends ReusableHelper {
|
|
private locator = ObjectsRegistry.CommonLocators;
|
|
public _modifierKey = Cypress.platform === "darwin" ? "meta" : "ctrl";
|
|
|
|
public isMac = Cypress.platform === "darwin";
|
|
|
|
public Sleep(timeout = 1000) {
|
|
cy.wait(timeout);
|
|
}
|
|
|
|
public AssertDocumentReady() {
|
|
cy.waitUntil(() =>
|
|
//cy.document().then((doc) => doc.readyState === "complete"),
|
|
cy.document().should((doc) => {
|
|
expect(doc.readyState).to.equal("complete");
|
|
}),
|
|
);
|
|
cy.window().should("have.property", "onload");
|
|
}
|
|
|
|
public AssertDelete(entityType: EntityItems) {
|
|
let networkCall = "";
|
|
switch (entityType) {
|
|
case EntityItems.Api:
|
|
case EntityItems.Query:
|
|
networkCall = "deleteAction";
|
|
break;
|
|
case EntityItems.Widget:
|
|
networkCall = "updateLayout";
|
|
break;
|
|
case EntityItems.JSObject:
|
|
networkCall = "deleteJSCollection";
|
|
this.AssertContains("deleted successfully");
|
|
break;
|
|
case EntityItems.Datasource:
|
|
networkCall = "deleteDatasource";
|
|
break;
|
|
case EntityItems.Page:
|
|
networkCall = "deletePage";
|
|
break;
|
|
|
|
default:
|
|
networkCall && this.AssertNetworkStatus(networkCall);
|
|
}
|
|
}
|
|
|
|
public AssertNetworkStatus(aliasName: string, expectedStatus = 200) {
|
|
// cy.wait(aliasName).then(($apiCall: any) => {
|
|
// expect($apiCall.response.body.responseMeta.status).to.eq(expectedStatus);
|
|
// });
|
|
|
|
// cy.wait(aliasName).should(
|
|
// "have.nested.property",
|
|
// "response.body.responseMeta.status",
|
|
// expectedStatus,
|
|
// );
|
|
this.Sleep(); //Wait a bit for call to finish!
|
|
aliasName = aliasName.startsWith("@") ? aliasName : "@" + aliasName;
|
|
cy.wait(aliasName);
|
|
cy.get(aliasName)
|
|
.its("response.body.responseMeta.status")
|
|
.should("eq", expectedStatus);
|
|
|
|
//To improve below:
|
|
// cy.wait(aliasName, { timeout: timeout }).should((response: any) => {
|
|
// expect(response.status).to.be.oneOf([expectedStatus]);
|
|
// });
|
|
}
|
|
|
|
public AssertContains(
|
|
text: string | RegExp,
|
|
exists: "exist" | "not.exist" | "be.visible" = "exist",
|
|
selector?: string,
|
|
) {
|
|
if (selector) {
|
|
return cy.contains(selector, text).should(exists);
|
|
}
|
|
return cy.contains(text).should(exists);
|
|
}
|
|
}
|