2021-02-11 13:58:05 +00:00
|
|
|
// <reference types="cypress" />
|
2020-08-20 13:36:00 +00:00
|
|
|
import { LOGIN_SELECTORS } from "../elements/account/login-selectors";
|
2021-02-11 13:58:05 +00:00
|
|
|
import { urlList } from "../url/urlList";
|
2020-08-20 13:36:00 +00:00
|
|
|
|
2020-07-20 09:42:44 +00:00
|
|
|
describe("User authorization", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData();
|
|
|
|
});
|
|
|
|
|
2020-08-25 10:03:20 +00:00
|
|
|
it("should successfully log in an user", () => {
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.visit(urlList.homePage);
|
2020-08-25 10:03:20 +00:00
|
|
|
cy.loginUser();
|
|
|
|
cy.get(LOGIN_SELECTORS.welcomePage);
|
|
|
|
});
|
2020-07-20 09:42:44 +00:00
|
|
|
|
2020-08-25 10:03:20 +00:00
|
|
|
it("should fail for wrong password", () => {
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.visit(urlList.homePage)
|
2020-08-25 10:03:20 +00:00
|
|
|
.get(LOGIN_SELECTORS.emailAddressInput)
|
|
|
|
.type("admin@example.com")
|
|
|
|
.get(LOGIN_SELECTORS.emailPasswordInput)
|
|
|
|
.type("wrong-password")
|
|
|
|
.get(LOGIN_SELECTORS.signInButton)
|
|
|
|
.click()
|
|
|
|
.get(LOGIN_SELECTORS.warningCredentialMessage);
|
2020-07-20 09:42:44 +00:00
|
|
|
});
|
|
|
|
|
2020-08-25 10:03:20 +00:00
|
|
|
it("should successfully log out an user", () => {
|
|
|
|
cy.window().then(win => {
|
|
|
|
win.sessionStorage.clear();
|
2020-07-20 09:42:44 +00:00
|
|
|
});
|
2021-02-11 13:58:05 +00:00
|
|
|
cy.visit(urlList.homePage);
|
2020-08-25 10:03:20 +00:00
|
|
|
cy.loginUser();
|
|
|
|
cy.get(LOGIN_SELECTORS.userMenu)
|
|
|
|
.click()
|
|
|
|
.get(LOGIN_SELECTORS.accountSettings)
|
|
|
|
.click();
|
|
|
|
cy.location("pathname").should("contains", "/staff/");
|
2020-07-20 09:42:44 +00:00
|
|
|
});
|
|
|
|
});
|