2022-02-22 12:46:49 +00:00
|
|
|
export enum Filter {
|
|
|
|
Name = "Name",
|
|
|
|
AssignedType = "Assigned type",
|
|
|
|
Protocol = "Protocol",
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum FilterAssignedType {
|
|
|
|
AllTypes = "All types",
|
|
|
|
Default = "Default",
|
|
|
|
Optional = "Optional",
|
|
|
|
None = "None",
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum FilterProtocol {
|
|
|
|
All = "All",
|
|
|
|
SAML = "SAML",
|
|
|
|
OpenID = "openid-connect", //TODO: text to be unified with item text
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum FilterSession {
|
|
|
|
AllSessionTypes = "All session types",
|
|
|
|
RegularSSO = "Regular SSO",
|
|
|
|
Offline = "Offline",
|
|
|
|
DirectGrant = "Direct grant",
|
|
|
|
ServiceAccount = "Service account",
|
|
|
|
}
|
|
|
|
|
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';
|
2022-02-22 12:46:49 +00:00
|
|
|
private tableToolbar = ".pf-c-toolbar";
|
2021-10-19 15:30:57 +00:00
|
|
|
private itemsRows = "table:visible";
|
2022-02-28 17:48:52 +00:00
|
|
|
private deleteUserButton = "delete-user-btn";
|
2022-02-16 16:34:54 +00:00
|
|
|
private emptyListImg =
|
|
|
|
'[role="tabpanel"]:not([hidden]) [data-testid="empty-state"]';
|
2022-02-28 17:48:52 +00:00
|
|
|
public emptyState = "empty-state";
|
2022-02-16 16:34:54 +00:00
|
|
|
private progressBar = '[role="progressbar"]';
|
2021-05-27 11:41:29 +00:00
|
|
|
private itemRowDrpDwn = ".pf-c-dropdown__toggle";
|
2022-02-22 12:46:49 +00:00
|
|
|
private itemRowSelect = ".pf-c-select__toggle:nth-child(1)";
|
|
|
|
private itemRowSelectItem = ".pf-c-select__menu-item";
|
|
|
|
private itemCheckbox = ".pf-c-table__check";
|
2021-05-27 11:41:29 +00:00
|
|
|
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";
|
2022-02-16 16:34:54 +00:00
|
|
|
private listHeaderPrimaryBtn =
|
2021-07-21 15:08:40 +00:00
|
|
|
".pf-c-page__main .pf-c-toolbar__content-section .pf-m-primary:visible";
|
2022-02-16 16:34:54 +00:00
|
|
|
private listHeaderSecondaryBtn =
|
2021-07-21 15:08:40 +00:00
|
|
|
".pf-c-page__main .pf-c-toolbar__content-section .pf-m-link";
|
2021-12-10 12:24:26 +00:00
|
|
|
private previousPageBtn =
|
|
|
|
"div[class=pf-c-pagination__nav-control] button[data-action=previous]:visible";
|
|
|
|
private nextPageBtn =
|
|
|
|
"div[class=pf-c-pagination__nav-control] button[data-action=next]:visible";
|
|
|
|
public tableRowItem = "tbody tr[data-ouia-component-type]:visible";
|
2022-02-22 12:46:49 +00:00
|
|
|
private table = "table[aria-label]";
|
|
|
|
private filterSessionDropdownButton = ".pf-c-select button:nth-child(1)";
|
|
|
|
private filterDropdownButton = "[class*='searchtype'] button";
|
|
|
|
private dropdownItem = ".pf-c-dropdown__menu-item";
|
|
|
|
private changeTypeToButton = ".pf-c-select__toggle";
|
|
|
|
private toolbarChangeType = "#change-type-dropdown";
|
2021-12-10 12:24:26 +00:00
|
|
|
|
|
|
|
showPreviousPageTableItems() {
|
|
|
|
cy.get(this.previousPageBtn).first().click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
showNextPageTableItems() {
|
|
|
|
cy.get(this.nextPageBtn).first().click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2021-01-27 12:56:28 +00:00
|
|
|
|
|
|
|
goToCreateItem() {
|
2022-02-16 16:34:54 +00:00
|
|
|
cy.get(this.listHeaderPrimaryBtn).click();
|
2021-01-27 12:56:28 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
goToImportItem() {
|
2022-02-16 16:34:54 +00:00
|
|
|
cy.get(this.listHeaderSecondaryBtn).click();
|
2021-01-27 12:56:28 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-02 09:12:40 +00:00
|
|
|
searchItem(searchValue: string, wait = true) {
|
|
|
|
if (wait) {
|
2022-03-06 15:25:37 +00:00
|
|
|
const searchUrl = `/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
|
|
|
}
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
cy.get(this.searchInput).clear();
|
|
|
|
if (searchValue) {
|
|
|
|
cy.get(this.searchInput).type(searchValue);
|
|
|
|
}
|
2021-01-27 12:56:28 +00:00
|
|
|
cy.get(this.searchBtn).click();
|
2022-02-16 16:34:54 +00:00
|
|
|
|
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
|
|
|
}
|
2022-02-16 16:34:54 +00:00
|
|
|
|
2021-01-27 12:56:28 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-02-22 12:46:49 +00:00
|
|
|
clickSearchBarActionButton() {
|
|
|
|
cy.get(this.tableToolbar).find(this.itemRowDrpDwn).last().click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
clickSearchBarActionItem(itemName: string) {
|
|
|
|
cy.get(this.tableToolbar)
|
|
|
|
.find(this.dropdownItem)
|
|
|
|
.contains(itemName)
|
|
|
|
.click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-29 11:37:47 +00:00
|
|
|
clickRowDetails(itemName: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
2021-05-27 11:41:29 +00:00
|
|
|
.parentsUntil("tbody")
|
2021-03-29 11:37:47 +00:00
|
|
|
.find(this.itemRowDrpDwn)
|
|
|
|
.click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
markItemRow(itemName: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find('input[name*="checkrow"]')
|
|
|
|
.click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
removeMarkedItems() {
|
|
|
|
cy.get(this.listHeaderSecondaryBtn).contains("Remove").click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkRowColumnValue(itemName: string, column: number, value: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find("td:nth-child(" + column + ")")
|
|
|
|
.should("have.text", value);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-29 11:37:47 +00:00
|
|
|
clickDetailMenu(name: string) {
|
|
|
|
cy.get(this.itemsRows).contains(name).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-02-22 12:46:49 +00:00
|
|
|
clickItemCheckbox(itemName: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find(this.itemCheckbox)
|
|
|
|
.click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
clickRowSelectButton(itemName: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find(this.itemRowSelect)
|
|
|
|
.click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
clickPrimaryButton() {
|
|
|
|
cy.get(this.listHeaderPrimaryBtn).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
clickRowSelectItem(rowItemName: string, selectItemName: string) {
|
|
|
|
this.clickRowSelectButton(rowItemName);
|
|
|
|
cy.get(this.itemRowSelectItem).contains(selectItemName).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;
|
|
|
|
}
|
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
checkEmptyList() {
|
|
|
|
cy.get(this.emptyListImg).should("be.visible");
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-02-28 17:48:52 +00:00
|
|
|
deleteItemFromSearchBar(itemName: string) {
|
|
|
|
this.markItemRow(itemName);
|
|
|
|
cy.findByTestId(this.deleteUserButton).click();
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2022-02-22 12:46:49 +00:00
|
|
|
|
|
|
|
removeItem(itemName: string) {
|
|
|
|
this.clickRowDetails(itemName);
|
|
|
|
this.clickDetailMenu("Remove");
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
itemsEqualTo(amount: number) {
|
|
|
|
cy.get(this.tableRowItem).its("length").should("be.eq", amount);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
itemsGreaterThan(amount: number) {
|
|
|
|
cy.get(this.tableRowItem).its("length").should("be.gt", amount);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
itemContainValue(itemName: string, colIndex: number, value: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find("td")
|
|
|
|
.eq(colIndex)
|
|
|
|
.should("contain", value);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectFilter(filter: Filter) {
|
|
|
|
cy.get(this.filterDropdownButton).first().click();
|
|
|
|
cy.get(this.dropdownItem).contains(filter).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectSecondaryFilter(itemName: string) {
|
|
|
|
cy.get(this.filterDropdownButton).last().click();
|
|
|
|
cy.get(this.itemRowSelectItem).contains(itemName).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectSecondaryFilterAssignedType(assignedType: FilterAssignedType) {
|
|
|
|
this.selectSecondaryFilter(assignedType);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectSecondaryFilterProtocol(protocol: FilterProtocol) {
|
|
|
|
this.selectSecondaryFilter(protocol);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectSecondaryFilterSession(sessionName: FilterSession) {
|
|
|
|
cy.get(this.filterSessionDropdownButton).click();
|
|
|
|
cy.get(this.itemRowSelectItem).contains(sessionName);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
changeTypeToOfSelectedItems(assignedType: FilterAssignedType) {
|
2022-03-06 15:25:37 +00:00
|
|
|
cy.intercept("/admin/realms/master/client-scopes").as("load");
|
2022-02-22 12:46:49 +00:00
|
|
|
cy.get(this.toolbarChangeType).click();
|
|
|
|
cy.get(this.itemRowSelectItem).contains(assignedType).click();
|
|
|
|
cy.wait("@load");
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
changeTypeToOfItem(assignedType: FilterAssignedType, itemName: string) {
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find(this.changeTypeToButton)
|
|
|
|
.first()
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get(this.itemsRows)
|
|
|
|
.contains(itemName)
|
|
|
|
.parentsUntil("tbody")
|
|
|
|
.find(this.changeTypeToButton)
|
|
|
|
.contains(assignedType)
|
|
|
|
.click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkInSearchBarChangeTypeToButtonIsDisabled(disabled: boolean = true) {
|
|
|
|
let condition = "be.disabled";
|
|
|
|
if (!disabled) {
|
|
|
|
condition = "be.enabled";
|
|
|
|
}
|
|
|
|
cy.get(this.changeTypeToButton).first().should(condition);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkDropdownItemIsDisabled(itemName: string, disabled: boolean = true) {
|
|
|
|
cy.get(this.dropdownItem)
|
|
|
|
.contains(itemName)
|
|
|
|
.should("have.attr", "aria-disabled", String(disabled));
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkTableExists(exists: boolean = true) {
|
|
|
|
let condition = "be.visible";
|
|
|
|
if (!exists) {
|
|
|
|
condition = "not.be.visible";
|
|
|
|
}
|
|
|
|
cy.get(this.table).should(condition);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2021-01-27 12:56:28 +00:00
|
|
|
}
|