From 2f0f6d7db7776d9918ca3ff25ecca319870bf8ca Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 21 Jan 2022 11:36:50 +0100 Subject: [PATCH 1/7] check array and send the correct parameters to the thx page --- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- frontend/src/views/Pages/ResetPassword.vue | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 651944547..d92f42f5d 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -198,7 +198,7 @@ }, "thx": { "activateEmail": "Dein Konto wurde noch nicht aktiviert. Bitte überprüfe deine E-Mail und klicke den Aktivierungslink!", - "checkEmail": "Deine E-Mail wurde erfolgreich verifiziert.", + "checkEmail": "Deine E-Mail wurde erfolgreich verifiziert. Du kannst dich jetzt anmelden.", "email": "Wir haben dir eine E-Mail gesendet.", "emailActivated": "Danke dass Du deine E-Mail bestätigt hast.", "errorTitle": "Achtung!", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index c6cbeed69..014d449a0 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -198,7 +198,7 @@ }, "thx": { "activateEmail": "Your account has not been activated yet, please check your emails and click the activation link!", - "checkEmail": "Your email has been successfully verified.", + "checkEmail": "Your email has been successfully verified. You can sign in now.", "email": "We have sent you an email.", "emailActivated": "Thank you your email has been activated.", "errorTitle": "Attention!", diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 05d8a0f6e..db4e0d6c8 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -92,7 +92,11 @@ export default { }) .then(() => { this.form.password = '' - this.$router.push('/thx/reset') + if (textFields.checkEmail) { + this.$router.push('/thx/checkEmail') + } else { + this.$router.push('/thx/reset') + } }) .catch((error) => { this.$toasted.global.error(error.message) From 40021fb46fdba96825f0bf197d1fe020779a309f Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 21 Jan 2022 13:15:34 +0100 Subject: [PATCH 2/7] check on the checkMail page which url path is attached --- frontend/src/views/Pages/ResetPassword.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index db4e0d6c8..69bc9e533 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -92,9 +92,10 @@ export default { }) .then(() => { this.form.password = '' - if (textFields.checkEmail) { + if (this.$route.path.includes('checkEmail')) { this.$router.push('/thx/checkEmail') - } else { + } + if (this.$route.path.includes('reset')) { this.$router.push('/thx/reset') } }) From 14e51b9f8705dcf4e37b2fca4c5bdbc778a9f75e Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Fri, 21 Jan 2022 19:01:12 +0100 Subject: [PATCH 3/7] Update frontend/src/views/Pages/ResetPassword.vue Co-authored-by: Hannes Heine --- frontend/src/views/Pages/ResetPassword.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 69bc9e533..f0ed0c348 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -94,8 +94,7 @@ export default { this.form.password = '' if (this.$route.path.includes('checkEmail')) { this.$router.push('/thx/checkEmail') - } - if (this.$route.path.includes('reset')) { + } else if (this.$route.path.includes('reset')) { this.$router.push('/thx/reset') } }) From e17d1b34e2a90a3cd801d56f7d2dc86e8b276b09 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 22 Jan 2022 10:09:04 +0100 Subject: [PATCH 4/7] test fixed for checkMail --- frontend/src/views/Pages/ResetPassword.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index e28d16c3e..4c45e7c2e 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -190,7 +190,7 @@ describe('ResetPassword', () => { }) it('redirects to "/thx/reset"', () => { - expect(routerPushMock).toHaveBeenCalledWith('/thx/reset') + expect(routerPushMock).toHaveBeenCalledWith('/thx/checkEmail') }) }) }) From 0bffe9d63ee10372d962d58e5d9966b3b1da063c Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 24 Jan 2022 12:43:04 +0100 Subject: [PATCH 5/7] change text for test checkMail --- frontend/src/views/Pages/ResetPassword.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index 4c45e7c2e..b86d37bc4 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -189,7 +189,7 @@ describe('ResetPassword', () => { ) }) - it('redirects to "/thx/reset"', () => { + it('redirects to "/thx/heckEmail"', () => { expect(routerPushMock).toHaveBeenCalledWith('/thx/checkEmail') }) }) From 65d23548177205f0e85bbddb75f8f80125684db1 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 24 Jan 2022 15:58:36 +0100 Subject: [PATCH 6/7] Update frontend/src/views/Pages/ResetPassword.spec.js Co-authored-by: Moriz Wahl --- frontend/src/views/Pages/ResetPassword.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index b86d37bc4..d6319086c 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -189,7 +189,7 @@ describe('ResetPassword', () => { ) }) - it('redirects to "/thx/heckEmail"', () => { + it('redirects to "/thx/checkEmail"', () => { expect(routerPushMock).toHaveBeenCalledWith('/thx/checkEmail') }) }) From 9df3ca7c01a3a79e7aaf63a971be2f780f7baff0 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 24 Jan 2022 16:42:09 +0100 Subject: [PATCH 7/7] mock path to have differnet include results --- .../src/views/Pages/ResetPassword.spec.js | 126 +++++++++++------- frontend/src/views/Pages/ResetPassword.vue | 2 +- 2 files changed, 81 insertions(+), 47 deletions(-) diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index d6319086c..da8b4bc4f 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -15,54 +15,48 @@ const stubs = { RouterLink: RouterLinkStub, } -const createMockObject = (comingFrom) => { - return { - localVue, - mocks: { - $i18n: { - locale: 'en', - }, - $t: jest.fn((t) => t), - $route: { - params: { - optin: '123', - comingFrom, - }, - path: { - includes: (t) => t, - }, - }, - $toasted: { - global: { - error: toasterMock, - }, - }, - $router: { - push: routerPushMock, - }, - $loading: { - show: jest.fn(() => { - return { hide: jest.fn() } - }), - }, - $apollo: { - mutate: apolloMutationMock, - }, +const mocks = { + $i18n: { + locale: 'en', + }, + $t: jest.fn((t) => t), + $route: { + params: { + optin: '123', }, - stubs, - } + path: { + mock: 'checkEmail', + includes: jest.fn((t) => t === mocks.$route.path.mock), + }, + }, + $toasted: { + global: { + error: toasterMock, + }, + }, + $router: { + push: routerPushMock, + }, + $loading: { + show: jest.fn(() => { + return { hide: jest.fn() } + }), + }, + $apollo: { + mutate: apolloMutationMock, + }, } describe('ResetPassword', () => { let wrapper - const Wrapper = (functionName) => { - return mount(ResetPassword, functionName) + const Wrapper = () => { + return mount(ResetPassword, { localVue, mocks, stubs }) } describe('mount', () => { beforeEach(() => { - wrapper = Wrapper(createMockObject()) + wrapper = Wrapper() }) describe('No valid optin', () => { @@ -86,11 +80,32 @@ describe('ResetPassword', () => { }) describe('Register header', () => { - it('has a welcome message', async () => { - expect(wrapper.find('div.header').text()).toContain('settings.password.reset') - expect(wrapper.find('div.header').text()).toContain( - 'settings.password.reset-password.text', - ) + describe('from reset', () => { + beforeEach(() => { + mocks.$route.path.mock = 'reset' + wrapper = Wrapper() + }) + + it('has a welcome message', async () => { + expect(wrapper.find('div.header').text()).toContain('settings.password.reset') + expect(wrapper.find('div.header').text()).toContain( + 'settings.password.reset-password.text', + ) + }) + }) + + describe('from checkEmail', () => { + beforeEach(() => { + mocks.$route.path.mock = 'checkEmail' + wrapper = Wrapper() + }) + + it('has a welcome message', async () => { + expect(wrapper.find('div.header').text()).toContain('settings.password.set') + expect(wrapper.find('div.header').text()).toContain( + 'settings.password.set-password.text', + ) + }) }) }) @@ -128,7 +143,6 @@ describe('ResetPassword', () => { describe('submit form', () => { beforeEach(async () => { - // wrapper = Wrapper(createMockObject()) await wrapper.findAll('input').at(0).setValue('Aa123456_') await wrapper.findAll('input').at(1).setValue('Aa123456_') await flushPromises() @@ -164,14 +178,14 @@ describe('ResetPassword', () => { }) }) - describe('server response with success', () => { + describe('server response with success on /checkEmail', () => { beforeEach(async () => { + mocks.$route.path.mock = 'checkEmail' apolloMutationMock.mockResolvedValue({ data: { resetPassword: 'success', }, }) - wrapper = Wrapper(createMockObject('checkEmail')) await wrapper.findAll('input').at(0).setValue('Aa123456_') await wrapper.findAll('input').at(1).setValue('Aa123456_') await wrapper.find('form').trigger('submit') @@ -193,6 +207,26 @@ describe('ResetPassword', () => { expect(routerPushMock).toHaveBeenCalledWith('/thx/checkEmail') }) }) + + describe('server response with success on /reset', () => { + beforeEach(async () => { + mocks.$route.path.mock = 'reset' + wrapper = Wrapper() + apolloMutationMock.mockResolvedValue({ + data: { + resetPassword: 'success', + }, + }) + await wrapper.findAll('input').at(0).setValue('Aa123456_') + await wrapper.findAll('input').at(1).setValue('Aa123456_') + await wrapper.find('form').trigger('submit') + await flushPromises() + }) + + it('redirects to "/thx/reset"', () => { + expect(routerPushMock).toHaveBeenCalledWith('/thx/reset') + }) + }) }) }) }) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index f0ed0c348..0023c3838 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -94,7 +94,7 @@ export default { this.form.password = '' if (this.$route.path.includes('checkEmail')) { this.$router.push('/thx/checkEmail') - } else if (this.$route.path.includes('reset')) { + } else { this.$router.push('/thx/reset') } })