keycloak-scim/cypress/support/pages/admin_console/ListingPage.ts

81 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-01-27 12:56:28 +00:00
export default class ListingPage {
2021-05-27 11:41:29 +00:00
private searchInput = '.pf-c-toolbar__item [type="search"]:visible';
private itemsRows = "table";
private itemRowDrpDwn = ".pf-c-dropdown__toggle";
public exportBtn = '[role="menuitem"]:nth-child(1)';
public deleteBtn = '[role="menuitem"]:nth-child(2)';
private searchBtn =
".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-control:visible";
private createBtn =
".pf-c-page__main .pf-c-toolbar__content-section .pf-m-primary:visible";
2021-05-27 11:41:29 +00:00
private importBtn =
".pf-c-page__main .pf-c-toolbar__content-section .pf-m-link";
2021-01-27 12:56:28 +00:00
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) {
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
}
cy.get(this.searchInput).clear().type(searchValue);
2021-01-27 12:56:28 +00:00
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;
}
clickRowDetails(itemName: string) {
cy.get(this.itemsRows)
.contains(itemName)
2021-05-27 11:41:29 +00:00
.parentsUntil("tbody")
.find(this.itemRowDrpDwn)
.click();
return this;
}
clickDetailMenu(name: string) {
cy.get(this.itemsRows).contains(name).click();
return this;
}
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;
}
goToItemDetails(itemName: string) {
2021-01-27 12:56:28 +00:00
cy.get(this.itemsRows).contains(itemName).click();
return this;
}
deleteItem(itemName: string) {
this.clickRowDetails(itemName);
this.clickDetailMenu("Delete");
2021-01-27 12:56:28 +00:00
return this;
}
exportItem(itemName: string) {
this.clickRowDetails(itemName);
this.clickDetailMenu("Export");
2021-01-27 12:56:28 +00:00
return this;
}
}