PromucFlow_constructor/app/client/cypress/support/Pages/AggregateHelper.ts

363 lines
13 KiB
TypeScript
Raw Normal View History

2022-03-25 11:14:12 +00:00
import 'cypress-wait-until';
test: Automated tests for Promises & related bugs in Typescript + Flaky fixes (#10378) * Flaky fixes * S3 CRUD intercept fix * S3 CRUD script change revert * S3 revert! * .its(store) not present fix * TS failure fixes * ChartDataopoint js removed * JSObject ts flaky fix * Bugs 9789, 10150 scripted * Bug 10284 & 9782 scripted * Updated dsl file names * Table_Widget case #7 flaky fix * Bug 10150 scripting improved * DocumentViewer spec flaky fix * Input widget locator corrected * MemberRoles cases script started in TS * UpdateUserRoleInOrg() fix * Skip JSObject_To_ListWidgetSpec.ts until #10284 * Add validation * JSObject_To_ListWidgetSpec.ts timeout increase * Skipping tests until bug 10284 is fixed * Increased wait time * UpdateUserRoleInOrg() updated * MemberRoles_Spec.ts fixed * JSObjToInput - updated * Postgres flaky fix * Member Roles aka CreateOrg test flaky fix * JSObToListWidget_Spec.ts - commenting until bugfix * COmmenting JSobjToInput spec * Commonlocators added back * Entity explorer name fix * Locators fix * Locator corrected * Cypress.json removed files from ignoring list * S3 & Postgress failures fix * Postgress failure locator fix * S3 upload script skipping until bug fix * Params Bug 10784 script started * Fixing Promises Spec * Increased wait time! * MigrationSpec - Image column,Cardformat,Pagestyles * S3, Postgres, Promise - failures fix * Canvas renamed * Bug 11415 - Added Validations * InputWidgets_navigateTo - flaky fix * MigrationSpec - import change * Locators files - Json to Js conversion * DS plugnis name change * Locators - Json to JS conversion * Locators - Json to JS updations * Select_Widget_Value flaky fix * Adding timeout for execute calls to finish * Migration spec - diff syntax+List.js flaky fix * List & MIgration flaky fix
2022-03-02 16:54:43 +00:00
const uuid = require("uuid");
import { ObjectsRegistry } from '../Objects/Registry';
test: Automated tests for JSObjects in Typescript (#10223) * Bugs #9069, #9201, #6975, #9922 - Scripted * Mongo DS update from Cloud to Localhost * Updating command.js * Ignoring Mongo until Localhost is fixed * S3 fixes * S3 fix * Mongo Cloud to Localhost transition * Bug #6375 scripted * Failure fix * S3 fix + testSaveDs method flow update * Refresh datasource structure script fix * Entity explorer datasource structure script fix * testSaveDs method flow update fixes * testSaveDs method flow update fixes - set 2 * S3, Mongo Skipping cases fix * Custom Chart failure fix * Button-Call-Query Validation case script fix * Confirm run action failure fix * Confirm run action script fix * Dropdown-Call-Query Validation script fix * S3 - Delete icon issue fix * S3 - Delete icon locator updated * actionContextMenuByEntityName method call update * Table widget add new menu button column - rgb fix * Commenting BG color verify - to override flakiness * Mongo skipping script fix * Commenting Cypress.runner.stop() * Removing .skip * Bind_tableApi_spec.js failure fix * Slash command failure fix * Bugs # 8595 & 10049 - Implemented * Updating AGHelper methods to explicit public * Reverting tsconfig.json * tsconfig.json reverted * Adding local tsconfig.json for Cypress tests * fixture read updating for ts tests * Updating .yml files to pick up ts files execution * Including ts files for cypress run * Running only ts test files * Inclusion of TS files for cypress run * Revert cypress.json to run all tests * Added validation for Bug #10055 & commented * Flaky fix * JSObject_To_ListWidgetSpec - Implemented in TS * Entity_Explorer_JSEditor_spec implemented in TS * Uncommenting script for Bug 10049, 10055
2022-01-10 04:21:43 +00:00
export class AggregateHelper {
private locator = ObjectsRegistry.CommonLocators;
2022-03-25 11:14:12 +00:00
public AddDsl(dsl: string) {
let currentURL;
let pageid: string;
let layoutId;
cy.url().then((url) => {
pageid = url.split("/")[4]?.split("-").pop() as string;
cy.log(pageid + "page id");
//Fetch the layout id
cy.request("GET", "api/v1/pages/" + pageid).then((response) => {
const respBody = JSON.stringify(response.body);
layoutId = JSON.parse(respBody).data.layouts[0].id;
// Dumping the DSL to the created page
cy.request(
"PUT",
"api/v1/layouts/" + layoutId + "/pages/" + pageid,
dsl
).then((dslDumpResp) => {
//cy.log("Pages resposne is : " + dslDumpResp.body);
expect(dslDumpResp.status).equal(200);
cy.reload();
});
});
test: Automated tests for Promises & related bugs in Typescript + Flaky fixes (#10378) * Flaky fixes * S3 CRUD intercept fix * S3 CRUD script change revert * S3 revert! * .its(store) not present fix * TS failure fixes * ChartDataopoint js removed * JSObject ts flaky fix * Bugs 9789, 10150 scripted * Bug 10284 & 9782 scripted * Updated dsl file names * Table_Widget case #7 flaky fix * Bug 10150 scripting improved * DocumentViewer spec flaky fix * Input widget locator corrected * MemberRoles cases script started in TS * UpdateUserRoleInOrg() fix * Skip JSObject_To_ListWidgetSpec.ts until #10284 * Add validation * JSObject_To_ListWidgetSpec.ts timeout increase * Skipping tests until bug 10284 is fixed * Increased wait time * UpdateUserRoleInOrg() updated * MemberRoles_Spec.ts fixed * JSObjToInput - updated * Postgres flaky fix * Member Roles aka CreateOrg test flaky fix * JSObToListWidget_Spec.ts - commenting until bugfix * COmmenting JSobjToInput spec * Commonlocators added back * Entity explorer name fix * Locators fix * Locator corrected * Cypress.json removed files from ignoring list * S3 & Postgress failures fix * Postgress failure locator fix * S3 upload script skipping until bug fix * Params Bug 10784 script started * Fixing Promises Spec * Increased wait time! * MigrationSpec - Image column,Cardformat,Pagestyles * S3, Postgres, Promise - failures fix * Canvas renamed * Bug 11415 - Added Validations * InputWidgets_navigateTo - flaky fix * MigrationSpec - import change * Locators files - Json to Js conversion * DS plugnis name change * Locators - Json to JS conversion * Locators - Json to JS updations * Select_Widget_Value flaky fix * Adding timeout for execute calls to finish * Migration spec - diff syntax+List.js flaky fix * List & MIgration flaky fix
2022-03-02 16:54:43 +00:00
});
2022-03-25 11:14:12 +00:00
this.Sleep(5000)//settling time for dsl
cy.get(this.locator._loading).should("not.exist");//Checks the spinner is gone & dsl loaded!
2022-03-25 11:14:12 +00:00
}
public StartServerAndRoutes() {
cy.intercept("POST", "/api/v1/actions").as("createNewApi");
cy.intercept("PUT", "/api/v1/actions/*").as("saveAction");
//cy.intercept("POST", "/api/v1/users/invite", (req) => { req.headers["origin"] = "Cypress";}).as("mockPostInvite");
}
public RenameWithInPane(renameVal: string, query = true) {
let name = query ? this.locator._queryName : this.locator._dsName;
let text = query ? this.locator._queryNameTxt : this.locator._dsNameTxt;
2022-03-25 11:14:12 +00:00
cy.get(name).click({ force: true });
cy.get(text)
.clear({ force: true })
.type(renameVal, { force: true })
.should("have.value", renameVal)
.blur();
}
public AssertAutoSave() {
2022-03-25 11:14:12 +00:00
// wait for save query to trigger & n/w call to finish occuring
cy.get(this.locator._saveStatusSuccess, { timeout: 40000 }).should("exist");
2022-03-25 11:14:12 +00:00
}
public ValidateCodeEditorContent(selector: string, contentToValidate: any) {
cy.get(selector).within(() => {
cy.get(this.locator._codeMirrorCode).should("have.text", contentToValidate);
2022-03-25 11:14:12 +00:00
});
}
//refering PublishtheApp from command.js
public DeployApp() {
cy.intercept("POST", "/api/v1/applications/publish/*").as("publishApp");
// Wait before publish
this.Sleep(2000)
this.AssertAutoSave()
2022-03-25 11:14:12 +00:00
// Stubbing window.open to open in the same tab
cy.window().then((window) => {
cy.stub(window, "open").callsFake((url) => {
window.location.href = Cypress.config().baseUrl + url.substring(1);
test: Automated tests for Promises & related bugs in Typescript + Flaky fixes (#10378) * Flaky fixes * S3 CRUD intercept fix * S3 CRUD script change revert * S3 revert! * .its(store) not present fix * TS failure fixes * ChartDataopoint js removed * JSObject ts flaky fix * Bugs 9789, 10150 scripted * Bug 10284 & 9782 scripted * Updated dsl file names * Table_Widget case #7 flaky fix * Bug 10150 scripting improved * DocumentViewer spec flaky fix * Input widget locator corrected * MemberRoles cases script started in TS * UpdateUserRoleInOrg() fix * Skip JSObject_To_ListWidgetSpec.ts until #10284 * Add validation * JSObject_To_ListWidgetSpec.ts timeout increase * Skipping tests until bug 10284 is fixed * Increased wait time * UpdateUserRoleInOrg() updated * MemberRoles_Spec.ts fixed * JSObjToInput - updated * Postgres flaky fix * Member Roles aka CreateOrg test flaky fix * JSObToListWidget_Spec.ts - commenting until bugfix * COmmenting JSobjToInput spec * Commonlocators added back * Entity explorer name fix * Locators fix * Locator corrected * Cypress.json removed files from ignoring list * S3 & Postgress failures fix * Postgress failure locator fix * S3 upload script skipping until bug fix * Params Bug 10784 script started * Fixing Promises Spec * Increased wait time! * MigrationSpec - Image column,Cardformat,Pagestyles * S3, Postgres, Promise - failures fix * Canvas renamed * Bug 11415 - Added Validations * InputWidgets_navigateTo - flaky fix * MigrationSpec - import change * Locators files - Json to Js conversion * DS plugnis name change * Locators - Json to JS conversion * Locators - Json to JS updations * Select_Widget_Value flaky fix * Adding timeout for execute calls to finish * Migration spec - diff syntax+List.js flaky fix * List & MIgration flaky fix
2022-03-02 16:54:43 +00:00
});
2022-03-23 04:34:11 +00:00
});
cy.get(this.locator._publishButton).click();
2022-03-25 11:14:12 +00:00
cy.log("Pagename: " + localStorage.getItem("PageName"));
cy.wait("@publishApp").its("request.url").should("not.contain", "edit")
//cy.wait('@publishApp').wait('@publishApp') //waitng for 2 calls to complete
2022-03-25 11:14:12 +00:00
}
public AddNewPage() {
cy.get(this.locator._newPage)
2022-03-25 11:14:12 +00:00
.first()
.click();
cy.wait("@createPage").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
}
public ValidateToastMessage(text: string, length = 1, index = 1) {
cy.get(this.locator._toastMsg)
.should("have.length", length)
.should("contain.text", text);
}
2022-03-25 11:14:12 +00:00
public ClickButton(btnVisibleText: string) {
cy.xpath(this.locator._spanButton(btnVisibleText))
2022-03-25 11:14:12 +00:00
.scrollIntoView()
.click({ force: true });
}
public Paste(selector: any, pastePayload: string) {
cy.wrap(selector).then(($destination) => {
const pasteEvent = Object.assign(
new Event("paste", { bubbles: true, cancelable: true }),
{
clipboardData: {
getData: () => pastePayload,
},
},
);
$destination[0].dispatchEvent(pasteEvent);
});
}
public WaitUntilEleDisappear(selector: string, msgToCheckforDisappearance: string) {
2022-03-25 11:14:12 +00:00
cy.waitUntil(() => cy.get(selector).contains(msgToCheckforDisappearance).should("have.length", 0),
{
errorMsg: msgToCheckforDisappearance + " did not disappear",
timeout: 5000,
interval: 1000
}).then(() => this.Sleep())
2022-03-25 11:14:12 +00:00
}
public WaitUntilEleAppear(selector: string) {
2022-03-25 11:14:12 +00:00
cy.waitUntil(() => cy.get(selector, { timeout: 50000 }).should("have.length.greaterThan", 0),
{
errorMsg: "Element did not appear",
timeout: 5000,
interval: 1000
}).then(() => this.Sleep(500))
2022-03-25 11:14:12 +00:00
}
public ValidateNetworkExecutionSuccess(aliasName: string, expectedRes = true) {
cy.wait(aliasName).should(
"have.nested.property",
"response.body.data.isExecutionSuccess",
expectedRes,
)
}
public ValidateNetworkDataSuccess(aliasName: string, expectedRes = true) {
2022-03-25 11:14:12 +00:00
cy.wait(aliasName).should(
"have.nested.property",
"response.body.data.success",
2022-03-25 11:14:12 +00:00
expectedRes,
)
}
public ValidateNetworkStatus(aliasName: string, expectedStatus = 200) {
2022-03-25 11:14:12 +00:00
cy.wait(aliasName).should(
"have.nested.property",
"response.body.responseMeta.status",
expectedStatus,
)
}
public SelectPropertiesDropDown(endp: string, ddOption: string,) {
cy.xpath(this.locator._selectPropDropdown(endp))
2022-03-25 11:14:12 +00:00
.first()
.scrollIntoView()
.click()
cy.get(this.locator._dropDownValue(ddOption)).click()
2022-03-25 11:14:12 +00:00
}
public SelectDropDown(endp: string, ddOption: string,) {
cy.xpath(this.locator._selectWidgetDropdown(endp))
2022-03-25 11:14:12 +00:00
.first()
.scrollIntoView()
.click()
cy.get(this.locator._selectOptionValue(ddOption)).click({ force: true })
2022-03-25 11:14:12 +00:00
this.Sleep(2000)
}
public EnterActionValue(actionName: string, value: string, paste = true) {
cy.xpath(this.locator._actionTextArea(actionName))
2022-03-25 11:14:12 +00:00
.first()
.focus()
.type("{uparrow}", { force: true })
.type("{ctrl}{shift}{downarrow}{del}", { force: true });
cy.focused().then(($cm: any) => {
if ($cm.contents != "") {
cy.log("The field is not empty");
cy.xpath(this.locator._actionTextArea(actionName))
2022-03-25 11:14:12 +00:00
.first()
.click({ force: true })
.focused()
.clear({
force: true,
});
}
this.Sleep()
cy.xpath(this.locator._actionTextArea(actionName))
2022-03-25 11:14:12 +00:00
.first()
.then((el: any) => {
const input = cy.get(el);
if (paste) {
//input.invoke("val", value);
this.Paste(el, value)
} else {
input.type(value, {
parseSpecialCharSequences: false,
});
}
});
this.AssertAutoSave()
2022-03-25 11:14:12 +00:00
})
}
public XpathNClick(selector: string) {
cy.xpath(selector)
.first()
.click({ force: true });
this.Sleep()
}
public GetNClick(selector: string) {
cy.get(selector).click({ force: true });
}
public ToggleOnOrOff(propertyName: string, toggle: 'On' | 'Off') {
if (toggle == 'On') {
cy.get(this.locator._propertyToggle(propertyName))
2022-03-25 11:14:12 +00:00
.check({ force: true })
.should("be.checked");
}
else {
cy.get(this.locator._propertyToggle(propertyName))
2022-03-25 11:14:12 +00:00
.uncheck({ force: true })
.should("not.checked");
}
this.AssertAutoSave()
}
public AssertExistingToggleState(propertyName: string, toggle: 'checked' | 'unchecked') {
cy.xpath(this.locator._propertyToggleValue(propertyName)).invoke("attr", "class")
.then((classes) => {
expect(classes).includes(toggle);
});
2022-03-25 11:14:12 +00:00
}
public NavigateBacktoEditor() {
cy.get(this.locator._backToEditor).click({ force: true });
2022-03-25 11:14:12 +00:00
this.Sleep(2000)
}
public GenerateUUID() {
let id = uuid.v4();
id = id.split("-")[0];
cy.wrap(id).as("guid")
}
public GetObjectName() {
//cy.get(this.locator._queryName).invoke("text").then((text) => cy.wrap(text).as("queryName")); or below syntax
return cy.get(this.locator._queryName).invoke("text");
2022-03-25 11:14:12 +00:00
}
public Sleep(timeout = 1000) {
cy.wait(timeout)
}
public ActionContextMenuWithInPane(action: 'Copy to page' | 'Move to page' | 'Delete', subAction = "") {
cy.get(this.locator._contextMenuInPane).click()
cy.xpath(this.locator._visibleTextDiv(action)).should('be.visible').click()
if (action == 'Delete') {
cy.xpath(this.locator._visibleTextDiv('Are you sure?')).click()
this.ValidateNetworkStatus("@deleteAction");
}
2022-03-25 11:14:12 +00:00
if (subAction) {
cy.xpath(this.locator._visibleTextDiv(subAction)).click()
2022-03-25 11:14:12 +00:00
this.Sleep(500)
}
}
public TypeValueNValidate(valueToType: string, fieldName = "") {
this.EnterValue(valueToType, fieldName)
this.VerifyEvaluatedValue(valueToType);
}
public EnterValue(valueToType: string, fieldName = "") {
if (fieldName) {
cy.xpath(this.locator._inputFieldByName(fieldName)).then(($field: any) => {
2022-03-25 11:14:12 +00:00
this.UpdateCodeInput($field, valueToType);
});
} else {
cy.get(this.locator._codeEditorTarget).then(($field: any) => {
2022-03-25 11:14:12 +00:00
this.UpdateCodeInput($field, valueToType);
});
}
}
public UpdateCodeInput($selector: string, value: string) {
cy.get($selector)
.find(".CodeMirror")
.first()
.then((ins: any) => {
const input = ins[0].CodeMirror;
input.focus();
this.Sleep(200)
input.setValue(value);
this.Sleep(200)
});
}
public VerifyEvaluatedValue(currentValue: string) {
this.Sleep(3000);
cy.get(this.locator._evaluatedCurrentValue)
2022-03-25 11:14:12 +00:00
.first()
.should("be.visible")
.should("not.have.text", "undefined");
cy.get(this.locator._evaluatedCurrentValue)
2022-03-25 11:14:12 +00:00
.first()
.click({ force: true })
.then(($text) => {
if ($text.text()) expect($text.text()).to.eq(currentValue);
});
}
public EvaluateExistingPropertyFieldValue(fieldName = "", currentValue = "") {
let toValidate = false;
if (currentValue) toValidate = true;
if (fieldName) {
cy.xpath(this.locator._existingFieldValueByName(fieldName)).eq(0).click();
} else {
cy.xpath(this.locator._codeMirrorCode).click();
}
this.Sleep(3000); //Increasing wait time to evaluate non-undefined values
const val = cy
.get(this.locator._evaluatedCurrentValue)
.first()
.should("be.visible")
.invoke("text");
if (toValidate) expect(val).to.eq(currentValue);
return val;
}
public UploadFile(fixtureName: string, execStat = true) {
cy.get(this.locator._uploadFiles).attachFile(fixtureName).wait(1000);
cy.get(this.locator._uploadBtn).click().wait(3000);
this.ValidateNetworkExecutionSuccess("@postExecute", execStat);
}
public AssertDebugError(label: string, messgae: string) {
cy.get(this.locator._debuggerIcon)
.should("be.visible")
.click({ force: true });
cy.get(this.locator._errorTab)
.should("be.visible")
.click({ force: true });
cy.get(this.locator._debuggerLabel).eq(0)
.invoke("text")
.then(($text) => {
expect($text).to.eq(label);
});
cy.get(this.locator._debugErrorMsg).eq(0)
.invoke("text")
.then(($text) => {
expect($text).contains(messgae);
});
2022-03-25 11:14:12 +00:00
}
}