PromucFlow_constructor/app/client/cypress/support/Pages/AggregateHelper.ts
Aishwarya-U-R c711e39849
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 09:51:43 +05:30

150 lines
5.0 KiB
TypeScript

import { CommonLocators } from "../Objects/CommonLocators";
const locator = new CommonLocators();
export class AggregateHelper {
public AddDsl(dsl: string) {
let currentURL;
let pageid: string;
let layoutId;
cy.url().then((url) => {
currentURL = url;
const myRegexp = /pages(.*)/;
const match = myRegexp.exec(currentURL);
pageid = match![1].split("/")[1];
cy.log(pageid + "page id");
//Fetch the layout id
cy.server()
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((response) => {
//cy.log("Pages resposne is : " + response.body);
expect(response.status).equal(200);
cy.reload();
});
});
});
}
public NavigateToCreateNewTabPage() {
cy.get(locator._addEntityAPI).last()
.should("be.visible")
.click({ force: true });
cy.get(locator._integrationCreateNew)
.should("be.visible")
.click({ force: true });
cy.get(locator._loading).should("not.exist");
}
public StartServerAndRoutes() {
cy.intercept("POST", "/api/v1/actions").as("createNewApi");
cy.intercept("PUT", "/api/v1/actions/*").as("saveAction");
}
public RenameWithInPane(renameVal: string) {
cy.get(locator._actionName).click({ force: true });
cy.get(locator._actionTxt)
.clear()
.type(renameVal, { force: true })
.should("have.value", renameVal)
.blur();
}
public WaitAutoSave() {
// wait for save query to trigger & n/w call to finish occuring
cy.get(locator._saveStatusSuccess, { timeout: 40000 }).should("exist");
}
public SelectEntityByName(entityNameinLeftSidebar: string) {
cy.xpath(locator._entityNameInExplorer(entityNameinLeftSidebar))
.last()
.click({ force: true })
this.Sleep(2000)
}
public ValidateEntityPresenceInExplorer(entityNameinLeftSidebar: string) {
cy.xpath(locator._entityNameInExplorer(entityNameinLeftSidebar))
.should("have.length", 1);
}
public NavigateToHome() {
cy.get(locator._homeIcon).click({ force: true });
this.Sleep(3000)
cy.wait("@applications");
cy.get(locator._homePageAppCreateBtn).should("be.visible").should("be.enabled");
//cy.get(this._homePageAppCreateBtn);
}
public CreateNewApplication() {
cy.get(locator._homePageAppCreateBtn).click({ force: true })
cy.wait("@createNewApplication").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
}
public ValidateCodeEditorContent(selector: string, contentToValidate: any) {
cy.get(selector).within(() => {
cy.get(".CodeMirror-code").should("have.text", contentToValidate);
});
}
public DeployApp() {
cy.server();
cy.route("POST", "/api/v1/applications/publish/*").as("publishApp");
// Wait before publish
this.Sleep(2000)
this.WaitAutoSave()
// 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);
});
});
cy.get(locator._publishButton).click();
cy.wait("@publishApp");
cy.url().should("include", "/pages");
cy.log("Pagename: " + localStorage.getItem("PageName"));
}
public expandCollapseEntity(entityName: string) {
cy.xpath(locator._expandCollapseArrow(entityName))
.click({ multiple: true }).wait(500);
}
public ActionContextMenuByEntityName(entityNameinLeftSidebar: string, action = "Delete", subAction = "") {
this.Sleep()
cy.xpath(locator._contextMenu(entityNameinLeftSidebar)).first().click({ force: true });
cy.xpath(locator._contextMenuItem(action)).click({ force: true }).wait(500);
if (subAction)
cy.xpath(locator._contextMenuItem(subAction)).click({ force: true }).wait(500);
if (action == "Delete")
cy.xpath("//div[text()='" + entityNameinLeftSidebar + "']").should(
"not.exist");
}
public AddNewPage() {
cy.get(locator._newPage)
.first()
.click();
cy.wait("@createPage").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
}
public Sleep(timeout = 1000) {
cy.wait(timeout)
}
}