2022-12-07 15:28:28 +00:00
|
|
|
import PageObject from "../pages/admin-ui/components/PageObject";
|
|
|
|
import TablePage from "../pages/admin-ui/components/TablePage";
|
2022-04-19 12:25:57 +00:00
|
|
|
|
2022-06-27 08:47:41 +00:00
|
|
|
export default class ModalUtils extends PageObject {
|
2024-04-05 14:37:05 +00:00
|
|
|
#modalDiv = ".pf-v5-c-modal-box";
|
|
|
|
#modalTitle = ".pf-v5-c-modal-box .pf-v5-c-modal-box__title-text";
|
|
|
|
#modalMessage = ".pf-v5-c-modal-box .pf-v5-c-modal-box__body";
|
2023-10-23 18:12:55 +00:00
|
|
|
#confirmModalBtn = "confirm";
|
|
|
|
#cancelModalBtn = "cancel";
|
2024-04-05 14:37:05 +00:00
|
|
|
#closeModalBtn = ".pf-v5-c-modal-box .pf-m-plain";
|
2023-10-23 18:12:55 +00:00
|
|
|
#copyToClipboardBtn = '[id*="copy-button"]';
|
2024-05-30 11:45:58 +00:00
|
|
|
#addModalDropdownBtn = "#add-dropdown";
|
|
|
|
#addModalDropdownItem = ".pf-v5-c-modal-box__footer .pf-v5-c-menu__content";
|
2023-10-23 18:12:55 +00:00
|
|
|
#addBtn = "add";
|
|
|
|
#tablePage = new TablePage(TablePage.tableSelector);
|
2024-09-27 11:25:09 +00:00
|
|
|
#confirmDuplicateModalBtn = "duplicateGroup";
|
2022-04-19 12:25:57 +00:00
|
|
|
|
|
|
|
table() {
|
2023-10-23 18:12:55 +00:00
|
|
|
return this.#tablePage;
|
2022-04-19 12:25:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add() {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.findByTestId(this.#addBtn).click();
|
2022-04-19 12:25:57 +00:00
|
|
|
return this;
|
|
|
|
}
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
confirmModal() {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.findByTestId(this.#confirmModalBtn).click({ force: true });
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2024-09-27 11:25:09 +00:00
|
|
|
confirmDuplicateModal() {
|
2024-10-01 14:08:18 +00:00
|
|
|
cy.findByTestId(this.#confirmDuplicateModalBtn).click();
|
2024-09-27 11:25:09 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
checkConfirmButtonText(text: string) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.findByTestId(this.#confirmModalBtn).contains(text);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-02-22 12:46:49 +00:00
|
|
|
confirmModalWithItem(itemName: string) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#addModalDropdownBtn).click();
|
|
|
|
cy.get(this.#addModalDropdownItem).contains(itemName).click();
|
2022-02-22 12:46:49 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:09:50 +00:00
|
|
|
cancelModal() {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.findByTestId(this.#cancelModalBtn).click({ force: true });
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
cancelButtonContains(text: string) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.findByTestId(this.#cancelModalBtn).contains(text);
|
2022-02-16 16:34:54 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
copyToClipboard() {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#copyToClipboardBtn).click();
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
closeModal() {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#closeModalBtn).click({ force: true });
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
checkModalTitle(title: string) {
|
2022-06-27 08:47:41 +00:00
|
|
|
//deprecated
|
|
|
|
this.assertModalTitleEqual(title);
|
2021-01-21 12:09:50 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
checkModalMessage(message: string) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#modalMessage).invoke("text").should("eq", message);
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2022-05-19 13:43:48 +00:00
|
|
|
|
|
|
|
assertModalMessageContainText(text: string) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#modalMessage).should("contain.text", text);
|
2022-05-19 13:43:48 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
assertModalHasElement(elementSelector: string, exist: boolean) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#modalDiv)
|
2022-05-19 13:43:48 +00:00
|
|
|
.find(elementSelector)
|
|
|
|
.should((exist ? "" : ".not") + "exist");
|
|
|
|
return this;
|
|
|
|
}
|
2022-06-27 08:47:41 +00:00
|
|
|
|
|
|
|
assertModalVisible(isVisible: boolean) {
|
2023-10-23 18:12:55 +00:00
|
|
|
super.assertIsVisible(cy.get(this.#modalDiv), isVisible);
|
2022-06-27 08:47:41 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
assertModalExist(exist: boolean) {
|
2023-10-23 18:12:55 +00:00
|
|
|
super.assertExist(cy.get(this.#modalDiv), exist);
|
2022-06-27 08:47:41 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
assertModalTitleEqual(text: string) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#modalTitle).invoke("text").should("eq", text);
|
2022-06-27 08:47:41 +00:00
|
|
|
return this;
|
|
|
|
}
|
2021-01-21 12:09:50 +00:00
|
|
|
}
|