From ac15586f34f09281d41a9862a5d62e16832fc4e1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 19 Jan 2023 13:05:58 +0100 Subject: [PATCH 1/2] reduce min value to 0.25 to be consistent --- frontend/src/components/Contributions/ContributionForm.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index e9f99848f..b70404c9b 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -35,12 +35,12 @@ v-model="form.hours" :name="$t('form.hours')" :label="$t('form.hours')" - placeholder="0.5" + placeholder="0.25" :rules="{ required: true, - min: 0.5, + min: 0.25, max: validMaxTime, - gddCreationTime: [0.5, validMaxTime], + gddCreationTime: [0.25, validMaxTime], }" :validMaxTime="validMaxTime" @updateAmount="updateAmount" From d7fa8b8f8b4133e861e8e73daadec940335c0b38 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 19 Jan 2023 13:24:51 +0100 Subject: [PATCH 2/2] refactor(frontend): forgot password unit tests --- frontend/src/pages/ForgotPassword.spec.js | 62 +++++++++-------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/frontend/src/pages/ForgotPassword.spec.js b/frontend/src/pages/ForgotPassword.spec.js index f4b74e555..c5b25bf1c 100644 --- a/frontend/src/pages/ForgotPassword.spec.js +++ b/frontend/src/pages/ForgotPassword.spec.js @@ -1,4 +1,4 @@ -import { mount, RouterLinkStub } from '@vue/test-utils' +import { mount } from '@vue/test-utils' import flushPromises from 'flush-promises' import { toastErrorSpy } from '@test/testSetup' import ForgotPassword from './ForgotPassword' @@ -7,43 +7,28 @@ const mockAPIcall = jest.fn() const localVue = global.localVue -const mockRouterPush = jest.fn() - -const stubs = { - RouterLink: RouterLinkStub, -} - -const createMockObject = (comingFrom) => { - return { - localVue, - mocks: { - $t: jest.fn((t) => t), - $router: { - push: mockRouterPush, - }, - $apollo: { - mutate: mockAPIcall, - }, - $route: { - params: { - comingFrom, - }, - }, +const mocks = { + $t: jest.fn((t) => t), + $apollo: { + mutate: mockAPIcall, + }, + $route: { + params: { + comingFrom: '', }, - stubs, - } + }, } describe('ForgotPassword', () => { let wrapper - const Wrapper = (functionN) => { - return mount(ForgotPassword, functionN) + const Wrapper = () => { + return mount(ForgotPassword, { localVue, mocks }) } describe('mount', () => { beforeEach(() => { - wrapper = Wrapper(createMockObject()) + wrapper = Wrapper() }) it('renders the component', () => { @@ -110,12 +95,6 @@ describe('ForgotPassword', () => { expect(wrapper.find('.test-message-button').attributes('href')).toBe('/login') }) - it.skip('click redirects to "/login"', async () => { - // wrapper.find('.test-message-button').trigger('click') - // await wrapper.vm.$nextTick() - expect(mockRouterPush).toBeCalledWith('/login') - }) - it('toasts a standard error message', () => { expect(toastErrorSpy).toBeCalledWith('error.email-already-sent') }) @@ -144,13 +123,20 @@ describe('ForgotPassword', () => { it('button link redirects to "/login"', () => { expect(wrapper.find('.test-message-button').attributes('href')).toBe('/login') }) - - it.skip('click redirects to "/login"', () => { - // expect(mockRouterPush).toBeCalledWith('/login') - }) }) }) }) }) + + describe('route has coming from ', () => { + beforeEach(() => { + mocks.$route.params.comingFrom = 'coming from' + wrapper = Wrapper() + }) + + it('changes subtitle', () => { + expect(wrapper.vm.subtitle).toBe('settings.password.resend_subtitle') + }) + }) }) })