From 04fa6665902e3b3aec3f6838db1551d23f1f7ff5 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 12 Jun 2021 11:36:07 +0200 Subject: [PATCH] fix lint, fix test, change ids --- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- frontend/src/views/Pages/Login.vue | 9 +- frontend/src/views/Pages/Register.spec.js | 25 ++- frontend/src/views/Pages/Register.vue | 240 ++++++++++----------- frontend/src/views/Pages/ResetPassword.vue | 4 +- 6 files changed, 137 insertions(+), 145 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index f47493aea..60015ef98 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -34,7 +34,7 @@ "email":"E-Mail", "email_repeat":"eMail wiederholen", "password":"Passwort", - "password_repeat":"Passwort wiederholen", + "passwordRepeat":"Passwort wiederholen", "password_old":"altes Passwort", "password_new":"neues Passwort", "password_new_repeat":"neues Passwort wiederholen", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index dbb9b445c..5154aacc0 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -34,7 +34,7 @@ "email":"Email", "email_repeat":"Repeat Email", "password":"Password", - "password_repeat":"Repeat password", + "passwordRepeat":"Repeat password", "password_old":"Old password", "password_new":"New password", "password_new_repeat":"Repeat new password", diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue index 23e5741f2..4619dddf2 100755 --- a/frontend/src/views/Pages/Login.vue +++ b/frontend/src/views/Pages/Login.vue @@ -34,7 +34,7 @@ { expect(wrapper.find('form').exists()).toBeTruthy() }) - it('has 3 text input fields', () => { - expect(wrapper.findAll('input[type="text"]').length).toBe(3) + it('has firstname input fields', () => { + expect(wrapper.find('#registerFirstname').exists()).toBeTruthy() + }) + it('has lastname input fields', () => { + expect(wrapper.find('#registerLastname').exists()).toBeTruthy() }) - it('has 2 password input fields', () => { - expect(wrapper.findAll('input[type="password"]').length).toBe(2) + it('has email input fields', () => { + expect(wrapper.find('#registerEmail').exists()).toBeTruthy() + }) + + it('has password input fields', () => { + expect(wrapper.find('#registerPassword').exists()).toBeTruthy() + }) + + it('has password repeat input fields', () => { + expect(wrapper.find('#registerPasswordRepeat').exists()).toBeTruthy() }) it('has 1 checkbox input fields', () => { - expect(wrapper.findAll('input[type="checkbox"]').length).toBe(1) + expect(wrapper.find('#registerCheckbox').exists()).toBeTruthy() }) it('has no submit button when not completely filled', () => { @@ -70,9 +81,9 @@ describe('Register', () => { }) it('shows a warning when no valid Email is entered', async () => { - wrapper.findAll('input[type="text"]').at(2).setValue('no_valid@Email') + wrapper.find('#registerEmail').setValue('no_valid@Email') await flushPromises() - await expect(wrapper.find('.invalid-feedback').text()).toEqual( + await expect(wrapper.find('#registerEmailLiveFeedback').text()).toEqual( 'The Email field must be a valid email', ) }) diff --git a/frontend/src/views/Pages/Register.vue b/frontend/src/views/Pages/Register.vue index f427c5a8c..7f475ebae 100755 --- a/frontend/src/views/Pages/Register.vue +++ b/frontend/src/views/Pages/Register.vue @@ -23,107 +23,101 @@
{{ $t('signup') }}
- - - - - + + - - + - + {{ validationContext.errors[0] }} - - - - - + - - + - - {{ validationContext.errors[0] }} - - - - - - - - - - - - + {{ validationContext.errors[0] }} - + + + + + + + {{ validationContext.errors[0] }} + + + +
- - - @@ -132,37 +126,34 @@ - + {{ validationContext.errors[0] }} - - - + + + + + + + + + + + - - - - - - - - -
    @@ -180,18 +171,13 @@ - - - - - - - + + + - - - -
    - {{ $t('form.reset') }} - {{ $t('signup') }} -
    - +
    + {{ $t('form.reset') }} + {{ $t('signup') }} +
@@ -247,15 +229,15 @@ export default { name: 'register', data() { return { - model: { + form: { firstname: '', lastname: '', email: '', agree: false, + password: '', + passwordRepeat: '', }, - password: '', - passwordRepeat: '', passwordVisible: false, passwordVisibleRepeat: false, submitted: false, @@ -268,14 +250,13 @@ export default { return dirty || validated ? valid : null }, resetForm() { - this.model = { + this.form = { firstname: '', lastname: '', email: '', - } - this.password= '', - this.passwordRepeat= '', - + password: '', + passwordRepeat: '', + } this.$nextTick(() => { this.$refs.observer.reset() }) @@ -288,20 +269,21 @@ export default { }, async onSubmit() { const result = await loginAPI.create( - this.model.email, - this.model.firstname, - this.model.lastname, - this.password, + this.form.email, + this.form.firstname, + this.form.lastname, + this.form.password, ) if (result.success) { this.$store.dispatch('login', { sessionId: result.result.data.session_id, - email: this.model.email, + email: this.form.email, }) - this.model.email = '' - this.model.firstname = '' - this.model.lastname = '' + this.form.email = '' + this.form.firstname = '' + this.form.lastname = '' this.password = '' + this.passwordVisibleRepeat = '' this.$router.push('/thx/register') } else { this.showError = true @@ -311,29 +293,29 @@ export default { closeAlert() { this.showError = false this.messageError = '' - this.model.email = '' - this.model.firstname = '' - this.model.lastname = '' - this.password = '' + this.form.email = '' + this.form.firstname = '' + this.form.lastname = '' + this.form.password = '' }, }, computed: { samePasswords() { - return this.password === this.passwordRepeat + return this.form.password === this.form.passwordRepeat }, passwordsFilled() { - return this.password !== '' && this.passwordRepeat !== '' + return this.form.password !== '' && this.form.passwordRepeat !== '' }, namesFilled() { return ( - this.model.firstname !== '' && - this.model.firstname.length > 2 && - this.model.lastname !== '' && - this.model.lastname.length > 1 + this.form.firstname !== '' && + this.form.firstname.length > 2 && + this.form.lastname !== '' && + this.form.lastname.length > 1 ) }, emailFilled() { - return this.model.email !== '' + return this.form.email !== '' }, rules() { return [ @@ -346,7 +328,7 @@ export default { passwordValidation() { const errors = [] for (const condition of this.rules) { - if (!condition.regex.test(this.password)) { + if (!condition.regex.test(this.form.password)) { errors.push(condition.message) } } diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 99892612c..e8982b170 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -43,10 +43,10 @@