2021-01-27 12:56:28 +00:00
|
|
|
export default class LoginPage {
|
2023-10-23 18:12:55 +00:00
|
|
|
#userNameInput = "#username";
|
|
|
|
#passwordInput = "#password";
|
|
|
|
#submitBtn = "#kc-login";
|
2021-05-06 08:38:45 +00:00
|
|
|
|
2023-10-23 18:12:55 +00:00
|
|
|
#oldLoadContainer = "#loading";
|
|
|
|
#loadContainer = "div.keycloak__loading-container";
|
2021-01-27 12:56:28 +00:00
|
|
|
|
|
|
|
isLogInPage() {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#userNameInput).should("exist");
|
2021-01-27 12:56:28 +00:00
|
|
|
cy.url().should("include", "/auth");
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
logIn(userName = "admin", password = "admin") {
|
2023-02-10 10:10:35 +00:00
|
|
|
cy.session(
|
|
|
|
[userName, password],
|
|
|
|
() => {
|
|
|
|
cy.visit("/");
|
|
|
|
cy.get('[role="progressbar"]').should("not.exist");
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#oldLoadContainer).should("not.exist");
|
|
|
|
cy.get(this.#loadContainer).should("not.exist");
|
2021-01-28 09:07:12 +00:00
|
|
|
|
2023-02-10 10:10:35 +00:00
|
|
|
cy.get("body")
|
|
|
|
.children()
|
|
|
|
.then((children) => {
|
|
|
|
if (children.length == 1) {
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#userNameInput).type(userName);
|
|
|
|
cy.get(this.#passwordInput).type(password);
|
2021-01-28 09:07:12 +00:00
|
|
|
|
2023-10-23 18:12:55 +00:00
|
|
|
cy.get(this.#submitBtn).click();
|
2023-02-10 10:10:35 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
{
|
|
|
|
validate() {
|
|
|
|
cy.get('[role="progressbar"]').should("not.exist");
|
|
|
|
},
|
2023-07-11 14:03:21 +00:00
|
|
|
},
|
2023-02-10 10:10:35 +00:00
|
|
|
);
|
2021-01-27 12:56:28 +00:00
|
|
|
}
|
|
|
|
}
|