From 5fd8ea2223f6f2e2739834ef39fde091ec955682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 25 Jul 2022 14:06:10 +0200 Subject: [PATCH 01/16] Reset amount in Contribution form and write a test --- .../src/components/Contributions/ContributionForm.vue | 1 + frontend/src/pages/Community.spec.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 6b8ef39d0..72576ece8 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -111,6 +111,7 @@ export default { this.form.date = '' this.id = null this.form.memo = '' + this.form.amount = '0' }, }, computed: { diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index d834ddac1..bce29452c 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -190,6 +190,13 @@ describe('Community', () => { fetchPolicy: 'network-only', }) }) + + it('set all data to the default values)', () => { + expect(wrapper.vm.form.id).toBe(null) + expect(wrapper.vm.form.date).toBe('') + expect(wrapper.vm.form.memo).toBe('') + expect(wrapper.vm.form.amount).toBe('0') + }) }) describe('with error', () => { @@ -376,7 +383,7 @@ describe('Community', () => { }) }) - it('sets the form date to the new values', () => { + it('sets the form data to the new values', () => { expect(wrapper.vm.form.id).toBe(2) expect(wrapper.vm.form.date).toBe(now) expect(wrapper.vm.form.memo).toBe('Mein Beitrag zur Gemeinschaft für diesen Monat ...') From 7b2de945bc5bc109d44f1db1f9cf82db9a4dc675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 09:29:20 +0200 Subject: [PATCH 02/16] Set amount in Contribution form all over the place as '0' --- frontend/src/pages/Community.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 64aca6156..e85f708c3 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -103,7 +103,7 @@ export default { id: null, date: '', memo: '', - amount: '', + amount: '0', }, updateAmount: '', } From a4947339dcff69ae6dde73242cd23cdaf1afdf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 09:39:33 +0200 Subject: [PATCH 03/16] Set amount in Contribution form all over the place as '' and not '0' --- frontend/src/components/Contributions/ContributionForm.vue | 2 +- frontend/src/pages/Community.spec.js | 2 +- frontend/src/pages/Community.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 72576ece8..6bd18d784 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -111,7 +111,7 @@ export default { this.form.date = '' this.id = null this.form.memo = '' - this.form.amount = '0' + this.form.amount = '' }, }, computed: { diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index bce29452c..05dbb3bdc 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -195,7 +195,7 @@ describe('Community', () => { expect(wrapper.vm.form.id).toBe(null) expect(wrapper.vm.form.date).toBe('') expect(wrapper.vm.form.memo).toBe('') - expect(wrapper.vm.form.amount).toBe('0') + expect(wrapper.vm.form.amount).toBe('') }) }) diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index e85f708c3..64aca6156 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -103,7 +103,7 @@ export default { id: null, date: '', memo: '', - amount: '0', + amount: '', }, updateAmount: '', } From 5ff0de7b4f604db95388ccd94380d03f554dee79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 10:41:29 +0200 Subject: [PATCH 04/16] Submit on 'Change' (with id) submit button text shall change to 'Submit' and chnage button text from 'Edit' to 'Change' --- .../components/Contributions/ContributionForm.vue | 15 ++++++++------- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 6bd18d784..647cd0067 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -74,7 +74,7 @@ - {{ value.id ? $t('form.edit') : $t('contribution.submit') }} + {{ form.id ? $t('form.change') : $t('contribution.submit') }} @@ -93,13 +93,13 @@ export default { minlength: 50, maxlength: 255, maximalDate: new Date(), - form: this.value, - id: this.value.id, + form: this.value, // includes 'id' + // Wolle: id: this.value.id, } }, methods: { submit() { - if (this.value.id) { + if (this.form.id) { this.$emit('update-contribution', this.form) } else { this.$emit('set-contribution', this.form) @@ -108,8 +108,9 @@ export default { }, reset() { this.$refs.form.reset() + // Wolle: this.id = null + this.form.id = null this.form.date = '' - this.id = null this.form.memo = '' this.form.amount = '' }, @@ -154,13 +155,13 @@ export default { }, maxGddLastMonth() { // When edited, the amount is added back on top of the amount - return this.value.id && !this.isThisMonth + return this.form.id && !this.isThisMonth ? parseInt(this.$store.state.creation[1]) + parseInt(this.updateAmount) : this.$store.state.creation[1] }, maxGddThisMonth() { // When edited, the amount is added back on top of the amount - return this.value.id && this.isThisMonth + return this.form.id && this.isThisMonth ? parseInt(this.$store.state.creation[2]) + parseInt(this.updateAmount) : this.$store.state.creation[2] }, diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index ef81d463e..d06299245 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -110,7 +110,7 @@ "current_balance": "Aktueller Kontostand", "date": "Datum", "description": "Beschreibung", - "edit": "Bearbeiten", + "change": "Ändern", "email": "E-Mail", "firstname": "Vorname", "from": "Von", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 47753487d..de1ee6900 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -110,7 +110,7 @@ "current_balance": "Current Balance", "date": "Date", "description": "Description", - "edit": "Edit", + "change": "Change", "email": "Email", "firstname": "Firstname", "from": "from", From 37a255ffeaa6e4d944da4d96ceba2ba90a80e084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 10:51:57 +0200 Subject: [PATCH 05/16] Write a test for reseting all form data after updateContribution --- frontend/src/pages/Community.spec.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index 05dbb3bdc..24260addf 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -277,6 +277,13 @@ describe('Community', () => { fetchPolicy: 'network-only', }) }) + + it('set all data to the default values)', () => { + expect(wrapper.vm.form.id).toBe(null) + expect(wrapper.vm.form.date).toBe('') + expect(wrapper.vm.form.memo).toBe('') + expect(wrapper.vm.form.amount).toBe('') + }) }) describe('with error', () => { From c808ecc3f4094f5103e2f131ea51317a260ec621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 15:47:51 +0200 Subject: [PATCH 06/16] Fix linting and cleanup --- frontend/src/components/Contributions/ContributionForm.vue | 2 -- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 647cd0067..39a7b6130 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 = '' 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 91538b72de88c9fb63d02c257f518ec75092f00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:10:05 +0200 Subject: [PATCH 07/16] Change reset button to cancel and add tests --- .../Contributions/ContributionForm.spec.js | 66 ++++++++++++++++++- .../Contributions/ContributionForm.vue | 4 +- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 4f3ee6fa6..0a85c088d 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -45,8 +45,70 @@ 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('update contrubtion', () => { + describe('fill in form data and "id"', () => { + const now = new Date().toISOString() + + beforeEach(async () => { + await wrapper.setData({ + form: { + id: 2, + 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() + }) + }) + }) }) }) }) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index f5231c1aa..b18a92a13 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -71,8 +71,8 @@ - - {{ $t('form.reset') }} + + {{ $t('form.cancel') }} From 0489130f4caefe670cdb1e07a68e1857c825e4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:31:16 +0200 Subject: [PATCH 08/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 0a85c088d..85c4506ed 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -46,7 +46,7 @@ describe('ContributionForm', () => { }) describe('empty form data', () => { - describe('has button', () => { + describe('buttons', () => { it('reset enabled', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) From 539e50cad2b8bff74acd27b96bc787ddf4dc1a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:31:26 +0200 Subject: [PATCH 09/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 85c4506ed..53244e484 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -47,7 +47,7 @@ describe('ContributionForm', () => { describe('empty form data', () => { describe('buttons', () => { - it('reset enabled', () => { + it('has reset enabled', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) From cc8f0d0ee7f970b986c714e9a0b60b94e18ed559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:31:33 +0200 Subject: [PATCH 10/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 53244e484..1e80e7cf7 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -51,7 +51,7 @@ describe('ContributionForm', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) - it('submit disabled', () => { + it('has submit disabled', () => { expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled') }) }) From 67048de5c79c8a8762782b37807fb80ea72afb71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:31:41 +0200 Subject: [PATCH 11/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 1e80e7cf7..58f1b9a24 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -72,7 +72,7 @@ describe('ContributionForm', () => { }) }) - describe('has button', () => { + describe('buttons', () => { it('reset enabled', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) From 52c48f16e494525ebe918fc5f2672532251da7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:31:50 +0200 Subject: [PATCH 12/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 58f1b9a24..f5d5d04f4 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -73,7 +73,7 @@ describe('ContributionForm', () => { }) describe('buttons', () => { - it('reset enabled', () => { + it('has reset enabled', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) From e171abfa7d7c7b97497fe8497e9ff64ae98fa7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:32:13 +0200 Subject: [PATCH 13/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index f5d5d04f4..5a6241e86 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -77,7 +77,7 @@ describe('ContributionForm', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) - it('submit enabled', () => { + it('has submit enabled', () => { expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy() }) }) From 1ae5c7cfac8a8e5d19571a893ac513b5f7213d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:32:21 +0200 Subject: [PATCH 14/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 5a6241e86..5cddad918 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -99,7 +99,7 @@ describe('ContributionForm', () => { }) }) - describe('has button', () => { + describe('buttons', () => { it('reset enabled', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) From 8b596de97ed7ec5683fb33b11bfede5273af3f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:32:29 +0200 Subject: [PATCH 15/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 5cddad918..c74add5b0 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -100,7 +100,7 @@ describe('ContributionForm', () => { }) describe('buttons', () => { - it('reset enabled', () => { + it('has reset enabled', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) From e41be4d8329d916be7eb427f832cf3dc168398c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 26 Jul 2022 16:52:39 +0200 Subject: [PATCH 16/16] Update frontend/src/components/Contributions/ContributionForm.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/Contributions/ContributionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index c74add5b0..eb1509328 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -104,7 +104,7 @@ describe('ContributionForm', () => { expect(wrapper.find('button[type="reset"]').attributes('disabled')).toBeFalsy() }) - it('submit enabled', () => { + it('has submit enabled', () => { expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBeFalsy() }) })