keycloak-scim/apps/admin-ui/cypress/support/pages/admin_console/Masthead.ts

82 lines
2 KiB
TypeScript
Raw Normal View History

2022-04-19 12:25:57 +00:00
import CommonElements from "../CommonElements";
export default class Masthead extends CommonElements {
private logoBtn = "#masthead-logo";
private helpBtn = "#help";
private closeAlertMessageBtn = ".pf-c-alert__action button";
private closeLastAlertMessageBtn =
".pf-c-alert-group > li:first-child .pf-c-alert__action button";
private alertMessage = ".pf-c-alert__title";
private userDrpDwn = "#user-dropdown";
private userDrpDwnKebab = "#user-dropdown-kebab";
2022-01-05 09:56:38 +00:00
checkIsAdminConsole() {
cy.get(this.logoBtn).should("exist");
cy.get(this.userDrpDwn).should("exist");
return this;
}
setMobileMode(isMobileMode: boolean) {
if (isMobileMode) {
cy.viewport("iphone-6");
} else {
2021-01-27 12:56:28 +00:00
cy.viewport(1024, 768);
}
}
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)
);
}
signOut() {
this.userDropdown().click();
cy.get("#sign-out").click();
}
accountManagement() {
this.userDropdown().click();
cy.get("#manage-account").click();
}
checkNotificationMessage(message: string, closeNotification = true) {
cy.get(this.alertMessage).should("contain.text", message);
if (closeNotification) {
cy.get(`button[title="` + message.replaceAll('"', '\\"') + `"]`)
.last()
.click({ force: true });
}
return this;
}
2021-05-06 09:06:20 +00:00
closeLastAlertMessage() {
cy.get(this.closeLastAlertMessageBtn).click();
return this;
}
closeAllAlertMessages() {
2022-08-12 10:52:41 +00:00
cy.get(this.closeAlertMessageBtn).each(() => {
cy.get(this.closeAlertMessageBtn).click({ force: true, multiple: true });
});
return this;
}
2021-05-06 09:06:20 +00:00
checkKebabShown() {
cy.get(this.userDrpDwn).should("not.be.visible");
2021-05-06 09:06:20 +00:00
cy.get(this.userDrpDwnKebab).should("exist");
return this;
}
}