keycloak-scim/js/apps/admin-ui/cypress/support/util/ModalUtils.ts

115 lines
2.7 KiB
TypeScript
Raw Normal View History

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 {
#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";
#confirmModalBtn = "confirm";
#cancelModalBtn = "cancel";
#closeModalBtn = ".pf-v5-c-modal-box .pf-m-plain";
#copyToClipboardBtn = '[id*="copy-button"]';
remove all use of deprecated Select and Dropdown (#29270) * removed deprecated select Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * some more deprecation removal working towards fixing: #28197 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * changed to use new api Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * more deprecation removal Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed merge error Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fix tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * small fix Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed merge error Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * no more default text for SelectOption Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * changed to use id Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed dropdown in keycloakCard and test fixes Signed-off-by: mfrances <mfrances@redhat.com> Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed lint error Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fix dropdown/select related test failures Signed-off-by: mfrances <mfrances@redhat.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * i18n label Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fix test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed tests Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * removed Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed merge error Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> Signed-off-by: mfrances <mfrances@redhat.com> Co-authored-by: mfrances <mfrances@redhat.com>
2024-05-30 11:45:58 +00:00
#addModalDropdownBtn = "#add-dropdown";
#addModalDropdownItem = ".pf-v5-c-modal-box__footer .pf-v5-c-menu__content";
#addBtn = "add";
#tablePage = new TablePage(TablePage.tableSelector);
#confirmDuplicateModalBtn = "duplicateGroup";
2022-04-19 12:25:57 +00:00
table() {
return this.#tablePage;
2022-04-19 12:25:57 +00:00
}
add() {
cy.findByTestId(this.#addBtn).click();
2022-04-19 12:25:57 +00:00
return this;
}
confirmModal() {
cy.findByTestId(this.#confirmModalBtn).click({ force: true });
return this;
}
confirmDuplicateModal() {
cy.findByTestId(this.#confirmDuplicateModalBtn).click();
return this;
}
checkConfirmButtonText(text: string) {
cy.findByTestId(this.#confirmModalBtn).contains(text);
return this;
}
confirmModalWithItem(itemName: string) {
cy.get(this.#addModalDropdownBtn).click();
cy.get(this.#addModalDropdownItem).contains(itemName).click();
return this;
}
cancelModal() {
cy.findByTestId(this.#cancelModalBtn).click({ force: true });
return this;
}
cancelButtonContains(text: string) {
cy.findByTestId(this.#cancelModalBtn).contains(text);
return this;
}
copyToClipboard() {
cy.get(this.#copyToClipboardBtn).click();
return this;
}
closeModal() {
cy.get(this.#closeModalBtn).click({ force: true });
return this;
}
checkModalTitle(title: string) {
2022-06-27 08:47:41 +00:00
//deprecated
this.assertModalTitleEqual(title);
return this;
}
checkModalMessage(message: string) {
cy.get(this.#modalMessage).invoke("text").should("eq", message);
return this;
}
2022-05-19 13:43:48 +00:00
assertModalMessageContainText(text: string) {
cy.get(this.#modalMessage).should("contain.text", text);
2022-05-19 13:43:48 +00:00
return this;
}
assertModalHasElement(elementSelector: string, exist: boolean) {
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) {
super.assertIsVisible(cy.get(this.#modalDiv), isVisible);
2022-06-27 08:47:41 +00:00
return this;
}
assertModalExist(exist: boolean) {
super.assertExist(cy.get(this.#modalDiv), exist);
2022-06-27 08:47:41 +00:00
return this;
}
assertModalTitleEqual(text: string) {
cy.get(this.#modalTitle).invoke("text").should("eq", text);
2022-06-27 08:47:41 +00:00
return this;
}
}