fefe2f57ae
Uses JavaScript [private class features](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields) over TypeScript's `private` keyword. Also introduces some ESLint configuration to enforce this rule throughout the project.
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
export default class LoginPage {
|
|
#userNameInput = "#username";
|
|
#passwordInput = "#password";
|
|
#submitBtn = "#kc-login";
|
|
|
|
#oldLoadContainer = "#loading";
|
|
#loadContainer = "div.keycloak__loading-container";
|
|
|
|
isLogInPage() {
|
|
cy.get(this.#userNameInput).should("exist");
|
|
cy.url().should("include", "/auth");
|
|
|
|
return this;
|
|
}
|
|
|
|
logIn(userName = "admin", password = "admin") {
|
|
cy.session(
|
|
[userName, password],
|
|
() => {
|
|
cy.visit("/");
|
|
cy.get('[role="progressbar"]').should("not.exist");
|
|
cy.get(this.#oldLoadContainer).should("not.exist");
|
|
cy.get(this.#loadContainer).should("not.exist");
|
|
|
|
cy.get("body")
|
|
.children()
|
|
.then((children) => {
|
|
if (children.length == 1) {
|
|
cy.get(this.#userNameInput).type(userName);
|
|
cy.get(this.#passwordInput).type(password);
|
|
|
|
cy.get(this.#submitBtn).click();
|
|
}
|
|
});
|
|
},
|
|
{
|
|
validate() {
|
|
cy.get('[role="progressbar"]').should("not.exist");
|
|
},
|
|
},
|
|
);
|
|
}
|
|
}
|