saleor-dashboard/cypress/integration/login_form.js
M.Graczyk ef967eb5e4
Refactor of login tests (#630)
* WIP refactor of login tests

* Xit not woriking tests, fixed rest of them

* Properly pass env vars to cypress

* Remove unused code

Co-authored-by: Krzysztof Wolski <krzysztof.k.wolski@gmail.com>
2020-08-20 15:36:00 +02:00

42 lines
1.1 KiB
JavaScript

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