From 4207aee09d095e26600ac816b2a37bafd4b2919c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 8 Jul 2019 18:57:57 +0200 Subject: [PATCH] DRY up password validations --- cypress/integration/common/steps.js | 2 +- webapp/components/Password/Change.spec.js | 14 ++--- webapp/components/Password/Change.vue | 54 +++++-------------- .../PasswordReset/ChangePassword.spec.js | 6 +-- .../PasswordReset/ChangePassword.vue | 52 ++++++------------ .../Registration/CreateUserAccount.spec.js | 4 +- .../Registration/CreateUserAccount.vue | 42 ++++----------- webapp/components/utils/PasswordFormHelper.js | 36 +++++++++++++ 8 files changed, 88 insertions(+), 122 deletions(-) create mode 100644 webapp/components/utils/PasswordFormHelper.js diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index f8d18baa0..61d46b5df 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -278,7 +278,7 @@ When("I fill the password form with:", table => { .type(table["Your old password"]) .get("input[id=newPassword]") .type(table["Your new passsword"]) - .get("input[id=confirmPassword]") + .get("input[id=passwordConfirmation]") .type(table["Confirm new password"]); }); diff --git a/webapp/components/Password/Change.spec.js b/webapp/components/Password/Change.spec.js index a15695a55..ef89c34f7 100644 --- a/webapp/components/Password/Change.spec.js +++ b/webapp/components/Password/Change.spec.js @@ -54,7 +54,7 @@ describe('ChangePassword.vue', () => { describe('match', () => { beforeEach(() => { wrapper.find('input#oldPassword').setValue('some secret') - wrapper.find('input#newPassword').setValue('some secret') + wrapper.find('input#password').setValue('some secret') }) it('invalid', () => { @@ -90,8 +90,8 @@ describe('ChangePassword.vue', () => { describe('given valid input', () => { beforeEach(() => { wrapper.find('input#oldPassword').setValue('supersecret') - wrapper.find('input#newPassword').setValue('superdupersecret') - wrapper.find('input#confirmPassword').setValue('superdupersecret') + wrapper.find('input#password').setValue('superdupersecret') + wrapper.find('input#passwordConfirmation').setValue('superdupersecret') }) describe('submit form', () => { @@ -109,8 +109,8 @@ describe('ChangePassword.vue', () => { expect.objectContaining({ variables: { oldPassword: 'supersecret', - newPassword: 'superdupersecret', - confirmPassword: 'superdupersecret', + password: 'superdupersecret', + passwordConfirmation: 'superdupersecret', }, }), ) @@ -135,8 +135,8 @@ describe('ChangePassword.vue', () => { /* describe('mutation rejects', () => { beforeEach(async () => { await wrapper.find('input#oldPassword').setValue('supersecret') - await wrapper.find('input#newPassword').setValue('supersecret') - await wrapper.find('input#confirmPassword').setValue('supersecret') + await wrapper.find('input#password').setValue('supersecret') + await wrapper.find('input#passwordConfirmation').setValue('supersecret') }) it('displays error message', async () => { diff --git a/webapp/components/Password/Change.vue b/webapp/components/Password/Change.vue index ab9a89cbc..dabc53d6f 100644 --- a/webapp/components/Password/Change.vue +++ b/webapp/components/Password/Change.vue @@ -1,9 +1,5 @@