keycloak-scim/js/apps/admin-ui/cypress/support/pages/LoginPage.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-01-27 12:56:28 +00:00
export default class LoginPage {
#userNameInput = "#username";
#passwordInput = "#password";
#submitBtn = "#kc-login";
#oldLoadContainer = "#loading";
#loadContainer = "div.keycloak__loading-container";
2021-01-27 12:56:28 +00:00
isLogInPage() {
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");
cy.get(this.#oldLoadContainer).should("not.exist");
cy.get(this.#loadContainer).should("not.exist");
2023-02-10 10:10:35 +00:00
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();
2023-02-10 10:10:35 +00:00
}
});
},
{
validate() {
cy.get('[role="progressbar"]').should("not.exist");
},
},
2023-02-10 10:10:35 +00:00
);
2021-01-27 12:56:28 +00:00
}
}