2022-04-19 12:25:57 +00:00
|
|
|
import TablePage from "../pages/admin_console/components/TablePage";
|
|
|
|
import CommonElements from "../pages/CommonElements";
|
|
|
|
|
|
|
|
export default class ModalUtils extends CommonElements {
|
2021-05-06 08:38:45 +00:00
|
|
|
private modalTitle = ".pf-c-modal-box .pf-c-modal-box__title-text";
|
|
|
|
private modalMessage = ".pf-c-modal-box .pf-c-modal-box__body";
|
2022-02-02 11:44:52 +00:00
|
|
|
private confirmModalBtn = "confirm";
|
|
|
|
private cancelModalBtn = "cancel";
|
2021-05-06 08:38:45 +00:00
|
|
|
private closeModalBtn = ".pf-c-modal-box .pf-m-plain";
|
2022-02-16 16:34:54 +00:00
|
|
|
private copyToClipboardBtn = '[id*="copy-button"]';
|
2022-02-22 12:46:49 +00:00
|
|
|
private addModalDropdownBtn = "#add-dropdown > button";
|
|
|
|
private addModalDropdownItem = "#add-dropdown [role='menuitem']";
|
2022-04-19 12:25:57 +00:00
|
|
|
private tablePage = new TablePage(TablePage.tableSelector);
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(".pf-c-modal-box");
|
|
|
|
}
|
|
|
|
|
|
|
|
table() {
|
|
|
|
return this.tablePage;
|
|
|
|
}
|
|
|
|
|
|
|
|
add() {
|
|
|
|
cy.get(this.primaryBtn).contains("Add").click();
|
|
|
|
return this;
|
|
|
|
}
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
confirmModal() {
|
|
|
|
cy.findByTestId(this.confirmModalBtn).click({ force: true });
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkConfirmButtonText(text: string) {
|
|
|
|
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) {
|
|
|
|
cy.get(this.addModalDropdownBtn).click();
|
|
|
|
cy.get(this.addModalDropdownItem).contains(itemName).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:09:50 +00:00
|
|
|
cancelModal() {
|
2022-02-16 16:34:54 +00:00
|
|
|
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();
|
2021-01-21 12:09:50 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
closeModal() {
|
2022-02-16 16:34:54 +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) {
|
2021-01-21 12:09:50 +00:00
|
|
|
cy.get(this.modalTitle).invoke("text").should("eq", title);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
checkModalMessage(message: string) {
|
2021-01-21 12:09:50 +00:00
|
|
|
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);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
assertModalHasElement(elementSelector: string, exist: boolean) {
|
|
|
|
cy.get(this.parentSelector)
|
|
|
|
.find(elementSelector)
|
|
|
|
.should((exist ? "" : ".not") + "exist");
|
|
|
|
return this;
|
|
|
|
}
|
2021-01-21 12:09:50 +00:00
|
|
|
}
|