2022-04-19 12:25:57 +00:00
|
|
|
import { trim } from "lodash-es";
|
|
|
|
|
|
|
|
export default class CommonElements {
|
|
|
|
protected parentSelector;
|
|
|
|
protected primaryBtn;
|
|
|
|
protected secondaryBtn;
|
|
|
|
protected secondaryBtnLink;
|
|
|
|
protected dropdownMenuItem;
|
|
|
|
protected selectMenuItem;
|
|
|
|
protected dropdownToggleBtn;
|
|
|
|
protected dropdownSelectToggleBtn;
|
|
|
|
protected dropdownSelectToggleItem;
|
|
|
|
|
|
|
|
constructor(parentSelector = "") {
|
|
|
|
this.parentSelector = trim(parentSelector) + " ";
|
|
|
|
this.primaryBtn = this.parentSelector + ".pf-c-button.pf-m-primary";
|
|
|
|
this.secondaryBtn = this.parentSelector + ".pf-c-button.pf-m-secondary";
|
|
|
|
this.secondaryBtnLink = this.parentSelector + ".pf-c-button.pf-m-link";
|
|
|
|
this.dropdownMenuItem =
|
|
|
|
this.parentSelector + ".pf-c-dropdown__menu .pf-c-dropdown__menu-item";
|
|
|
|
this.selectMenuItem =
|
|
|
|
this.parentSelector + ".pf-c-select__menu .pf-c-select__menu-item";
|
|
|
|
this.dropdownToggleBtn = this.parentSelector + ".pf-c-dropdown__toggle";
|
|
|
|
this.dropdownSelectToggleBtn = this.parentSelector + ".pf-c-select__toggle";
|
|
|
|
this.dropdownSelectToggleItem =
|
|
|
|
this.parentSelector + ".pf-c-select__menu > li";
|
|
|
|
}
|
|
|
|
|
2022-05-19 13:43:48 +00:00
|
|
|
clickPrimaryBtn() {
|
|
|
|
cy.get(this.primaryBtn).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-09-15 10:55:57 +00:00
|
|
|
clickSecondaryBtn(buttonName: string, force = false) {
|
|
|
|
cy.get(this.secondaryBtn).contains(buttonName).click({ force: force });
|
2022-04-19 12:25:57 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkIfExists(exist: boolean) {
|
|
|
|
cy.get(this.parentSelector).should((!exist ? "not." : "") + "exist");
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkElementIsDisabled(
|
|
|
|
element: Cypress.Chainable<JQuery<HTMLElement>>,
|
2023-07-11 14:03:21 +00:00
|
|
|
disabled: boolean,
|
2022-04-19 12:25:57 +00:00
|
|
|
) {
|
|
|
|
element.then(($btn) => {
|
|
|
|
if ($btn.hasClass("pf-m-disabled")) {
|
|
|
|
element.should(
|
|
|
|
(!disabled ? "not." : "") + "have.class",
|
2023-07-11 14:03:21 +00:00
|
|
|
"pf-m-disabled",
|
2022-04-19 12:25:57 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
element.should((!disabled ? "not." : "") + "have.attr", "disabled");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|