2021-01-27 12:56:28 +00:00
|
|
|
export default class ListingPage {
|
|
|
|
searchInput: string;
|
|
|
|
itemsRows: string;
|
|
|
|
itemRowDrpDwn: string;
|
|
|
|
exportBtn: string;
|
|
|
|
deleteBtn: string;
|
|
|
|
searchBtn: string;
|
|
|
|
createBtn: string;
|
|
|
|
importBtn: string;
|
|
|
|
|
|
|
|
constructor() {
|
2021-05-04 08:11:58 +00:00
|
|
|
this.searchInput = '.pf-c-toolbar__item [type="search"]:visible';
|
2021-04-07 17:58:29 +00:00
|
|
|
this.itemsRows = "table";
|
2021-01-27 12:56:28 +00:00
|
|
|
this.itemRowDrpDwn = ".pf-c-dropdown > button";
|
|
|
|
this.exportBtn = '[role="menuitem"]:nth-child(1)';
|
|
|
|
this.deleteBtn = '[role="menuitem"]:nth-child(2)';
|
|
|
|
this.searchBtn =
|
2021-05-04 08:11:58 +00:00
|
|
|
".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-control:visible";
|
2021-01-27 12:56:28 +00:00
|
|
|
this.createBtn =
|
2021-05-06 05:31:40 +00:00
|
|
|
".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-primary:visible";
|
2021-01-27 12:56:28 +00:00
|
|
|
this.importBtn =
|
|
|
|
".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-link";
|
|
|
|
}
|
|
|
|
|
|
|
|
goToCreateItem() {
|
|
|
|
cy.get(this.createBtn).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
goToImportItem() {
|
|
|
|
cy.get(this.importBtn).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-02 09:12:40 +00:00
|
|
|
searchItem(searchValue: string, wait = true) {
|
|
|
|
if (wait) {
|
2021-03-18 12:48:14 +00:00
|
|
|
const searchUrl = `/auth/admin/realms/master/*${searchValue}*`;
|
2021-03-05 13:47:59 +00:00
|
|
|
cy.intercept(searchUrl).as("search");
|
2021-03-02 09:12:40 +00:00
|
|
|
}
|
2021-01-27 12:56:28 +00:00
|
|
|
cy.get(this.searchInput).type(searchValue);
|
|
|
|
cy.get(this.searchBtn).click();
|
2021-03-02 09:12:40 +00:00
|
|
|
if (wait) {
|
2021-03-05 13:47:59 +00:00
|
|
|
cy.wait(["@search"]);
|
2021-03-02 09:12:40 +00:00
|
|
|
}
|
2021-01-27 12:56:28 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-29 11:37:47 +00:00
|
|
|
clickRowDetails(itemName: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find(this.itemRowDrpDwn)
|
|
|
|
.click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
clickDetailMenu(name: string) {
|
|
|
|
cy.get(this.itemsRows).contains(name).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
itemExist(itemName: string, exist = true) {
|
2021-01-27 12:56:28 +00:00
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.should((!exist ? "not." : "") + "exist");
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
goToItemDetails(itemName: string) {
|
2021-01-27 12:56:28 +00:00
|
|
|
cy.get(this.itemsRows).contains(itemName).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
deleteItem(itemName: string) {
|
2021-03-29 11:37:47 +00:00
|
|
|
this.clickRowDetails(itemName);
|
|
|
|
this.clickDetailMenu("Delete");
|
2021-01-27 12:56:28 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
exportItem(itemName: string) {
|
2021-03-29 11:37:47 +00:00
|
|
|
this.clickRowDetails(itemName);
|
|
|
|
this.clickDetailMenu("Export");
|
2021-01-27 12:56:28 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|