PromucFlow_constructor/app/client/cypress/support/pageObjects/AggregateHelper.ts
Aishwarya-U-R ac705a49f3
test: Automated tests for RestApi Bug in Typescript (#10137)
* 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
2022-01-06 20:36:17 +05:30

101 lines
3.5 KiB
TypeScript

export class AggregateHelper {
private _addEntityAPI = ".datasources .t--entity-add-btn"
private _integrationCreateNew = "[data-cy=t--tab-CREATE_NEW]"
_loading = "#loading"
private _actionName = ".t--action-name-edit-field span"
private _actionTxt = ".t--action-name-edit-field input"
private _entityNameInExplorer = (entityNameinLeftSidebar: string) => "//div[contains(@class, 't--entity-name')][text()='" + entityNameinLeftSidebar + "']"
private _homeIcon = ".t--appsmith-logo"
private _homePageAppCreateBtn = ".t--applications-container .createnew"
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(this._addEntityAPI).last()
.should("be.visible")
.click({ force: true });
cy.get(this._integrationCreateNew)
.should("be.visible")
.click({ force: true });
cy.get(this._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(this._actionName).click({ force: true });
cy.get(this._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.wait("@saveAction", { timeout: 8000 });
}
public SelectEntityByName(entityNameinLeftSidebar: string) {
cy.xpath(this._entityNameInExplorer(entityNameinLeftSidebar))
.last()
.click({ force: true })
.wait(2000);
}
public NavigateToHome() {
cy.get(this._homeIcon).click({ force: true });
cy.wait(3000);
cy.wait("@applications");
cy.get(this._homePageAppCreateBtn).should("be.visible").should("be.enabled");
//cy.get(this._homePageAppCreateBtn);
}
public CreateNewApplication() {
cy.get(this._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);
});
}
}