From b590a82b04cc3d4197e2bf060538c54634a6add6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:20:29 +0200 Subject: [PATCH 01/68] Change reset button to cancel and dev comments --- .../src/components/Contributions/ContributionForm.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 647cd0067..97d012516 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -68,8 +68,8 @@ - - {{ $t('form.reset') }} + + {{ $t('form.cancel') }} @@ -136,6 +136,7 @@ export default { return false }, lastMonthObject() { + // Wolle: refine logic and melt with 'thisMonthObject' // new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month const obj = { monthAndYear: this.$d(new Date(this.minimalDate), 'monthAndYear'), @@ -144,6 +145,7 @@ export default { return this.$t('contribution.formText.openAmountForMonth', obj) }, thisMonthObject() { + // Wolle: refine logic and melt with 'lastMonthObject' const obj = { monthAndYear: this.$d(new Date(), 'monthAndYear'), creation: this.maxGddThisMonth, @@ -151,15 +153,18 @@ export default { return this.$t('contribution.formText.openAmountForMonth', obj) }, isThisMonth() { + // Wolle: Jahr testen return new Date(this.form.date).getMonth() === new Date().getMonth() }, maxGddLastMonth() { + // Wolle: refine logic and melt with 'maxGddThisMonth' // When edited, the amount is added back on top of the amount return this.form.id && !this.isThisMonth ? parseInt(this.$store.state.creation[1]) + parseInt(this.updateAmount) : this.$store.state.creation[1] }, maxGddThisMonth() { + // Wolle: refine logic and melt with 'maxGddLastMonth' // When edited, the amount is added back on top of the amount return this.form.id && this.isThisMonth ? parseInt(this.$store.state.creation[2]) + parseInt(this.updateAmount) From 7eb6fc6c5165c5b88a8fbfe02061555da947e691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:20:49 +0200 Subject: [PATCH 02/68] Refactor and enhance tests, try --- .../Contributions/ContributionForm.spec.js | 131 +++++++++++++++++- 1 file changed, 128 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 5b05957bb..00a3d9578 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -1,4 +1,5 @@ import { mount } from '@vue/test-utils' +import flushPromises from 'flush-promises' import ContributionForm from './ContributionForm.vue' const localVue = global.localVue @@ -6,7 +7,7 @@ const localVue = global.localVue describe('ContributionForm', () => { let wrapper - const propsData = { + let propsData = { value: { id: null, date: '', @@ -42,8 +43,132 @@ describe('ContributionForm', () => { expect(wrapper.find('div.contribution-form').exists()).toBe(true) }) - it('is submit button disable of true', () => { - expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled') + describe('empty form data', () => { + describe('has button', () => { + it('reset enabled', () => { + expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() + }) + + it('submit disabled', () => { + expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled') + }) + }) + }) + + describe('set contrubtion', () => { + describe('fill in form data', () => { + const now = new Date().toISOString() + + beforeEach(async () => { + await wrapper.setData({ + form: { + id: null, + date: now, + memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', + amount: '200', + }, + }) + }) + + describe('has button', () => { + it('reset enabled', () => { + expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() + }) + + it('submit enabled', () => { + expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy() + }) + }) + + describe.skip('on trigger submit', () => { + beforeEach(async () => { + // await wrapper.find('.test-submit').trigger('click') + await wrapper.find('button[type="submit"]').trigger('click') + }) + + it('emits "set-contribution"', () => { + expect(wrapper.emitted('set-contribution')).toEqual({ + id: null, + date: now, + memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', + amount: '200', + }) + }) + }) + }) + }) + + describe('update contrubtion', () => { + describe('fill in form data and "id"', () => { + const now = new Date().toISOString() + + beforeEach(async () => { + // Wolle: await wrapper.setData({ + // form: { + // id: 2, + // date: now, + // memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', + // amount: '200', + // }, + // }) + // await wrapper.setData({ + // form: { + // id: 2, + // }, + // }) + propsData = { + value: { + id: 2, + date: '', + memo: '', + amount: '', + }, + } + wrapper = Wrapper() + // await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now) + await wrapper + .find('#contribution-memo') + .find('textarea') + .setValue('Mein Beitrag zur Gemeinschaft für diesen Monat ...') + await wrapper.find('#contribution-amount').find('input').setValue('200') + await flushPromises() + // Wolle: + await wrapper.vm.$nextTick() + }) + + describe('has button', () => { + it('reset enabled', () => { + expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() + }) + + it('submit enabled', () => { + expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy() + }) + }) + + describe.only('on trigger submit', () => { + beforeEach(async () => { + // await wrapper.find('.test-submit').trigger('click') + // await wrapper.find('button[type="submit"]').trigger('click') + await wrapper.find('form').trigger('submit') + }) + + it('emits "update-contribution"', () => { + expect(wrapper.emitted('update-contribution')).toEqual( + expect.arrayContaining([ + expect.arrayContaining([ + { + id: 2, + date: now, + memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', + amount: '200', + }, + ]), + ]), + ) + }) + }) + }) }) }) }) From 14360fb8afba8ba129a31870cf2867e953648da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:26:10 +0200 Subject: [PATCH 03/68] Cleanup a little --- frontend/src/components/Contributions/ContributionForm.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 97d012516..da5b2fbee 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -94,7 +94,6 @@ export default { maxlength: 255, maximalDate: new Date(), form: this.value, // includes 'id' - // Wolle: id: this.value.id, } }, methods: { @@ -108,7 +107,6 @@ export default { }, reset() { this.$refs.form.reset() - // Wolle: this.id = null this.form.id = null this.form.date = '' this.form.memo = '' From 3a183918c5306b868fdb8b7d653bdef709143b5b Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 4 Aug 2022 11:34:46 +0200 Subject: [PATCH 04/68] Change checkOptInCode to check if emailChecked before changing optInState. --- backend/src/graphql/resolver/UserResolver.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index a89a8cb0b..bd1fff918 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -187,7 +187,7 @@ const newEmailOptIn = (userId: number): LoginEmailOptIn => { // if optIn does not exits, it is created export const checkOptInCode = async ( optInCode: LoginEmailOptIn | undefined, - userId: number, + user: DbUser, optInType: OptInType = OptInType.EMAIL_OPT_IN_REGISTER, ): Promise => { logger.info(`checkOptInCode... ${optInCode}`) @@ -207,15 +207,18 @@ export const checkOptInCode = async ( optInCode.updatedAt = new Date() optInCode.resendCount++ } else { - logger.trace('create new OptIn for userId=' + userId) - optInCode = newEmailOptIn(userId) + logger.trace('create new OptIn for userId=' + user.id) + optInCode = newEmailOptIn(user.id) + } + + if (user.emailChecked) { + optInCode.emailOptInTypeId = optInType } - optInCode.emailOptInTypeId = optInType await LoginEmailOptIn.save(optInCode).catch(() => { logger.error('Unable to save optin code= ' + optInCode) throw new Error('Unable to save optin code.') }) - logger.debug(`checkOptInCode...successful: ${optInCode} for userid=${userId}`) + logger.debug(`checkOptInCode...successful: ${optInCode} for userid=${user.id}`) return optInCode } @@ -493,7 +496,7 @@ export class UserResolver { userId: user.id, }) - optInCode = await checkOptInCode(optInCode, user.id, OptInType.EMAIL_OPT_IN_RESET_PASSWORD) + optInCode = await checkOptInCode(optInCode, user, OptInType.EMAIL_OPT_IN_RESET_PASSWORD) logger.info(`optInCode for ${email}=${optInCode}`) // eslint-disable-next-line @typescript-eslint/no-unused-vars const emailSent = await sendResetPasswordEmailMailer({ From f42ba0557295453104bd9b619a16b3e3915381aa Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 4 Aug 2022 11:35:34 +0200 Subject: [PATCH 05/68] Change call of checkOptInCode since signature changed. --- backend/src/graphql/resolver/AdminResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 84ae09cf8..b7ac63842 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -501,7 +501,7 @@ export class AdminResolver { order: { updatedAt: 'DESC' }, }) - optInCode = await checkOptInCode(optInCode, user.id) + optInCode = await checkOptInCode(optInCode, user) // eslint-disable-next-line @typescript-eslint/no-unused-vars const emailSent = await sendAccountActivationEmail({ From 6c748fdb30e30251a74150b8cb9b7a2c1a92b47f Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 4 Aug 2022 11:46:48 +0200 Subject: [PATCH 06/68] Add new logger for klicktipp. --- backend/log4js-config.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/log4js-config.json b/backend/log4js-config.json index 451da56ab..848a4fa79 100644 --- a/backend/log4js-config.json +++ b/backend/log4js-config.json @@ -25,6 +25,14 @@ "keepFileExt" : true, "fileNameSep" : "_" }, + "klicktipp": + { + "type": "dateFile", + "filename": "../logs/backend/klicktipp.log", + "pattern": "%d{ISO8601} %p %c %X{user} %f:%l %m", + "keepFileExt" : true, + "fileNameSep" : "_" + }, "errorFile": { "type": "dateFile", @@ -90,6 +98,17 @@ "level": "debug", "enableCallStack": true }, + "klicktipp": + { + "appenders": + [ + "klicktipp", + "out", + "errors" + ], + "level": "debug", + "enableCallStack": true + }, "http": { "appenders": From 87055e732c5242791ced8b158d3d9c2f2b331514 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 4 Aug 2022 11:47:10 +0200 Subject: [PATCH 07/68] Define klicktipp logger. --- backend/src/server/logger.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index cbc8c9b9b..0cfa5689b 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -12,7 +12,8 @@ log4js.configure(options) const apolloLogger = log4js.getLogger('apollo') const backendLogger = log4js.getLogger('backend') +const klickTippLogger = log4js.getLogger('klicktipp') backendLogger.addContext('user', 'unknown') -export { apolloLogger, backendLogger } +export { apolloLogger, backendLogger, klickTippLogger } From 140a374291b452830a088047c3866446d0940735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 4 Aug 2022 11:47:29 +0200 Subject: [PATCH 08/68] Add data-test properties to buttons --- .../Contributions/ContributionForm.spec.js | 12 ++++++++---- .../components/Contributions/ContributionForm.vue | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 00a3d9578..80dcd28c1 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -138,15 +138,19 @@ describe('ContributionForm', () => { describe('has button', () => { it('reset enabled', () => { - expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() + expect( + wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), + ).toBeFalsy() }) - it('submit enabled', () => { - expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy() + it.only('submit enabled', () => { + expect( + wrapper.find('button[data-test="button-submit"]').attributes('disabled'), + ).toBeFalsy() }) }) - describe.only('on trigger submit', () => { + describe.skip('on trigger submit', () => { beforeEach(async () => { // await wrapper.find('.test-submit').trigger('click') // await wrapper.find('button[type="submit"]').trigger('click') diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index da5b2fbee..5434881ab 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -68,12 +68,12 @@ - + {{ $t('form.cancel') }} - + {{ form.id ? $t('form.change') : $t('contribution.submit') }} From 174d592d5a6b4140f1af164aae7dcc00555bed4e Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 4 Aug 2022 11:47:55 +0200 Subject: [PATCH 09/68] Log error for klicktipp for not found users. --- backend/src/middleware/klicktippMiddleware.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/middleware/klicktippMiddleware.ts b/backend/src/middleware/klicktippMiddleware.ts index b3699f29b..5f0c28477 100644 --- a/backend/src/middleware/klicktippMiddleware.ts +++ b/backend/src/middleware/klicktippMiddleware.ts @@ -2,6 +2,7 @@ import { MiddlewareFn } from 'type-graphql' import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' import { KlickTipp } from '@model/KlickTipp' import CONFIG from '@/config' +import { klickTippLogger as logger } from '@/server/logger' // export const klicktippRegistrationMiddleware: MiddlewareFn = async ( // // Only for demo @@ -29,7 +30,9 @@ export const klicktippNewsletterStateMiddleware: MiddlewareFn = async ( if (klickTippUser) { klickTipp = new KlickTipp(klickTippUser) } - } catch (err) {} + } catch (err) { + logger.info(`Their is no user for (email='${result.email}') ${err}`) + } } result.klickTipp = klickTipp return result From 2759c7011d8065d1849689d60c3b178512e14ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 4 Aug 2022 12:18:50 +0200 Subject: [PATCH 10/68] Fix test in 'ContributionForm.spec.js' --- .../Contributions/ContributionForm.spec.js | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 80dcd28c1..fdd037b63 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -7,7 +7,7 @@ const localVue = global.localVue describe('ContributionForm', () => { let wrapper - let propsData = { + const propsData = { value: { id: null, date: '', @@ -103,37 +103,13 @@ describe('ContributionForm', () => { const now = new Date().toISOString() beforeEach(async () => { - // Wolle: await wrapper.setData({ - // form: { - // id: 2, - // date: now, - // memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', - // amount: '200', - // }, - // }) - // await wrapper.setData({ - // form: { - // id: 2, - // }, - // }) - propsData = { - value: { - id: 2, - date: '', - memo: '', - amount: '', - }, - } wrapper = Wrapper() - // await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now) + await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now) await wrapper .find('#contribution-memo') .find('textarea') .setValue('Mein Beitrag zur Gemeinschaft für diesen Monat ...') await wrapper.find('#contribution-amount').find('input').setValue('200') - await flushPromises() - // Wolle: - await wrapper.vm.$nextTick() }) describe('has button', () => { @@ -143,21 +119,24 @@ describe('ContributionForm', () => { ).toBeFalsy() }) - it.only('submit enabled', () => { + it('submit enabled', () => { expect( wrapper.find('button[data-test="button-submit"]').attributes('disabled'), ).toBeFalsy() }) }) - describe.skip('on trigger submit', () => { + describe('on trigger submit', () => { beforeEach(async () => { // await wrapper.find('.test-submit').trigger('click') // await wrapper.find('button[type="submit"]').trigger('click') await wrapper.find('form').trigger('submit') + await flushPromises() + // Wolle: + await wrapper.vm.$nextTick() }) - it('emits "update-contribution"', () => { + it.only('emits "update-contribution"', () => { expect(wrapper.emitted('update-contribution')).toEqual( expect.arrayContaining([ expect.arrayContaining([ From f7dccb04b61a90fbe902cfa12bfa65c9b5304360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 4 Aug 2022 15:45:38 +0200 Subject: [PATCH 11/68] Fix all tests in 'ContributionForm.spec.js' --- .../Contributions/ContributionForm.spec.js | 121 ++++++++++-------- .../Contributions/ContributionForm.vue | 7 +- 2 files changed, 69 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index fdd037b63..9dfc090f2 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -1,5 +1,4 @@ import { mount } from '@vue/test-utils' -import flushPromises from 'flush-promises' import ContributionForm from './ContributionForm.vue' const localVue = global.localVue @@ -46,64 +45,24 @@ describe('ContributionForm', () => { describe('empty form data', () => { describe('has button', () => { it('reset enabled', () => { - expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() + expect( + wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), + ).toBeFalsy() }) it('submit disabled', () => { - expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled') + expect(wrapper.find('button[data-test="button-submit"]').attributes('disabled')).toBe( + 'disabled', + ) }) }) }) describe('set contrubtion', () => { - describe('fill in form data', () => { + describe('fill in form data with "id === null"', () => { const now = new Date().toISOString() beforeEach(async () => { - await wrapper.setData({ - form: { - id: null, - date: now, - memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', - amount: '200', - }, - }) - }) - - describe('has button', () => { - it('reset enabled', () => { - expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() - }) - - it('submit enabled', () => { - expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy() - }) - }) - - describe.skip('on trigger submit', () => { - beforeEach(async () => { - // await wrapper.find('.test-submit').trigger('click') - await wrapper.find('button[type="submit"]').trigger('click') - }) - - it('emits "set-contribution"', () => { - expect(wrapper.emitted('set-contribution')).toEqual({ - id: null, - date: now, - memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', - amount: '200', - }) - }) - }) - }) - }) - - describe('update contrubtion', () => { - describe('fill in form data and "id"', () => { - const now = new Date().toISOString() - - beforeEach(async () => { - wrapper = Wrapper() await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now) await wrapper .find('#contribution-memo') @@ -128,15 +87,69 @@ describe('ContributionForm', () => { describe('on trigger submit', () => { beforeEach(async () => { - // await wrapper.find('.test-submit').trigger('click') - // await wrapper.find('button[type="submit"]').trigger('click') await wrapper.find('form').trigger('submit') - await flushPromises() - // Wolle: - await wrapper.vm.$nextTick() }) - it.only('emits "update-contribution"', () => { + it('emits "set-contribution"', () => { + expect(wrapper.emitted('set-contribution')).toEqual( + expect.arrayContaining([ + expect.arrayContaining([ + { + id: null, + date: now, + memo: 'Mein Beitrag zur Gemeinschaft für diesen Monat ...', + amount: '200', + }, + ]), + ]), + ) + }) + }) + }) + }) + + describe('update contrubtion', () => { + describe('fill in form data with set "id"', () => { + const now = new Date().toISOString() + + beforeEach(async () => { + wrapper = Wrapper() + await wrapper.setData({ + form: { + id: 2, + date: now, + memo: 'Mein kommerzieller Beitrag für diesen Monat ...', + amount: '100', + }, + }) + await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now) + await wrapper + .find('#contribution-memo') + .find('textarea') + .setValue('Mein Beitrag zur Gemeinschaft für diesen Monat ...') + await wrapper.find('#contribution-amount').find('input').setValue('200') + }) + + describe('has button', () => { + it('reset enabled', () => { + expect( + wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), + ).toBeFalsy() + }) + + it('submit enabled', () => { + expect( + wrapper.find('button[data-test="button-submit"]').attributes('disabled'), + ).toBeFalsy() + }) + }) + + describe('on trigger submit', () => { + beforeEach(async () => { + await wrapper.find('form').trigger('submit') + }) + + it('emits "update-contribution"', () => { expect(wrapper.emitted('update-contribution')).toEqual( expect.arrayContaining([ expect.arrayContaining([ diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 5434881ab..e19fb2b9a 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -98,11 +98,8 @@ export default { }, methods: { submit() { - if (this.form.id) { - this.$emit('update-contribution', this.form) - } else { - this.$emit('set-contribution', this.form) - } + // this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', this.form) // is not working for testing + this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', { ...this.form }) // this works for testing, why ever, we have to make a spread '...', to evaluate the values it looks like this.reset() }, reset() { From 9c8f76d080ff1daee0ec5847fa77d4a62dd883ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 4 Aug 2022 16:02:15 +0200 Subject: [PATCH 12/68] Write new tests in 'ContributionForm.spec.js' --- .../Contributions/ContributionForm.spec.js | 52 +++++++++++++------ .../Contributions/ContributionForm.vue | 6 ++- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 9dfc090f2..298f4a82f 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -72,16 +72,26 @@ describe('ContributionForm', () => { }) describe('has button', () => { - it('reset enabled', () => { - expect( - wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), - ).toBeFalsy() + describe('reset', () => { + it('enabled', () => { + expect( + wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), + ).toBeFalsy() + }) }) - it('submit enabled', () => { - expect( - wrapper.find('button[data-test="button-submit"]').attributes('disabled'), - ).toBeFalsy() + describe('submit', () => { + it('enabled', () => { + expect( + wrapper.find('button[data-test="button-submit"]').attributes('disabled'), + ).toBeFalsy() + }) + + it('labeled with "contribution.submit"', () => { + expect(wrapper.find('button[data-test="button-submit"]').text()).toContain( + 'contribution.submit', + ) + }) }) }) @@ -131,16 +141,26 @@ describe('ContributionForm', () => { }) describe('has button', () => { - it('reset enabled', () => { - expect( - wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), - ).toBeFalsy() + describe('reset', () => { + it('enabled', () => { + expect( + wrapper.find('button[data-test="button-cancel"]').attributes('disabled'), + ).toBeFalsy() + }) }) - it('submit enabled', () => { - expect( - wrapper.find('button[data-test="button-submit"]').attributes('disabled'), - ).toBeFalsy() + describe('submit', () => { + it('enabled', () => { + expect( + wrapper.find('button[data-test="button-submit"]').attributes('disabled'), + ).toBeFalsy() + }) + + it('labeled with "form.change"', () => { + expect(wrapper.find('button[data-test="button-submit"]').text()).toContain( + 'form.change', + ) + }) }) }) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index e19fb2b9a..a24c07ec2 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -98,8 +98,10 @@ export default { }, methods: { submit() { - // this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', this.form) // is not working for testing - this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', { ...this.form }) // this works for testing, why ever, we have to make a spread '...', to evaluate the values it looks like + // not working for testing: + // this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', this.form) + // works for testing, why ever, we have to make a spread '...', to evaluate the values it looks like: (I didn't find a solution in the test itmself) + this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', { ...this.form }) this.reset() }, reset() { From 6823ff548804a9f0600dbc0a81e74100c22a1e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 4 Aug 2022 16:06:48 +0200 Subject: [PATCH 13/68] Fix locales --- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index d06299245..0deec9ae1 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -105,12 +105,12 @@ "amount": "Betrag", "at": "am", "cancel": "Abbrechen", + "change": "Ändern", "check_now": "Jetzt prüfen", "close": "Schließen", "current_balance": "Aktueller Kontostand", "date": "Datum", "description": "Beschreibung", - "change": "Ändern", "email": "E-Mail", "firstname": "Vorname", "from": "Von", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index de1ee6900..65b7abc87 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -105,12 +105,12 @@ "amount": "Amount", "at": "at", "cancel": "Cancel", + "change": "Change", "check_now": "Check now", "close": "Close", "current_balance": "Current Balance", "date": "Date", "description": "Description", - "change": "Change", "email": "Email", "firstname": "Firstname", "from": "from", From 18ad0107dec4479c66f21a10fc851deb0e4b40e9 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sun, 7 Aug 2022 11:55:43 +0200 Subject: [PATCH 14/68] add new menu point for GDT --- frontend/src/components/Menu/Sidebar.vue | 4 ++++ frontend/src/pages/Transactions.vue | 25 +++++++++++++++++++++++- frontend/src/routes/routes.js | 9 +++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index 00243fa49..fc3ecc21d 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -16,6 +16,10 @@ {{ $t('navigation.transactions') }} + + + {{ $t('gdt.gdt') }} + {{ $t('navigation.community') }} diff --git a/frontend/src/pages/Transactions.vue b/frontend/src/pages/Transactions.vue index 109e3f19c..d0f4ac8b8 100644 --- a/frontend/src/pages/Transactions.vue +++ b/frontend/src/pages/Transactions.vue @@ -1,7 +1,11 @@