keycloak-scim/cypress/support/pages/admin_console/ListingPage.ts
Erik Jan de Wit 8d72f8a705
Fixing cypress tests (#586)
* upgrade cypress

* fixed delete now has dialog

* also check "unAssign"

* client type no longer required

* providers and group changes

* grp creation working

* moved create realm button ouside the dropdown

* sped up test and added cleanup

* Revert "moved create realm button ouside the dropdown"

This reverts commit e2076a5305808417de910ba8fada8e528e5c356a.

* make test re-runnable

* removed un needed navigation

* Fix misformed Cypress config for GitHub Action

* cleanup after test

* fixed cleanup

* temporary removed this test

* also remove user "new"

* try adding a wait for CI

* get different modal id

* add {force: true} to modal functions

* mv grp search last and ignore 401

* try using cy.get and disable video for testing

* add back video artifacts

Co-authored-by: mfrances <mfrances@redhat.com>
Co-authored-by: Jon Koops <jonkoops@gmail.com>
Co-authored-by: jenny-s51 <jshandel@redhat.com>
2021-05-06 07:31:40 +02:00

91 lines
2.1 KiB
TypeScript

export default class ListingPage {
searchInput: string;
itemsRows: string;
itemRowDrpDwn: string;
exportBtn: string;
deleteBtn: string;
searchBtn: string;
createBtn: string;
importBtn: string;
constructor() {
this.searchInput = '.pf-c-toolbar__item [type="search"]:visible';
this.itemsRows = "table";
this.itemRowDrpDwn = ".pf-c-dropdown > button";
this.exportBtn = '[role="menuitem"]:nth-child(1)';
this.deleteBtn = '[role="menuitem"]:nth-child(2)';
this.searchBtn =
".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-control:visible";
this.createBtn =
".pf-c-page__main .pf-c-toolbar__content-section button.pf-m-primary:visible";
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;
}
searchItem(searchValue: string, wait = true) {
if (wait) {
const searchUrl = `/auth/admin/realms/master/*${searchValue}*`;
cy.intercept(searchUrl).as("search");
}
cy.get(this.searchInput).type(searchValue);
cy.get(this.searchBtn).click();
if (wait) {
cy.wait(["@search"]);
}
return this;
}
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;
}
itemExist(itemName: string, exist = true) {
cy.get(this.itemsRows)
.contains(itemName)
.should((!exist ? "not." : "") + "exist");
return this;
}
goToItemDetails(itemName: string) {
cy.get(this.itemsRows).contains(itemName).click();
return this;
}
deleteItem(itemName: string) {
this.clickRowDetails(itemName);
this.clickDetailMenu("Delete");
return this;
}
exportItem(itemName: string) {
this.clickRowDetails(itemName);
this.clickDetailMenu("Export");
return this;
}
}