diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 822dfeb24..4aec1dfd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -206,7 +206,7 @@ jobs: report_name: Coverage Frontend type: lcov result_path: ./coverage/lcov.info - min_coverage: 35 + min_coverage: 37 token: ${{ github.token }} ############################################################################## diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 7d42be813..3904cd7f7 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -141,6 +141,7 @@ }, "reset-password": { "title": "Passwort zurücksetzen", - "text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünftig in der Gradido-App anmelden kannst." + "text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünftig in der Gradido-App anmelden kannst.", + "not-authenticated": "Leider konnten wir dich nicht authentifizieren. Bitte wende dich an den Support." } } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index ce4199711..95016d810 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -142,6 +142,7 @@ }, "reset-password": { "title": "Reset Password", - "text": "Now you can save a new password to login to the Gradido-App in the future." + "text": "Now you can save a new password to login to the Gradido-App in the future.", + "not-authenticated": "Unfortunately we could not authenticate you. Please contact the support." } } diff --git a/frontend/src/main.js b/frontend/src/main.js index 731fc896a..0e6fd0ef2 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -2,8 +2,7 @@ import Vue from 'vue' import DashboardPlugin from './plugins/dashboard-plugin' import App from './App.vue' import i18n from './i18n.js' -// eslint-disable-next-line no-unused-vars -import validationRules from './validation-rules' +import './validation-rules' import { store } from './store/store' diff --git a/frontend/src/views/Pages/Login.spec.js b/frontend/src/views/Pages/Login.spec.js index a4ff79bed..2339cd341 100644 --- a/frontend/src/views/Pages/Login.spec.js +++ b/frontend/src/views/Pages/Login.spec.js @@ -131,7 +131,7 @@ describe('Login', () => { await wrapper.find('form').trigger('submit') await flushPromises() expect(wrapper.findAll('div.invalid-feedback').at(1).text()).toBe( - 'The password field is required', + 'The form.password field is required', ) }) }) diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue index 2d4ce2345..f7382ef89 100755 --- a/frontend/src/views/Pages/Login.vue +++ b/frontend/src/views/Pages/Login.vue @@ -27,6 +27,7 @@
diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index 14038e676..11bdad1ba 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -2,6 +2,23 @@ import { mount, RouterLinkStub } from '@vue/test-utils' import loginAPI from '../../apis/loginAPI' import ResetPassword from './ResetPassword' import flushPromises from 'flush-promises' +import { extend } from 'vee-validate' + +const rules = [ + 'containsLowercaseCharacter', + 'containsUppercaseCharacter', + 'containsNumericCharacter', + 'atLeastEightCharactera', + 'samePassword', +] + +rules.forEach((rule) => { + extend(rule, { + validate(value) { + return true + }, + }) +}) jest.mock('../../apis/loginAPI') @@ -28,6 +45,7 @@ emailVerificationMock .mockReturnValueOnce({ success: false, result: { message: 'error' } }) .mockReturnValueOnce({ success: false, result: { message: 'error' } }) .mockReturnValueOnce({ success: false, result: { message: 'error' } }) + .mockReturnValueOnce({ success: false, result: { message: 'error' } }) .mockReturnValue(successResponseObject) changePasswordMock @@ -81,36 +99,39 @@ describe('ResetPassword', () => { }) it('does not render the Reset Password form when not authenticated', () => { - expect(wrapper.find('div.resetpwd-form').exists()).toBeFalsy() + expect(wrapper.find('form').exists()).toBeFalsy() }) it('toasts an error when no valid optin is given', () => { expect(toasterMock).toHaveBeenCalledWith('error') }) + it('has a message suggesting to contact the support', () => { + expect(wrapper.find('div.header').text()).toContain('reset-password.title') + expect(wrapper.find('div.header').text()).toContain('reset-password.not-authenticated') + }) + it('renders the Reset Password form when authenticated', async () => { - wrapper.setData({ authenticated: true }) - await wrapper.vm.$nextTick() + await wrapper.setData({ authenticated: true }) expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy() }) describe('Register header', () => { it('has a welcome message', () => { - expect(wrapper.find('div.header').text()).toBe('reset-password.title reset-password.text') + expect(wrapper.find('div.header').text()).toContain('reset-password.title') + expect(wrapper.find('div.header').text()).toContain('reset-password.text') }) }) - /* there is no back button, why? describe('links', () => { it('has a link "Back"', () => { expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual('back') }) it('links to /login when clicking "Back"', () => { - expect(wrapper.findAllComponents(RouterLinkStub).at(0).props().to).toBe('/login') + expect(wrapper.findAllComponents(RouterLinkStub).at(0).props().to).toBe('/Login') }) }) - */ describe('reset password form', () => { it('has a register form', () => { @@ -121,10 +142,6 @@ describe('ResetPassword', () => { expect(wrapper.findAll('input[type="password"]').length).toBe(2) }) - it('has no submit button when not completely filled', () => { - expect(wrapper.find('button[type="submit"]').exists()).toBe(false) - }) - it('toggles the first input field to text when eye icon is clicked', async () => { wrapper.findAll('button').at(0).trigger('click') await wrapper.vm.$nextTick() @@ -140,23 +157,20 @@ describe('ResetPassword', () => { describe('submit form', () => { beforeEach(async () => { - wrapper.findAll('input').at(0).setValue('Aa123456') - wrapper.findAll('input').at(1).setValue('Aa123456') - await wrapper.vm.$nextTick() + await wrapper.findAll('input').at(0).setValue('Aa123456') + await wrapper.findAll('input').at(1).setValue('Aa123456') await flushPromises() - wrapper.find('form').trigger('submit') + await wrapper.find('form').trigger('submit') }) describe('server response with error', () => { - it('toasts an error message', async () => { + it('toasts an error message', () => { expect(toasterMock).toHaveBeenCalledWith('error') }) }) describe('server response with success', () => { - it('calls the API', async () => { - await wrapper.vm.$nextTick() - await flushPromises() + it('calls the API', () => { expect(changePasswordMock).toHaveBeenCalledWith(1, 'user@example.org', 'Aa123456') }) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 1f1cbdbc0..616fa85c1 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -1,102 +1,34 @@