skillbox/client/cypress/integration/login.spec.js

52 lines
1.7 KiB
JavaScript

const schema = require('../fixtures/schema.json');
const isEmailAvailableUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers/isEmailAvailable';
const checkPasswordUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers';
describe('Login', () => {
beforeEach(() => {
cy.server();
});
it('works with valid email and password', () => {
cy.viewport('macbook-15');
cy.route('POST', isEmailAvailableUrl, "false");
cy.route('POST', checkPasswordUrl, "token12345ABCD+");
cy.visit('/hello');
cy.checkEmailAvailable('feuz@aebi.ch');
cy.get('[data-cy="login-title"]').contains('Bitte geben Sie das passende Passwort ein');
cy.enterPassword('abcd1234');
});
it('displays error message if password is wrong', () => {
cy.viewport('macbook-15');
cy.route('POST', isEmailAvailableUrl, "false");
cy.route({
method: 'POST',
status: 401,
response: {
message: "Sie haben sich nicht korrekt eingeloggt oder Ihr Konto ist vor\u00fcbergehend deaktiviert."
},
url: checkPasswordUrl
});
cy.visit('/hello');
cy.checkEmailAvailable('feuz@aebi.ch');
cy.get('[data-cy="login-title"]').contains('Bitte geben Sie das passende Passwort ein');
cy.enterPassword('abcd1234');
cy.get('[data-cy="password-errors"]').contains('Sie haben sich nicht korrekt eingeloggt oder Ihr Konto ist vorübergehend deaktiviert.');
});
it('displays error message if input is not an email address', () => {
cy.viewport('macbook-15');
cy.visit('/hello');
cy.checkEmailAvailable('feuzaebi.ch');
cy.get('[data-cy="email-local-errors"]').contains('Bitte geben Sie eine gülitge E-Mail an');
})
});