2020-08-20 13:36:00 +00:00
|
|
|
import { LOGIN_SELECTORS } from "../elements/account/login-selectors";
|
|
|
|
|
2020-07-20 09:42:44 +00:00
|
|
|
// <reference types="cypress" />
|
|
|
|
describe("User authorization", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Login", () => {
|
|
|
|
it("should successfully log in an user", () => {
|
|
|
|
cy.visit("/");
|
2020-08-20 13:36:00 +00:00
|
|
|
cy.loginUser();
|
|
|
|
cy.get(LOGIN_SELECTORS.welcomePage);
|
2020-07-20 09:42:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should fail for wrong password", () => {
|
2020-08-20 13:36:00 +00:00
|
|
|
cy.visit("/")
|
|
|
|
.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
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Logout", () => {
|
|
|
|
it("should successfully log out an user", () => {
|
|
|
|
cy.window().then(win => {
|
|
|
|
win.sessionStorage.clear();
|
|
|
|
});
|
|
|
|
cy.visit("/");
|
2020-08-20 13:36:00 +00:00
|
|
|
cy.loginUser();
|
2020-07-20 09:42:44 +00:00
|
|
|
cy.get("[data-test=userMenu]")
|
|
|
|
.click()
|
|
|
|
.get("[data-test=accountSettingsButton]")
|
|
|
|
.click();
|
|
|
|
cy.location("pathname").should("contains", "/staff/");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|