## Description **- This PR includes below:** - NavigateBacktoEditor() improved - Flaky fixed - ClientSide/EmbedSettings/EmbedSettings_spec.js- 1st test - ServerSide/QueryPane/S3_1_spec.js - 1st test - handling added error message - Sanity/Datasources/Arango_Basic_Spec.ts - 3rd test - schema pop-up handle - ClientSide/FormLogin/EnableFormLogin_spec.js - server restart fix - Moved AssertNetworkExecutionSuccess to AssertHelper - GetNAssertContains() simplified - Widgets/ListV2/DataIdentifierProperty_spec.ts - 7th case flaky fix - /Widgets/Checkbox/CheckboxGroup2_spec.js - flaky fix - BugTests/AllWidgets_Reset_Spec.ts - script improved - /Widgets/Radio/Radio_spec.js - script improved - AssertExistingCheckedState() improved to validate attribute & checked state - ClickButton() improved - AssertElementEnabledDisabled() improved - UpdateInput(), replaced with TypeText() **- New scripting for:** - S3 - Deploy mode validations added - S3 - Edit File validation added from Deploy page - S3 - Upon file upload, validating button changes - S3 - Verify max number of files upload - S3 - File name Prefix search & Delete improved - S3_2_spec from js to ts helpers - Tc # 2439 scripted #### Type of change - Script fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [X] Cypress CI runs ## Checklist: #### QA activity: - [X] Added `Test Plan Approved` label after Cypress tests were reviewed
111 lines
3.1 KiB
TypeScript
111 lines
3.1 KiB
TypeScript
import "cypress-wait-until";
|
|
import { ObjectsRegistry } from "../Objects/Registry";
|
|
import { ReusableHelper } from "../Objects/ReusableHelper";
|
|
|
|
export const EntityItems = {
|
|
Page: 0,
|
|
Query: 1,
|
|
Api: 2,
|
|
JSObject: 3,
|
|
Widget: 4,
|
|
Datasource: 5,
|
|
} as const;
|
|
|
|
export type EntityItemsType = (typeof EntityItems)[keyof typeof EntityItems];
|
|
|
|
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({ timeout: 60000 }).should("have.property", "onload");
|
|
}
|
|
|
|
public AssertDelete(entityType: EntityItemsType) {
|
|
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 GetAliasName(aliasName: string) {
|
|
aliasName = aliasName.startsWith("@") ? aliasName : "@" + aliasName;
|
|
return aliasName;
|
|
}
|
|
|
|
public WaitForNetworkCall(aliasName: string) {
|
|
// 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(2000); //Wait a bit for call to finish!
|
|
return cy.wait(this.GetAliasName(aliasName), { responseTimeout: 60000 });
|
|
}
|
|
|
|
public AssertNetworkStatus(aliasName: string, expectedStatus = 200) {
|
|
this.WaitForNetworkCall(aliasName);
|
|
cy.get(this.GetAliasName(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 AssertNetworkExecutionSuccess(aliasName: string, expectedRes = true) {
|
|
this.WaitForNetworkCall(aliasName);
|
|
cy.get(aliasName)
|
|
.its("response.body.data.isExecutionSuccess")
|
|
.should("eq", expectedRes);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|