From de9ed55738f31442f81f19cbe9aa90c20c2947d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 17 Jun 2019 14:29:24 +0200 Subject: [PATCH] Display nice success message on password reset --- webapp/locales/de.json | 2 +- webapp/locales/en.json | 2 +- webapp/pages/password-reset.spec.js | 18 ++++++++--- webapp/pages/password-reset.vue | 49 +++++++++++++++++++++-------- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 7497648e1..88afa07e0 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -19,7 +19,7 @@ "form": { "description": "Eine Mail zum Zurücksetzen des Passworts wird an die angegebene E-Mail Adresse geschickt.", "submit": "Email anfordern", - "submitted": "Eine E-Mail zum Zurücksetzen wurde angefordert" + "submitted": "E-Mail verschickt an {email}" } }, "editor": { diff --git a/webapp/locales/en.json b/webapp/locales/en.json index fd7968428..53ad9fb40 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -19,7 +19,7 @@ "form": { "description": "A password reset email will be sent to the given email address.", "submit": "Request email", - "submitted": "Reset email was requested" + "submitted": "Email sent to {email}" } }, "editor": { diff --git a/webapp/pages/password-reset.spec.js b/webapp/pages/password-reset.spec.js index bba001614..e78ace4ba 100644 --- a/webapp/pages/password-reset.spec.js +++ b/webapp/pages/password-reset.spec.js @@ -20,7 +20,7 @@ describe('ProfileSlug', () => { $t: jest.fn(), $apollo: { loading: false, - mutate: jest.fn().mockResolvedValue(), + mutate: jest.fn().mockResolvedValue({ data: { reqestPasswordReset: true } }), }, } }) @@ -49,9 +49,19 @@ describe('ProfileSlug', () => { expect(mocks.$apollo.mutate).toHaveBeenCalled() }) - it.todo('delivers email to backend') - it.todo('disables form to avoid re-submission') - it.todo('displays a message that a password email was requested') + it('delivers email to backend', () => { + const expected = expect.objectContaining({ variables: { email: 'mail@example.org' } }) + expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) + }) + + it('hides form to avoid re-submission', () => { + expect(wrapper.find('form').exists()).not.toBeTruthy() + }) + + it('displays a message that a password email was requested', () => { + const expected = ['password-reset.form.submitted', { email: 'mail@example.org' }] + expect(mocks.$t).toHaveBeenCalledWith(...expected) + }) }) describe('given password reset token as URL param', () => { diff --git a/webapp/pages/password-reset.vue b/webapp/pages/password-reset.vue index 0ad9b7997..9e7d2d195 100644 --- a/webapp/pages/password-reset.vue +++ b/webapp/pages/password-reset.vue @@ -6,11 +6,13 @@ + @submit="handleSubmit" + > + :loading="$apollo.loading" + primary + fullwidth + name="submit" + type="submit" + icon="envelope" + > {{ $t('password-reset.form.submit') }} +
+ + + + + + +
@@ -40,33 +56,43 @@