2022-04-19 12:25:57 +00:00
|
|
|
import CommonElements from "../CommonElements";
|
|
|
|
export default class Masthead extends CommonElements {
|
2022-10-06 14:18:33 +00:00
|
|
|
private logoBtn = ".pf-c-page__header-brand-link img";
|
2021-05-06 08:38:45 +00:00
|
|
|
private helpBtn = "#help";
|
2022-02-16 16:34:54 +00:00
|
|
|
private closeAlertMessageBtn = ".pf-c-alert__action button";
|
|
|
|
private closeLastAlertMessageBtn =
|
2022-10-24 11:43:46 +00:00
|
|
|
"li:first-child .pf-c-alert__action button";
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
private alertMessage = ".pf-c-alert__title";
|
2021-05-06 08:38:45 +00:00
|
|
|
private userDrpDwn = "#user-dropdown";
|
|
|
|
private userDrpDwnKebab = "#user-dropdown-kebab";
|
2022-10-24 11:43:46 +00:00
|
|
|
private globalAlerts = "global-alerts";
|
|
|
|
|
|
|
|
private getAlertsContainer() {
|
|
|
|
return cy.findByTestId(this.globalAlerts);
|
|
|
|
}
|
2021-01-21 12:09:50 +00:00
|
|
|
|
2022-01-05 09:56:38 +00:00
|
|
|
checkIsAdminConsole() {
|
2021-01-21 12:09:50 +00:00
|
|
|
cy.get(this.logoBtn).should("exist");
|
|
|
|
cy.get(this.userDrpDwn).should("exist");
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:07:12 +00:00
|
|
|
setMobileMode(isMobileMode: boolean) {
|
2021-01-21 12:09:50 +00:00
|
|
|
if (isMobileMode) {
|
|
|
|
cy.viewport("iphone-6");
|
|
|
|
} else {
|
2021-01-27 12:56:28 +00:00
|
|
|
cy.viewport(1024, 768);
|
2021-01-21 12:09:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleGlobalHelp() {
|
|
|
|
cy.get(this.helpBtn).click();
|
|
|
|
cy.get("#enableHelp").click({ force: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
userDropdown() {
|
2022-07-12 13:21:18 +00:00
|
|
|
return cy
|
|
|
|
.document()
|
|
|
|
.then(({ documentElement }) => documentElement.getBoundingClientRect())
|
|
|
|
.then(({ width }) =>
|
|
|
|
cy.get(width < 1024 ? this.userDrpDwnKebab : this.userDrpDwn)
|
|
|
|
);
|
2021-01-21 12:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
signOut() {
|
|
|
|
this.userDropdown().click();
|
|
|
|
cy.get("#sign-out").click();
|
|
|
|
}
|
|
|
|
|
|
|
|
accountManagement() {
|
|
|
|
this.userDropdown().click();
|
|
|
|
cy.get("#manage-account").click();
|
|
|
|
}
|
|
|
|
|
2022-09-15 10:55:57 +00:00
|
|
|
checkNotificationMessage(message: string, closeNotification = true) {
|
2022-10-24 11:43:46 +00:00
|
|
|
this.getAlertsContainer()
|
|
|
|
.find(this.alertMessage)
|
|
|
|
.should("contain.text", message);
|
2022-04-21 12:57:30 +00:00
|
|
|
|
|
|
|
if (closeNotification) {
|
2022-10-24 11:43:46 +00:00
|
|
|
this.getAlertsContainer()
|
|
|
|
.find(`button[title="` + message.replaceAll('"', '\\"') + `"]`)
|
2022-09-15 10:55:57 +00:00
|
|
|
.last()
|
|
|
|
.click({ force: true });
|
2022-04-21 12:57:30 +00:00
|
|
|
}
|
2021-01-21 12:09:50 +00:00
|
|
|
return this;
|
|
|
|
}
|
2021-05-06 09:06:20 +00:00
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
closeLastAlertMessage() {
|
2022-10-24 11:43:46 +00:00
|
|
|
this.getAlertsContainer().find(this.closeLastAlertMessageBtn).click();
|
2022-02-16 16:34:54 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
closeAllAlertMessages() {
|
2022-10-24 11:43:46 +00:00
|
|
|
this.getAlertsContainer().find(this.closeAlertMessageBtn).click({
|
|
|
|
force: true,
|
|
|
|
multiple: true,
|
2022-08-12 10:52:41 +00:00
|
|
|
});
|
2022-10-24 11:43:46 +00:00
|
|
|
|
2022-02-16 16:34:54 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-05-06 09:06:20 +00:00
|
|
|
checkKebabShown() {
|
2022-02-16 16:34:54 +00:00
|
|
|
cy.get(this.userDrpDwn).should("not.be.visible");
|
2021-05-06 09:06:20 +00:00
|
|
|
cy.get(this.userDrpDwnKebab).should("exist");
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2021-01-21 12:09:50 +00:00
|
|
|
}
|