Add registration tests
This commit is contained in:
parent
dd272757bf
commit
6509b31ab5
|
|
@ -1,77 +0,0 @@
|
||||||
describe('The Regstration Page', () => {
|
|
||||||
// works locally, but not in pipelines.
|
|
||||||
// it('register user', () => {
|
|
||||||
|
|
||||||
// let timestamp = Math.round((new Date()).getTime() / 1000);
|
|
||||||
|
|
||||||
// const firstname = 'pesche';
|
|
||||||
// const lastname = 'peschemann';
|
|
||||||
// const email = `skillboxtest${timestamp}@iterativ.ch`;
|
|
||||||
// const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
|
||||||
|
|
||||||
// cy.visit('/register');
|
|
||||||
// cy.register(firstname, lastname, email, licenseKey);
|
|
||||||
// cy.get('.reset__heading').contains('Schauen Sie in Ihr Postfach');
|
|
||||||
// });
|
|
||||||
|
|
||||||
it('user sees error message if firstname is omitted', () => {
|
|
||||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
|
||||||
const firstname = '';
|
|
||||||
const lastname = 'peschemann';
|
|
||||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
|
||||||
const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
|
||||||
|
|
||||||
cy.visit('/register');
|
|
||||||
cy.register(firstname, lastname, email, licenseKey);
|
|
||||||
cy.get('[data-cy="firstname-local-errors"]').contains('Vorname ist ein Pflichtfeld.');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('user sees error message if lastname is omitted', () => {
|
|
||||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
|
||||||
const firstname = 'pesche';
|
|
||||||
const lastname = '';
|
|
||||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
|
||||||
const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
|
||||||
|
|
||||||
cy.visit('/register');
|
|
||||||
cy.register(firstname, lastname, email, licenseKey);
|
|
||||||
cy.get('[data-cy="lastname-local-errors"]').contains('Nachname ist ein Pflichtfeld.');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('user sees error message if email is omitted', () => {
|
|
||||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
|
||||||
const firstname = 'pesche';
|
|
||||||
const lastname = 'peschemann';
|
|
||||||
const email = ``;
|
|
||||||
const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
|
||||||
|
|
||||||
cy.visit('/register');
|
|
||||||
cy.register(firstname, lastname, email, licenseKey);
|
|
||||||
cy.get('[data-cy="email-local-errors"]').contains('E-Mail ist ein Pflichtfeld.');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('user sees error message if license is omitted', () => {
|
|
||||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
|
||||||
const firstname = 'pesche';
|
|
||||||
const lastname = 'peschemann';
|
|
||||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
|
||||||
const licenseKey = '';
|
|
||||||
|
|
||||||
cy.visit('/register');
|
|
||||||
cy.register(firstname, lastname, email, licenseKey);
|
|
||||||
cy.get('[data-cy="licenseKey-local-errors"]').contains('Lizenz ist ein Pflichtfeld.');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('user sees error message if license key is wrong', () => {
|
|
||||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
|
||||||
const firstname = 'pesche';
|
|
||||||
const lastname = 'peschemann';
|
|
||||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
|
||||||
const licenseKey = 'asdsafsadfsadfasdf';
|
|
||||||
|
|
||||||
cy.visit('/register');
|
|
||||||
cy.register(firstname, lastname, email, licenseKey);
|
|
||||||
cy.get('[data-cy="licenseKey-remote-errors"]').contains('Die angegebenen Lizenz ist unglültig');
|
|
||||||
});
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
const schema = require('../fixtures/schema.json');
|
||||||
|
|
||||||
|
const isEmailAvailableUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers/isEmailAvailable';
|
||||||
|
const registerUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers';
|
||||||
|
|
||||||
|
let registrationResponse = {
|
||||||
|
id: 84215,
|
||||||
|
group_id: 1,
|
||||||
|
confirmation: "91cf39007547feae7e33778d89fc71db",
|
||||||
|
created_at: "2020-02-06 13:56:54",
|
||||||
|
updated_at: "2020-02-06 13:56:54",
|
||||||
|
created_in: "hep verlag",
|
||||||
|
email: "feuz@aebi.ch",
|
||||||
|
firstname: "Kari",
|
||||||
|
lastname: "Feuz",
|
||||||
|
prefix: "Herr",
|
||||||
|
gender: 1,
|
||||||
|
store_id: 1,
|
||||||
|
website_id: 1,
|
||||||
|
addresses: []
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Registration', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.viewport('macbook-15');
|
||||||
|
cy.server();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('works with valid data', () => {
|
||||||
|
cy.route('POST', isEmailAvailableUrl, "true");
|
||||||
|
cy.route('POST', registerUrl, registrationResponse);
|
||||||
|
|
||||||
|
cy.visit('/hello');
|
||||||
|
cy.checkEmailAvailable(registrationResponse.email);
|
||||||
|
|
||||||
|
cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.');
|
||||||
|
cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Abcd1234!', 'Abcd1234!');
|
||||||
|
cy.get('[data-cy="email-check"]').contains('Ein Email ist auf dem Weg, bitte überprüfen sie ihre E-mail Konto.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays error if firstname is missing', () => {
|
||||||
|
cy.route('POST', isEmailAvailableUrl, "true");
|
||||||
|
cy.route('POST', registerUrl, registrationResponse);
|
||||||
|
|
||||||
|
cy.visit('/hello');
|
||||||
|
cy.checkEmailAvailable(registrationResponse.email);
|
||||||
|
|
||||||
|
cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.');
|
||||||
|
cy.register(registrationResponse.gender, '', registrationResponse.lastname, 'Abcd1234!', 'Abcd1234!');
|
||||||
|
cy.get('[data-cy="firstname-local-errors"]').contains('Vorname ist ein Pflichtfeld');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays error if lastname is missing', () => {
|
||||||
|
cy.route('POST', isEmailAvailableUrl, "true");
|
||||||
|
cy.route('POST', registerUrl, registrationResponse);
|
||||||
|
|
||||||
|
cy.visit('/hello');
|
||||||
|
cy.checkEmailAvailable(registrationResponse.email);
|
||||||
|
|
||||||
|
cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.');
|
||||||
|
cy.register(registrationResponse.gender, registrationResponse.firstname, '', 'Abcd1234!', 'Abcd1234!');
|
||||||
|
cy.get('[data-cy="lastname-local-errors"]').contains('Nachname ist ein Pflichtfeld');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays error if password is missing', () => {
|
||||||
|
cy.route('POST', isEmailAvailableUrl, "true");
|
||||||
|
cy.route('POST', registerUrl, registrationResponse);
|
||||||
|
|
||||||
|
cy.visit('/hello');
|
||||||
|
cy.checkEmailAvailable(registrationResponse.email);
|
||||||
|
|
||||||
|
cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.');
|
||||||
|
cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, '', 'Abcd1234!');
|
||||||
|
cy.get('[data-cy="password-local-errors"]').contains('Passwort ist ein Pflichtfeld');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays error if passwords are not secure', () => {
|
||||||
|
cy.route('POST', isEmailAvailableUrl, "true");
|
||||||
|
cy.route('POST', registerUrl, registrationResponse);
|
||||||
|
|
||||||
|
cy.visit('/hello');
|
||||||
|
cy.checkEmailAvailable(registrationResponse.email);
|
||||||
|
|
||||||
|
cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.');
|
||||||
|
cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Abcd1234', 'Abcd1234');
|
||||||
|
cy.get('[data-cy="password-local-errors"]').contains('Das Passwort muss Grossbuchstaben, Zahlen und Sonderzeichen beinhalten und mindestens 8 Zeichen lang sein');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays error if passwords are too short', () => {
|
||||||
|
cy.route('POST', isEmailAvailableUrl, "true");
|
||||||
|
cy.route('POST', registerUrl, registrationResponse);
|
||||||
|
|
||||||
|
cy.visit('/hello');
|
||||||
|
cy.checkEmailAvailable(registrationResponse.email);
|
||||||
|
|
||||||
|
cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.');
|
||||||
|
cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Abcd12!', 'Abcd12!');
|
||||||
|
cy.get('[data-cy="password-local-errors"]').contains('Das Passwort muss Grossbuchstaben, Zahlen und Sonderzeichen beinhalten und mindestens 8 Zeichen lang sein');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays error if passwords are not matching', () => {
|
||||||
|
cy.route('POST', isEmailAvailableUrl, "true");
|
||||||
|
cy.route('POST', registerUrl, registrationResponse);
|
||||||
|
|
||||||
|
cy.visit('/hello');
|
||||||
|
cy.checkEmailAvailable(registrationResponse.email);
|
||||||
|
|
||||||
|
cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.');
|
||||||
|
cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Abcd1234!', 'Abcd129999!');
|
||||||
|
cy.get('[data-cy="passwordConfirmation-local-errors"]').contains('Die Bestätigung von Passwort wiederholen stimmt nicht überein');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('redirects to hello if email is missing', () => {
|
||||||
|
cy.visit('/register');
|
||||||
|
cy.get('[data-cy="hello-title"]').contains('Wollen sie mySkillbox jetzt im Unterricht verwenden?');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -131,13 +131,31 @@ Cypress.Commands.add('register', (firstname, lastname, email, licenseKey) => {
|
||||||
cy.get('[data-cy=register-button]').click();
|
cy.get('[data-cy=register-button]').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("checkEmailAvailable", (email) => {
|
Cypress.Commands.add('checkEmailAvailable', (email) => {
|
||||||
cy.get('[data-cy="email-input"]').type(email);
|
cy.get('[data-cy="email-input"]').type(email);
|
||||||
cy.get('[data-cy="hello-button"]').click();
|
cy.get('[data-cy="hello-button"]').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("enterPassword", (password) => {
|
Cypress.Commands.add('enterPassword', (password) => {
|
||||||
cy.get('[data-cy="password-input"]').type(password);
|
cy.get('[data-cy="password-input"]').type(password);
|
||||||
cy.get('[data-cy="login-button"]').click();
|
cy.get('[data-cy="login-button"]').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('register', (prefix, firstname, lastname, password, passwordConfirmation) => {
|
||||||
|
cy.get('[data-cy="prefix-selection"]').type(prefix);
|
||||||
|
|
||||||
|
if (firstname !== '') {
|
||||||
|
cy.get('[data-cy="firstname-input"]').type(firstname);
|
||||||
|
}
|
||||||
|
if (lastname !== '') {
|
||||||
|
cy.get('[data-cy="lastname-input"]').type(lastname);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password !== '') {
|
||||||
|
cy.get('[data-cy="password-input"]').type(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.get('[data-cy="passwordConfirmation-input"]').type(passwordConfirmation);
|
||||||
|
cy.get('[data-cy="register-button"]').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ Validator.localize('de', dict)
|
||||||
|
|
||||||
// https://github.com/baianat/vee-validate/issues/51
|
// https://github.com/baianat/vee-validate/issues/51
|
||||||
Validator.extend('strongPassword', {
|
Validator.extend('strongPassword', {
|
||||||
getMessage: field => 'Das Passwort muss Grossbuchstaben, Zahlen und Sonderzeichen beinhalten',
|
getMessage: field => 'Das Passwort muss Grossbuchstaben, Zahlen und Sonderzeichen beinhalten und mindestens 8 Zeichen lang sein',
|
||||||
validate: value => {
|
validate: value => {
|
||||||
const strongRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*?(),.":{}|<>+])(?=.{8,})/;
|
const strongRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*?(),.":{}|<>+])(?=.{8,})/;
|
||||||
return strongRegex.test(value);
|
return strongRegex.test(value);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="check-email">
|
<div class="check-email">
|
||||||
<main class="check-email__content">
|
<main class="check-email__content" data-cy="email-check">
|
||||||
Ein Email ist auf dem Weg, bitte überprüfen sie ihre E-mail Konto.
|
Ein Email ist auf dem Weg, bitte überprüfen sie ihre E-mail Konto.
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="hello public-page">
|
<div class="hello public-page">
|
||||||
<h1 class="hello__title public-page__title">Wollen sie mySkillbox jetzt im Unterricht verwenden?</h1>
|
<h1 class="hello__title public-page__title" data-cy="hello-title">Wollen sie mySkillbox jetzt im Unterricht verwenden?</h1>
|
||||||
<form class="hello__form hello-form" novalidate @submit.prevent="validateBeforeSubmit">
|
<form class="hello__form hello-form" novalidate @submit.prevent="validateBeforeSubmit">
|
||||||
<div class="hello-form__field skillboxform-input">
|
<div class="hello-form__field skillboxform-input">
|
||||||
<label for="email" class="skillboxform-input__label">E-Mail</label>
|
<label for="email" class="skillboxform-input__label">E-Mail</label>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="registration public-page">
|
<div class="registration public-page">
|
||||||
<header class="info-header">
|
<header class="info-header">
|
||||||
<p class="info-header__text small-emph">Für <span class="info-header__emph">{{helloEmail.email}}</span> haben wir kein Hep Konto gefunden.</p>
|
<p class="info-header__text small-emph">Für <span class="info-header__emph">{{helloEmail.email}}</span> haben wir kein Hep Konto gefunden.</p>
|
||||||
<h1 class="registration__title public-page__title">Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.</h1>
|
<h1 class="registration__title public-page__title" data-cy="registration-title">Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.</h1>
|
||||||
</header>
|
</header>
|
||||||
<form class="registration__form registration-form" novalidate @submit.prevent="validateBeforeSubmit">
|
<form class="registration__form registration-form" novalidate @submit.prevent="validateBeforeSubmit">
|
||||||
<div class="registration-form__field skillboxform-input">
|
<div class="registration-form__field skillboxform-input">
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
:class="{ 'skillboxform-input__input--error': errors.has('prefix') }"
|
:class="{ 'skillboxform-input__input--error': errors.has('prefix') }"
|
||||||
class="change-form__prefix skillbox-input skillboxform-input__input skillbox-dropdown"
|
class="change-form__prefix skillbox-input skillboxform-input__input skillbox-dropdown"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
data-cy="prefix-input"
|
data-cy="prefix-selection"
|
||||||
>
|
>
|
||||||
<option>Herr</option>
|
<option value="Herr" selected>Herr</option>
|
||||||
<option>Frau</option>
|
<option value="Frau">Frau</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<label for="firstname" class="skillboxform-input__label">Vorname</label>
|
<label for="firstname" class="skillboxform-input__label">Vorname</label>
|
||||||
|
|
@ -74,32 +74,6 @@
|
||||||
data-cy="lastname-remote-errors"
|
data-cy="lastname-remote-errors"
|
||||||
>{{ error }}</small>
|
>{{ error }}</small>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="change-form__field skillboxform-input">
|
|
||||||
<label for="email" class="skillboxform-input__label">E-Mail</label>
|
|
||||||
<input
|
|
||||||
id="email"
|
|
||||||
name="email"
|
|
||||||
type="email"
|
|
||||||
v-model="email"
|
|
||||||
data-vv-as="E-Mail"
|
|
||||||
v-validate="'required|email'"
|
|
||||||
:class="{ 'skillboxform-input__input--error': errors.has('email') }"
|
|
||||||
class="change-form__new skillbox-input skillboxform-input__input"
|
|
||||||
autocomplete="off"
|
|
||||||
data-cy="email-input"
|
|
||||||
/>
|
|
||||||
<small
|
|
||||||
v-if="errors.has('email') && submitted"
|
|
||||||
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="change-form__field skillboxform-input">
|
<div class="change-form__field skillboxform-input">
|
||||||
<label for="password" class="skillboxform-input__label">Passwort</label>
|
<label for="password" class="skillboxform-input__label">Passwort</label>
|
||||||
<input
|
<input
|
||||||
|
|
@ -120,12 +94,6 @@
|
||||||
class="skillboxform-input__error"
|
class="skillboxform-input__error"
|
||||||
data-cy="password-local-errors"
|
data-cy="password-local-errors"
|
||||||
>{{ errors.first('password') }}</small>
|
>{{ errors.first('password') }}</small>
|
||||||
<small
|
|
||||||
v-for="error in passwordErrors"
|
|
||||||
:key="error"
|
|
||||||
class="skillboxform-input__error"
|
|
||||||
data-cy="password-remote-errors"
|
|
||||||
>{{ error }}</small>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="change-form__field skillboxform-input">
|
<div class="change-form__field skillboxform-input">
|
||||||
<label for="password2" class="skillboxform-input__label">Passwort wiederholen</label>
|
<label for="password2" class="skillboxform-input__label">Passwort wiederholen</label>
|
||||||
|
|
@ -144,14 +112,8 @@
|
||||||
<small
|
<small
|
||||||
v-if="errors.has('passwordConfirmation') && submitted"
|
v-if="errors.has('passwordConfirmation') && submitted"
|
||||||
class="skillboxform-input__error"
|
class="skillboxform-input__error"
|
||||||
data-cy="password-local-errors"
|
data-cy="passwordConfirmation-local-errors"
|
||||||
>{{ errors.first('passwordConfirmation') }}</small>
|
>{{ errors.first('passwordConfirmation') }}</small>
|
||||||
<small
|
|
||||||
v-for="error in passwordErrors"
|
|
||||||
:key="error"
|
|
||||||
class="skillboxform-input__error"
|
|
||||||
data-cy="password-remote-errors"
|
|
||||||
>{{ error }}</small>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="skillboxform-input">
|
<div class="skillboxform-input">
|
||||||
<small class="skillboxform-input__error" data-cy="registration-error" v-if="registrationError">{{registrationError}}</small>
|
<small class="skillboxform-input__error" data-cy="registration-error" v-if="registrationError">{{registrationError}}</small>
|
||||||
|
|
@ -205,7 +167,7 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.prefix = '';
|
this.prefix = 'Herr';
|
||||||
this.lastname = '';
|
this.lastname = '';
|
||||||
this.firstname = '';
|
this.firstname = '';
|
||||||
this.password = '';
|
this.password = '';
|
||||||
|
|
@ -223,7 +185,7 @@ export default {
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
prefix: '',
|
prefix: 'Herr',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
firstname: '',
|
firstname: '',
|
||||||
password: '',
|
password: '',
|
||||||
|
|
@ -240,7 +202,12 @@ export default {
|
||||||
|
|
||||||
apollo: {
|
apollo: {
|
||||||
helloEmail: {
|
helloEmail: {
|
||||||
query: HELLO_EMAIL
|
query: HELLO_EMAIL,
|
||||||
|
result({data: {helloEmail}}) {
|
||||||
|
if (helloEmail.email === '') {
|
||||||
|
this.$router.push({name: 'hello'});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue