Add confirmation field

This commit is contained in:
Christian Cueni 2020-05-19 09:35:45 +02:00
parent 1e944f3c1b
commit 012ff7c604
5 changed files with 49 additions and 4 deletions

View File

@ -144,6 +144,18 @@ describe('Registration', () => {
cy.get('[data-cy="passwordConfirmation-local-errors"]').contains('Die Bestätigung von Passwort wiederholen stimmt nicht überein'); cy.get('[data-cy="passwordConfirmation-local-errors"]').contains('Die Bestätigung von Passwort wiederholen stimmt nicht überein');
}); });
it('displays error if terms are not accepted', () => {
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, 'Weg 1', 'Bern', '3001', 'Abcd1234!', 'Abcd1234!', false);
cy.get('[data-cy="acceptedTerms-local-errors"]').contains('Die AGBs und die Datenschutzbestimmungen müssen akzeptiert werden');
});
it('redirects to hello if email is missing', () => { it('redirects to hello if email is missing', () => {
cy.visit('/register'); cy.visit('/register');
cy.get('[data-cy="hello-title"]').contains('Wollen sie mySkillbox jetzt im Unterricht verwenden?'); cy.get('[data-cy="hello-title"]').contains('Wollen sie mySkillbox jetzt im Unterricht verwenden?');

View File

@ -121,7 +121,7 @@ Cypress.Commands.add('enterPassword', (password) => {
cy.get('[data-cy="login-button"]').click(); cy.get('[data-cy="login-button"]').click();
}); });
Cypress.Commands.add('register', (prefix, firstname, lastname, street, city, postcode, password, passwordConfirmation) => { Cypress.Commands.add('register', (prefix, firstname, lastname, street, city, postcode, password, passwordConfirmation, acceptTerms=true) => {
let selection = prefix === 1 ? 'Herr' : 'Frau'; let selection = prefix === 1 ? 'Herr' : 'Frau';
@ -150,6 +150,10 @@ Cypress.Commands.add('register', (prefix, firstname, lastname, street, city, pos
cy.get('[data-cy="password-input"]').type(password); cy.get('[data-cy="password-input"]').type(password);
} }
if (acceptTerms) {
cy.get('[data-cy="acceptedTerms-input"]').click();
}
cy.get('[data-cy="passwordConfirmation-input"]').type(passwordConfirmation); cy.get('[data-cy="passwordConfirmation-input"]').type(passwordConfirmation);
cy.get('[data-cy="register-button"]').click(); cy.get('[data-cy="register-button"]').click();
}); });

View File

@ -5,7 +5,9 @@
:item="item" :item="item"
:type="'checkbox'" :type="'checkbox'"
@input="passOn" @input="passOn"
/> >
<slot></slot>
</base-input>
</template> </template>
<script> <script>

View File

@ -12,7 +12,9 @@
<tick v-if="type === 'checkbox'"/> <tick v-if="type === 'checkbox'"/>
<circle-icon v-if="type === 'radiobutton'"/> <circle-icon v-if="type === 'radiobutton'"/>
</span> </span>
<span class="base-input-container__label">{{ label }}</span> <span v-if="label" class="base-input-container__label">{{ label }}</span>
<slot v-if="!label" class="base-input-container__label">
</slot>
</label> </label>
</template> </template>

View File

@ -216,6 +216,26 @@
v-if="errors.has('passwordConfirmation') && submitted" v-if="errors.has('passwordConfirmation') && submitted"
>{{ errors.first('passwordConfirmation') }}</small> >{{ errors.first('passwordConfirmation') }}</small>
</div> </div>
<div class="change-form__field skillboxform-input">
<checkbox
id="acceptedTerms"
name="acceptedTerms"
v-model="acceptedTerms"
class="skillboxform-input__checkbox"
:checked="acceptedTerms"
v-validate="'required:true'"
:class="{ 'skillboxform-input__input--error': errors.has('acceptedTerms') && submitted}"
data-cy="acceptedTerms-input"
>
<span>Hiermit akzeptiere ich die <a href="https://www.hep-verlag.ch/agb" target="_blank" class="hep-link">AGB</a> und
<a href="https://www.hep-verlag.ch/datenschutz" target="_blank" class="hep-link">Datenschutzbestimmungen</a></span>
</checkbox>
<small
v-if="errors.has('acceptedTerms') && submitted"
class="skillboxform-input__error"
data-cy="acceptedTerms-local-errors"
>Die AGBs und die Datenschutzbestimmungen müssen akzeptiert werden</small>
</div>
<div class="skillboxform-input"> <div class="skillboxform-input">
<small <small
class="skillboxform-input__error" class="skillboxform-input__error"
@ -236,6 +256,7 @@
import {register} from '../hep-client/index' import {register} from '../hep-client/index'
import HELLO_EMAIL from '@/graphql/gql/local/helloEmail.gql'; import HELLO_EMAIL from '@/graphql/gql/local/helloEmail.gql';
import Checkbox from '@/components/Checkbox';
function initialData() { function initialData() {
return { return {
@ -247,6 +268,7 @@ function initialData() {
street: '', street: '',
postcode: '', postcode: '',
city: '', city: '',
acceptedTerms: false,
firstnameErrors: '', firstnameErrors: '',
lastnameErrors: '', lastnameErrors: '',
emailErrors: '', emailErrors: '',
@ -256,12 +278,15 @@ function initialData() {
cityErrors: [], cityErrors: [],
postcodeErrors: [], postcodeErrors: [],
registrationError: '', registrationError: '',
acceptedTermsError: [],
submitted: false, submitted: false,
} }
} }
export default { export default {
components: {}, components: {
Checkbox
},
data() { data() {
return Object.assign( return Object.assign(