Add login tests
This commit is contained in:
parent
0922c5d198
commit
dd272757bf
|
|
@ -0,0 +1,51 @@
|
|||
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');
|
||||
})
|
||||
});
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
// import 'cypress-graphql-mock';
|
||||
import '@iam4x/cypress-graphql-mock';
|
||||
|
||||
|
||||
Cypress.Commands.add('apolloLogin', (username, password) => {
|
||||
const payload = {
|
||||
'operationName': 'Login',
|
||||
|
|
@ -129,3 +130,14 @@ Cypress.Commands.add('register', (firstname, lastname, email, licenseKey) => {
|
|||
|
||||
cy.get('[data-cy=register-button]').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add("checkEmailAvailable", (email) => {
|
||||
cy.get('[data-cy="email-input"]').type(email);
|
||||
cy.get('[data-cy="hello-button"]').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add("enterPassword", (password) => {
|
||||
cy.get('[data-cy="password-input"]').type(password);
|
||||
cy.get('[data-cy="login-button"]').click();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -7164,7 +7164,7 @@
|
|||
},
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"dev": true
|
||||
},
|
||||
|
|
@ -11569,6 +11569,7 @@
|
|||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
|
|
|||
|
|
@ -23,12 +23,6 @@
|
|||
class="skillboxform-input__error"
|
||||
data-cy="email-local-errors"
|
||||
>{{ errors.first('email') }}</small>
|
||||
<small
|
||||
v-for="error in emailErrors"
|
||||
:key="error"
|
||||
class="skillboxform-input__error"
|
||||
data-cy="email-remote-errors"
|
||||
>{{ error }}</small>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="button button--primary button--big actions__submit" data-cy="hello-button">Los geht's</button>
|
||||
|
|
@ -82,7 +76,6 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
email: '',
|
||||
emailErrors: [],
|
||||
submitted: false
|
||||
};
|
||||
},
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
<script>
|
||||
|
||||
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
||||
import {login} from '../hep-client/index';
|
||||
// import {login} from '../hep-client/index';
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
|
|
@ -74,8 +74,6 @@ export default {
|
|||
// console.log(error)
|
||||
// this.registrationError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals.';
|
||||
// });
|
||||
|
||||
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="login public-page">
|
||||
<header class="info-header">
|
||||
<p class="info-header__text small-emph">Super wir haben für <span class="info-header__emph">{{helloEmail.email}}</span> ein Hep Konto gefunden</p>
|
||||
<h1 class="login__title public-page__title">Bitte geben Sie das passende Passwort ein</h1>
|
||||
<h1 class="login__title public-page__title" data-cy="login-title">Bitte geben Sie das passende Passwort ein</h1>
|
||||
</header>
|
||||
<form class="login__form login-form" novalidate @submit.prevent="validateBeforeSubmit">
|
||||
<div class="change-form__field skillboxform-input">
|
||||
|
|
@ -20,16 +20,11 @@
|
|||
data-cy="password-input"
|
||||
tabindex="0"
|
||||
/>
|
||||
<small
|
||||
v-if="errors.has('password') && submitted"
|
||||
class="skillboxform-input__error"
|
||||
data-cy="password-local-errors"
|
||||
>{{ errors.first('password') }}</small>
|
||||
<small
|
||||
v-for="error in passwordErrors"
|
||||
:key="error"
|
||||
class="skillboxform-input__error"
|
||||
data-cy="password-remote-errors"
|
||||
data-cy="password-errors"
|
||||
>{{ error }}</small>
|
||||
</div>
|
||||
<div class="skillboxform-input">
|
||||
|
|
@ -57,14 +52,16 @@ export default {
|
|||
this.submitted = true;
|
||||
let that = this;
|
||||
if (result) {
|
||||
|
||||
login(this.password)
|
||||
login(this.helloEmail.email, this.password)
|
||||
.then((response) => {
|
||||
console.log(response)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
this.registrationError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals.';
|
||||
if (error.response.data.message && error.response.data.message === 'Sie haben sich nicht korrekt eingeloggt oder Ihr Konto ist vor\u00fcbergehend deaktiviert.') {
|
||||
this.passwordErrors = ['Sie haben sich nicht korrekt eingeloggt oder Ihr Konto ist vorübergehend deaktiviert.'];
|
||||
} else {
|
||||
this.passwordErrors = ['Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.'];
|
||||
}
|
||||
});
|
||||
|
||||
// this.$apollo.mutate({
|
||||
|
|
@ -119,7 +116,6 @@ export default {
|
|||
return {
|
||||
password: '',
|
||||
passwordErrors: [],
|
||||
loginError: '',
|
||||
submitted: false
|
||||
};
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue