From 1d4f628cb9e0a908332c45fd126679914735c25c Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 06:38:55 +0200 Subject: [PATCH 01/36] add locales required for new link copy use case --- frontend/src/locales/de.json | 6 +++++- frontend/src/locales/en.json | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 6be44f30d..4db32e369 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -125,7 +125,9 @@ "gdd_per_link": { "choose-amount": "Wähle einen Betrag aus, welchen du per Link versenden möchtest. Du kannst auch noch eine Nachricht eintragen. Beim Klick „Jetzt generieren“ wird ein Link erstellt, den du versenden kannst.", "copy": "kopieren", + "copy-with-text": "Link und Text kopieren", "created": "Der Link wurde erstellt!", + "credit-your-gradido": "Um deine Gradido gutzuschreiben, klicke auf den Link!", "decay-14-day": "Vergänglichkeit für 14 Tage", "delete-the-link": "Den Link löschen?", "deleted": "Der Link wurde gelöscht!", @@ -134,6 +136,7 @@ "header": "Gradidos versenden per Link", "isFree": "Gradido ist weltweit kostenfrei.", "link-copied": "Link wurde in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", + "link-and-text-copied": "Der Link und deine Nachricht wurden in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", "link-deleted": "Der Link wurde am {date} gelöscht.", "link-expired": "Der Link ist nicht mehr gültig. Die Gültigkeit ist am {date} abgelaufen.", "link-overview": "Linkübersicht", @@ -149,7 +152,8 @@ "redeemed-title": "eingelöst", "to-login": "Log dich ein", "to-register": "Registriere ein neues Konto.", - "validUntil": "Gültig bis" + "validUntil": "Gültig bis", + "validUntilDate": "Sie sind bis zum {date} gültig." }, "gdt": { "calculation": "Berechnung der Gradido Transform", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 5a89bb7bb..db409ff54 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -125,7 +125,9 @@ "gdd_per_link": { "choose-amount": "Select an amount that you would like to send via link. You can also enter a message. Click 'Generate now' to create a link that you can share.", "copy": "copy", + "copy-with-text": "copy link and text", "created": "Link was created!", + "credit-your-gradido": "To credit your Gradido, click on the link!", "decay-14-day": "Decay for 14 days", "delete-the-link": "Delete the link?", "deleted": "The link was deleted!", @@ -134,6 +136,7 @@ "header": "Send Gradidos via link", "isFree": "Gradido is free of charge worldwide.", "link-copied": "Link has been copied to the clipboard. You can now paste it into an email or message.", + "link-and-text-copied": "The link and your message have been copied to the clipboard. You can now include it in an email or message.", "link-deleted": "The link was deleted on {date}.", "link-expired": "The link is no longer valid. The validity expired on {date}.", "link-overview": "Link overview", @@ -149,7 +152,8 @@ "redeemed-title": "redeemed", "to-login": "Log in", "to-register": "Register a new account.", - "validUntil": "Valid until" + "validUntil": "Valid until", + "validUntilDate": "They are valid until {date}." }, "gdt": { "calculation": "Calculation of Gradido Transform", From b7fb51887f6afc11f8fe3b935a110e8e3f2f6058 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 06:42:39 +0200 Subject: [PATCH 02/36] add dropdown item and method for new link copy use case --- .../TransactionLinks/TransactionLink.vue | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index c7b7682ec..be512abcb 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -22,6 +22,10 @@ {{ $t('gdd_per_link.copy') }} + + + {{ $t('gdd_per_link.copy-with-text') }} + { + this.$bvModal.show('modalPopoverCopyError' + this.id) + this.toastError(this.$t('gdd_per_link.not-copied')) + }) + }, deleteLink() { this.$bvModal.msgBoxConfirm(this.$t('gdd_per_link.delete-the-link')).then(async (value) => { if (value) From 92eb144faa3d04a52ed903248c969d8a07225628 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 07:27:46 +0200 Subject: [PATCH 03/36] fix linting --- .../TransactionLinks/TransactionLink.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index be512abcb..75c57a160 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -107,13 +107,17 @@ export default { navigator.clipboard .writeText( `${this.link}\n` + - `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido.\n` + - `\"${this.memo}\"\n` + - `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', {date: this.$d(new Date(this.validUntil), 'short')})}` - ) - .then( + `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ + this.amount + } Gradido.\n` + + `"${this.memo}"\n` + + `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( + 'gdd_per_link.validUntilDate', { + date: this.$d(new Date(this.validUntil), 'short')}) + }`) + .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) - ) + }) .catch(() => { this.$bvModal.show('modalPopoverCopyError' + this.id) this.toastError(this.$t('gdd_per_link.not-copied')) From 5019a7c48f0c6b9ce8c47fb29b9891c5633d4349 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 07:40:50 +0200 Subject: [PATCH 04/36] sort 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 4db32e369..2c97d71aa 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -135,8 +135,8 @@ "has-account": "Du besitzt bereits ein Gradido Konto?", "header": "Gradidos versenden per Link", "isFree": "Gradido ist weltweit kostenfrei.", - "link-copied": "Link wurde in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", "link-and-text-copied": "Der Link und deine Nachricht wurden in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", + "link-copied": "Link wurde in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", "link-deleted": "Der Link wurde am {date} gelöscht.", "link-expired": "Der Link ist nicht mehr gültig. Die Gültigkeit ist am {date} abgelaufen.", "link-overview": "Linkübersicht", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index db409ff54..163bbd091 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -135,8 +135,8 @@ "has-account": "You already have a Gradido account?", "header": "Send Gradidos via link", "isFree": "Gradido is free of charge worldwide.", - "link-copied": "Link has been copied to the clipboard. You can now paste it into an email or message.", "link-and-text-copied": "The link and your message have been copied to the clipboard. You can now include it in an email or message.", + "link-copied": "Link has been copied to the clipboard. You can now paste it into an email or message.", "link-deleted": "The link was deleted on {date}.", "link-expired": "The link is no longer valid. The validity expired on {date}.", "link-overview": "Link overview", From 20e2e0edea4993cfa633e4f29b6db0ff042b5a69 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:01:28 +0200 Subject: [PATCH 05/36] Update frontend/src/components/TransactionLinks/TransactionLink.vue Co-authored-by: Alexander Friedland --- .../TransactionLinks/TransactionLink.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 75c57a160..f0836aa2a 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -106,15 +106,15 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link}\n` + - `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ - this.amount - } Gradido.\n` + - `"${this.memo}"\n` + - `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( - 'gdd_per_link.validUntilDate', { - date: this.$d(new Date(this.validUntil), 'short')}) - }`) + ``${this.link} + ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ + this.amount + }. Gradido + "${this.memo}" + ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( + 'gdd_per_link.validUntilDate', + { date: this.$d(new Date(this.validUntil), 'short') }, + )}`) .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) }) From fe4a95e32de278ec45cd9626175f3d03ff6117e4 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:05:24 +0200 Subject: [PATCH 06/36] Update frontend/src/locales/de.json Co-authored-by: Alexander Friedland --- frontend/src/locales/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 2c97d71aa..dbe029082 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -127,7 +127,7 @@ "copy": "kopieren", "copy-with-text": "Link und Text kopieren", "created": "Der Link wurde erstellt!", - "credit-your-gradido": "Um deine Gradido gutzuschreiben, klicke auf den Link!", + "credit-your-gradido": "Damit die Gradido gutgeschrieben werden können, klicke auf den Link!", "decay-14-day": "Vergänglichkeit für 14 Tage", "delete-the-link": "Den Link löschen?", "deleted": "Der Link wurde gelöscht!", From b8ba6af90615a3af65aed906e53ffa333d7a9bba Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:05:59 +0200 Subject: [PATCH 07/36] Update frontend/src/components/TransactionLinks/TransactionLink.vue Co-authored-by: Alexander Friedland --- frontend/src/components/TransactionLinks/TransactionLink.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index f0836aa2a..1cebf697d 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -22,7 +22,7 @@ {{ $t('gdd_per_link.copy') }} - + {{ $t('gdd_per_link.copy-with-text') }} From 74a6c22f6faffb879097ccf076363e8a20bae90e Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:06:32 +0200 Subject: [PATCH 08/36] Update frontend/src/locales/de.json Co-authored-by: Alexander Friedland --- frontend/src/locales/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index dbe029082..62160ec9d 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -153,7 +153,7 @@ "to-login": "Log dich ein", "to-register": "Registriere ein neues Konto.", "validUntil": "Gültig bis", - "validUntilDate": "Sie sind bis zum {date} gültig." + "validUntilDate": "Der Link ist bis zum {date} gültig." }, "gdt": { "calculation": "Berechnung der Gradido Transform", From 38d9e276acd6b58386de4d9f0e3613c81dc9dd37 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:06:52 +0200 Subject: [PATCH 09/36] Update frontend/src/locales/en.json Co-authored-by: Alexander Friedland --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 163bbd091..36a695e86 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -153,7 +153,7 @@ "to-login": "Log in", "to-register": "Register a new account.", "validUntil": "Valid until", - "validUntilDate": "They are valid until {date}." + "validUntilDate": "The link is valid until {date}." }, "gdt": { "calculation": "Calculation of Gradido Transform", From 6c856c8a92898d5e34c7f4df93b9d250c8ea2fc4 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:12:37 +0200 Subject: [PATCH 10/36] Update frontend/src/locales/en.json Co-authored-by: Alexander Friedland --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 36a695e86..735ae28bd 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -127,7 +127,7 @@ "copy": "copy", "copy-with-text": "copy link and text", "created": "Link was created!", - "credit-your-gradido": "To credit your Gradido, click on the link!", + "credit-your-gradido": "For the Gradido to be credited, click on the link!", "decay-14-day": "Decay for 14 days", "delete-the-link": "Delete the link?", "deleted": "The link was deleted!", From e8b70608e90e52eb619db4756595cbc1ff82d114 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 5 Jul 2022 09:34:32 +0200 Subject: [PATCH 11/36] double apostrophe removed, fix yarn lint --- .../TransactionLinks/TransactionLink.vue | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 1cebf697d..1476c3be6 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -22,7 +22,11 @@ {{ $t('gdd_per_link.copy') }} - + {{ $t('gdd_per_link.copy-with-text') }} @@ -106,7 +110,7 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - ``${this.link} + `${this.link} ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ this.amount }. Gradido @@ -114,11 +118,12 @@ export default { ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( 'gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') }, - )}`) - .then(() => { - this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) - }) - .catch(() => { + )}`, + ) + .then(() => { + this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) + }) + .catch(() => { this.$bvModal.show('modalPopoverCopyError' + this.id) this.toastError(this.$t('gdd_per_link.not-copied')) }) From 4274974207a4c61640be98414e1d3edf3d8d60a2 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 10:36:44 +0200 Subject: [PATCH 12/36] reformat string to avoid unwanted indents --- .../components/TransactionLinks/TransactionLink.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 1476c3be6..b9256331e 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -110,12 +110,12 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link} - ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ + `${this.link}\n` + + `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ this.amount - }. Gradido - "${this.memo}" - ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( + } Gradido.\n` + + `"${this.memo}"\n`+ + `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( 'gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') }, )}`, From a61df84a398728995bb3315cc786d7d3add8cada Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 10:37:17 +0200 Subject: [PATCH 13/36] add unit tests for new feature --- .../TransactionLinks/TransactionLink.spec.js | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 13aaea900..2f9c91337 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -25,6 +25,7 @@ const propsData = { link: 'http://localhost/redeem/c00000000c000000c0000', holdAvailableAmount: '5.13109484759482747111', id: 12, + firstname: 'Testy' memo: 'Katzenauge, Eulenschrei, was verschwunden komm herbei!', validUntil: '2022-03-30T14:22:40.000Z', } @@ -77,7 +78,7 @@ describe('TransactionLink', () => { navigator.clipboard = navigatorClipboard }) - describe('copy with success', () => { + describe('copy link with success', () => { beforeEach(async () => { navigatorClipboardMock.mockResolvedValue() await wrapper.find('.test-copy-link .dropdown-item').trigger('click') @@ -93,7 +94,26 @@ describe('TransactionLink', () => { }) }) - describe('copy with error', () => { + describe('copy link and text with success', () => { + beforeEach(async () => { + navigatorClipboardMock.mockResolvedValue() + await wrapper.find('.test-copy-text .dropdown-item').trigger('click') + }) + + it('should call clipboard.writeText', () => { + expect(navigator.clipboard.writeText).toHaveBeenCalledWith( + `http://localhost/redeem/c00000000c000000c0000\n + Testy wants to send you 75 Gradido.\n + "Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n + For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.`, + ) + }) + it('toasts success message', () => { + expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-copied') + }) + }) + + describe('copy link with error', () => { beforeEach(async () => { navigatorClipboardMock.mockRejectedValue() await wrapper.find('.test-copy-link .dropdown-item').trigger('click') @@ -103,6 +123,17 @@ describe('TransactionLink', () => { expect(toastErrorSpy).toBeCalledWith('gdd_per_link.not-copied') }) }) + + describe('copy link and text with error', () => { + beforeEach(async () => { + navigatorClipboardMock.mockRejectedValue() + await wrapper.find('.test-copy-text .dropdown-item').trigger('click') + }) + + it('toasts an error', () => { + expect(toastErrorSpy).toBeCalledWith('gdd_per_link.not-copied') + }) + }) }) describe('qr code modal', () => { From 45e7fecd3979774c2c19a02e03217a4ece328838 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 10:47:16 +0200 Subject: [PATCH 14/36] fix unit test --- .../src/components/TransactionLinks/TransactionLink.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 2f9c91337..d0abe462d 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -25,7 +25,7 @@ const propsData = { link: 'http://localhost/redeem/c00000000c000000c0000', holdAvailableAmount: '5.13109484759482747111', id: 12, - firstname: 'Testy' + firstname: 'Testy', memo: 'Katzenauge, Eulenschrei, was verschwunden komm herbei!', validUntil: '2022-03-30T14:22:40.000Z', } From 794bcbdfa37e831c4872ed4bc0e6e9088f33623e Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:20:48 +0200 Subject: [PATCH 15/36] update unit test --- .../TransactionLinks/TransactionLink.spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index d0abe462d..469a8377e 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -102,14 +102,14 @@ describe('TransactionLink', () => { it('should call clipboard.writeText', () => { expect(navigator.clipboard.writeText).toHaveBeenCalledWith( - `http://localhost/redeem/c00000000c000000c0000\n - Testy wants to send you 75 Gradido.\n - "Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n - For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.`, + 'http://localhost/redeem/c00000000c000000c0000\n' + + 'Testy wants to send you 75 Gradido.\n' + + '"Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n' + + 'For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.', ) }) it('toasts success message', () => { - expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-copied') + expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-and-text-copied') }) }) From 7d9253e4c7ae00ea058660ba8f6be277437db68e Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:49:52 +0200 Subject: [PATCH 16/36] Update frontend/src/components/TransactionLinks/TransactionLink.vue Co-authored-by: Moriz Wahl --- .../components/TransactionLinks/TransactionLink.vue | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index b9256331e..b7dc03db5 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -110,15 +110,10 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link}\n` + - `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ - this.amount - } Gradido.\n` + - `"${this.memo}"\n`+ - `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( - 'gdd_per_link.validUntilDate', - { date: this.$d(new Date(this.validUntil), 'short') }, - )}`, + `${this.link}\n +${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. +"${this.memo}" +${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') })}`, ) .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) From ca8732bd750317fe853c29a5530f89d58d6c42ff Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:50:52 +0200 Subject: [PATCH 17/36] Update frontend/src/locales/en.json Co-authored-by: Moriz Wahl --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 735ae28bd..088a006a7 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -125,7 +125,7 @@ "gdd_per_link": { "choose-amount": "Select an amount that you would like to send via link. You can also enter a message. Click 'Generate now' to create a link that you can share.", "copy": "copy", - "copy-with-text": "copy link and text", + "copy-with-text": "Copy link and text", "created": "Link was created!", "credit-your-gradido": "For the Gradido to be credited, click on the link!", "decay-14-day": "Decay for 14 days", From a9a518c9bbbe2fe882f8f87f48085227d3d5d48d Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:59:32 +0200 Subject: [PATCH 18/36] fix linting errors --- frontend/src/components/TransactionLinks/TransactionLink.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index b7dc03db5..d5491835c 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -113,7 +113,9 @@ export default { `${this.link}\n ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. "${this.memo}" -${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') })}`, +${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { + date: this.$d(new Date(this.validUntil), 'short'), + })}`, ) .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) From e4a4744f4e4be78367ed5128410709be95ad1ef0 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 5 Jul 2022 12:30:46 +0200 Subject: [PATCH 19/36] fix unit tests --- .../TransactionLinks/TransactionLink.spec.js | 15 ++++++++------- .../TransactionLinks/TransactionLink.vue | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 469a8377e..50f1588d7 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -9,15 +9,16 @@ const mockAPIcall = jest.fn() const navigatorClipboardMock = jest.fn() const mocks = { - $i18n: { - locale: 'en', - }, $t: jest.fn((t) => t), $d: jest.fn((d) => d), - $tc: jest.fn((tc) => tc), $apollo: { mutate: mockAPIcall, }, + $store: { + state: { + firstName: 'Testy', + }, + }, } const propsData = { @@ -103,9 +104,9 @@ describe('TransactionLink', () => { it('should call clipboard.writeText', () => { expect(navigator.clipboard.writeText).toHaveBeenCalledWith( 'http://localhost/redeem/c00000000c000000c0000\n' + - 'Testy wants to send you 75 Gradido.\n' + - '"Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n' + - 'For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.', + 'Testy transaction-link.send_you 75 Gradido.\n' + + '"Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n' + + 'gdd_per_link.credit-your-gradido gdd_per_link.validUntilDate', ) }) it('toasts success message', () => { diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index d5491835c..5618c8696 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -110,7 +110,7 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link}\n + `${this.link} ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. "${this.memo}" ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { From 6b3813a0c8ee52087e48e57791bc22b26c69600a Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Tue, 5 Jul 2022 17:09:31 +0200 Subject: [PATCH 20/36] add code for moving user creation date if transaction before exist --- .../0042-move_users_creation_date.ts | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 database/migrations/0042-move_users_creation_date.ts diff --git a/database/migrations/0042-move_users_creation_date.ts b/database/migrations/0042-move_users_creation_date.ts new file mode 100644 index 000000000..27353a5b4 --- /dev/null +++ b/database/migrations/0042-move_users_creation_date.ts @@ -0,0 +1,130 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +/* +Move forward the creation date of the users by 1 or 2 hours, +for which there are transactions created before their account creation. + +Because of a error by importing data from old db format into new, all older transactions balance_date +are 1 or 2 hours off + +*/ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + /* generate raw mysql queries + const usersToMove = await queryFn( + ` + SELECT u.id, u.created, t.balance_date + FROM \`users\` as u + LEFT JOIN \`transactions\` as t + ON t.user_id = u.id where t.balance_date < u.created + order by id + ` + ) + let downgradeQueries = '' + for(const id in usersToMove) { + const user = usersToMove[id] + const diff = (user.created - user.balance_date) / 1000 + const correcture = diff < 3600 ? 1: 2 + const correctedDate = new Date(user.created) + correctedDate.setHours(correctedDate.getHours() - correcture) + //console.log("%d, %s, %s, %s, %d", user.id, user.created, user.balance_date, diff, correcture) + console.log('await queryFn(`UPDATE \\`users\\` SET \\`created\\` = \'%s\' WHERE \\`id\\` = %d`)', + correctedDate.toISOString().slice(0, 19).replace('T', ' '), + user.id + ) + downgradeQueries += 'await queryFn(`UPDATE \\`users\\` SET \\`created\\` = \'' + downgradeQueries += user.created.toISOString().slice(0, 19).replace('T', ' ') + downgradeQueries += '\' WHERE \\`id\\` = ' + downgradeQueries += user.id + downgradeQueries += '`)\n' + } + console.log('downgrade: \n%s', downgradeQueries) + */ + + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-01-25 08:01:52' WHERE \`id\` = 179`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-05-26 10:21:57' WHERE \`id\` = 443`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-08 17:04:41' WHERE \`id\` = 490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-12 20:07:17' WHERE \`id\` = 508`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-07-17 19:20:36' WHERE \`id\` = 621`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-11-22 16:31:48' WHERE \`id\` = 788`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-12-17 20:09:16' WHERE \`id\` = 825`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-01-26 13:09:35' WHERE \`id\` = 949`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-03-20 16:55:46' WHERE \`id\` = 1057`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 15:59:30' WHERE \`id\` = 1228`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-17 22:51:19' WHERE \`id\` = 1239`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-03 07:23:28' WHERE \`id\` = 1273`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-09 06:16:18' WHERE \`id\` = 1287`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-17 11:26:41' WHERE \`id\` = 1298`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 15:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 15:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 15:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 07:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 07:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-13 12:07:29' WHERE \`id\` = 1342`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-16 15:32:48' WHERE \`id\` = 1348`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-09-30 14:06:40' WHERE \`id\` = 1470`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-15 14:35:37' WHERE \`id\` = 1490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 06:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 06:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-22 09:45:15' WHERE \`id\` = 1576`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-23 13:55:37' WHERE \`id\` = 1582`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 14:58:12' WHERE \`id\` = 1729`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 18:03:10' WHERE \`id\` = 1732`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 15:00:38' WHERE \`id\` = 1756`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 20:01:58' WHERE \`id\` = 1757`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-21 15:58:48' WHERE \`id\` = 1762`) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-01-25 09:01:52' WHERE \`id\` = 179`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-05-26 11:21:57' WHERE \`id\` = 443`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-08 19:04:41' WHERE \`id\` = 490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-12 22:07:17' WHERE \`id\` = 508`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-07-17 21:20:36' WHERE \`id\` = 621`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-11-22 17:31:48' WHERE \`id\` = 788`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-12-17 21:09:16' WHERE \`id\` = 825`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-01-26 14:09:35' WHERE \`id\` = 949`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-03-20 17:55:46' WHERE \`id\` = 1057`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:59:30' WHERE \`id\` = 1228`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-18 00:51:19' WHERE \`id\` = 1239`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-03 09:23:28' WHERE \`id\` = 1273`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-09 08:16:18' WHERE \`id\` = 1287`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-17 13:26:41' WHERE \`id\` = 1298`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 17:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 17:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 17:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 09:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 09:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-13 14:07:29' WHERE \`id\` = 1342`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-16 16:32:48' WHERE \`id\` = 1348`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-09-30 16:06:40' WHERE \`id\` = 1470`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-15 16:35:37' WHERE \`id\` = 1490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 08:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 08:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-22 10:45:15' WHERE \`id\` = 1576`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-23 14:55:37' WHERE \`id\` = 1582`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 15:58:12' WHERE \`id\` = 1729`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 19:03:10' WHERE \`id\` = 1732`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 16:00:38' WHERE \`id\` = 1756`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 21:01:58' WHERE \`id\` = 1757`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-21 16:58:48' WHERE \`id\` = 1762`) +} From 9272ca87cd92218e694eea032cef1d24b18c9375 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 6 Jul 2022 11:39:59 +0200 Subject: [PATCH 21/36] fix unit test --- frontend/src/components/TransactionLinks/TransactionLink.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 50f1588d7..d06f0f726 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -26,7 +26,6 @@ const propsData = { link: 'http://localhost/redeem/c00000000c000000c0000', holdAvailableAmount: '5.13109484759482747111', id: 12, - firstname: 'Testy', memo: 'Katzenauge, Eulenschrei, was verschwunden komm herbei!', validUntil: '2022-03-30T14:22:40.000Z', } From ca84fc3bae8d9c0943cafa5a6d6f6589db1530cd Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Jul 2022 07:42:39 +0200 Subject: [PATCH 22/36] change text from page --- frontend/src/components/Auth/AuthMobileStart.vue | 2 +- frontend/src/locales/de.json | 3 +-- frontend/src/locales/en.json | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Auth/AuthMobileStart.vue b/frontend/src/components/Auth/AuthMobileStart.vue index 09985dd77..690b8f895 100644 --- a/frontend/src/components/Auth/AuthMobileStart.vue +++ b/frontend/src/components/Auth/AuthMobileStart.vue @@ -6,7 +6,7 @@ {{ $t('auth.left.gratitude') }}
- {{ $t('auth.left.newCurrency') }} + {{ $t('auth.left.oneGratitude') }}
Date: Sun, 10 Jul 2022 08:39:25 +0200 Subject: [PATCH 23/36] finalize --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index aa4197a43..1f355623c 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0040-add_contribution_link_id_to_user', + DB_VERSION: '0042-move_users_creation_date', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From 971473965afed6642ddabdf5dc6102dec882e759 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 11 Jul 2022 10:59:27 +0200 Subject: [PATCH 24/36] Update en.json --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 4271e85f8..0bfde65ed 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -14,7 +14,7 @@ "learnMore": "Learn more …", "oneDignity": "We gift to each other and give thanks with Gradido.", "oneDonation": "You are a gift for the community. 1000 thanks because you are with us.", - "oneGratitude": "The new currency. For each other, for all people, for nature." + "oneGratitude": "For each other, for all people, for nature." }, "navbar": { "aboutGradido": "About Gradido" From 3718f0dc56ef3d0363c2911bca6c4da9891f3959 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 11:42:24 +0200 Subject: [PATCH 25/36] Change the test so that we can test if the contribution list finds only created but not confirmed contribution --- .../resolver/ContributionResolver.test.ts | 91 ++++++++++++------- backend/src/seeds/graphql/mutations.ts | 1 + backend/src/seeds/graphql/queries.ts | 1 + 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 2308cd4e7..01ece7440 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,6 +13,7 @@ import { peterLustig } from '@/seeds/users/peter-lustig' let mutate: any, query: any, con: any let testEnv: any +let result: any beforeAll(async () => { testEnv = await testEnvironment() @@ -114,6 +115,7 @@ describe('ContributionResolver', () => { expect.objectContaining({ data: { createContribution: { + id: expect.any(Number), amount: '100', memo: 'Test env contribution', }, @@ -148,25 +150,22 @@ describe('ContributionResolver', () => { describe('authenticated', () => { beforeAll(async () => { - await userFactory(testEnv, peterLustig) await userFactory(testEnv, bibiBloxberg) - // bibi needs GDDs - const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await creationFactory(testEnv, bibisCreation!) - // await userFactory(testEnv, bibiBloxberg) await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, }) + await mutate({ + mutation: createContribution, + variables: { + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }) }) - afterAll(async () => { - await cleanDB() - resetToken() - }) - - it('returns an empty array for unconfirmed creation filter', async () => { + it('returns only unconfirmed creations', async () => { await expect( query({ query: listContributions, @@ -177,39 +176,63 @@ describe('ContributionResolver', () => { filterConfirmed: true, }, }), - ).resolves.toEqual( - expect.objectContaining({ - data: { - listContributions: [], - }, - }), - ) - }) - - it('returns confirmed creation', async () => { - await expect( - query({ - query: listContributions, - variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: false, - }, - }), ).resolves.toEqual( expect.objectContaining({ data: { listContributions: expect.arrayContaining([ expect.objectContaining({ - memo: 'Herzlich Willkommen bei Gradido!', - amount: '1000', + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', }), ]), }, }), ) }) + + describe('Adding confirmed creations', () => { + beforeAll(async () => { + await userFactory(testEnv, peterLustig) + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + await creationFactory(testEnv, bibisCreation!) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + it('returns confirmed and unconfirmed creation', async () => { + await expect( + query({ + query: listContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listContributions: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }), + ) + }) + }) }) }) }) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 4926f706f..185485f2c 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -234,6 +234,7 @@ export const deleteContributionLink = gql` export const createContribution = gql` mutation ($amount: Decimal!, $memo: String!, $creationDate: String!) { createContribution(amount: $amount, memo: $memo, creationDate: $creationDate) { + id amount memo } diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index cf0fd09bd..c27ecdd66 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -185,6 +185,7 @@ export const listContributions = gql` order: $order filterConfirmed: $filterConfirmed ) { + id amount memo } From a2eccb12ed5b2e421d3ee8fd328afcc94c4def13 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 11:42:39 +0200 Subject: [PATCH 26/36] Change the variable name contribution to contributions. --- backend/src/graphql/resolver/ContributionResolver.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 59f1f359f..0925fac9c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -48,9 +48,9 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const user = getUser(context) - let contribution + let contributions if (filterConfirmed) { - contribution = await dbContribution.find({ + contributions = await dbContribution.find({ where: { userId: user.id, confirmedBy: IsNull(), @@ -62,7 +62,7 @@ export class ContributionResolver { take: pageSize, }) } else { - contribution = await dbContribution.find({ + contributions = await dbContribution.find({ where: { userId: user.id, }, @@ -73,6 +73,6 @@ export class ContributionResolver { take: pageSize, }) } - return contribution.map((contr) => new Contribution(contr, new User(user))) + return contributions.map((contribution) => new Contribution(contribution, new User(user))) } } From ae52b520dd0288e08f1fff35d461687bf3b96446 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 12:04:46 +0200 Subject: [PATCH 27/36] Withdrew where clause to an variable with inline condition. --- .../graphql/resolver/ContributionResolver.ts | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 0925fac9c..acf1b4cb0 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -48,31 +48,22 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const user = getUser(context) - let contributions - if (filterConfirmed) { - contributions = await dbContribution.find({ - where: { + const where = filterConfirmed + ? { userId: user.id, confirmedBy: IsNull(), - }, - order: { - createdAt: order, - }, - skip: (currentPage - 1) * pageSize, - take: pageSize, - }) - } else { - contributions = await dbContribution.find({ - where: { + } + : { userId: user.id, - }, - order: { - createdAt: order, - }, - skip: (currentPage - 1) * pageSize, - take: pageSize, - }) - } + } + const contributions = await dbContribution.find({ + where, + order: { + createdAt: order, + }, + skip: (currentPage - 1) * pageSize, + take: pageSize, + }) return contributions.map((contribution) => new Contribution(contribution, new User(user))) } } From 9239f93096afe579bc1f2a0cc0b44bed1d730d7f Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 12:21:51 +0200 Subject: [PATCH 28/36] Add no non nullable assertion to admin Creation. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 01ece7440..fcaaca11a 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,7 +13,6 @@ import { peterLustig } from '@/seeds/users/peter-lustig' let mutate: any, query: any, con: any let testEnv: any -let result: any beforeAll(async () => { testEnv = await testEnvironment() @@ -195,6 +194,7 @@ describe('ContributionResolver', () => { beforeAll(async () => { await userFactory(testEnv, peterLustig) const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion await creationFactory(testEnv, bibisCreation!) await query({ query: login, From caf4e9ae3e627cc6440636edf720cedd51fa51ec Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:04:38 +0200 Subject: [PATCH 29/36] Change the test name to filterConfirmed is false. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index fcaaca11a..1e3034b59 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -202,7 +202,7 @@ describe('ContributionResolver', () => { }) }) - it('returns confirmed and unconfirmed creation', async () => { + it('filter confirmed is false', async () => { await expect( query({ query: listContributions, From 2113061629310c0eee75049f300af42ba79bdaa1 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:05:57 +0200 Subject: [PATCH 30/36] Change the imports to the standard. --- .../src/graphql/resolver/ContributionResolver.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index acf1b4cb0..a54a5e6bf 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -3,13 +3,13 @@ import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' -import { IsNull } from '../../../../database/node_modules/typeorm' -import ContributionArgs from '../arg/ContributionArgs' -import Paginated from '../arg/Paginated' -import { Order } from '../enum/Order' -import { Contribution } from '../model/Contribution' -import { UnconfirmedContribution } from '../model/UnconfirmedContribution' -import { User } from '../model/User' +import { IsNull } from '@dbTools/typeorm' +import ContributionArgs from '@arg/ContributionArgs' +import Paginated from '@arg/Paginated' +import { Order } from '@enum/Order' +import { Contribution } from '@model/Contribution' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { User } from '@model/User' import { validateContribution, getUserCreation } from './util/creations' @Resolver() From f8cdad7e58bfb232d7780543974a6f39787fadfd Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:07:57 +0200 Subject: [PATCH 31/36] Change the where clause to a defined object. --- .../src/graphql/resolver/ContributionResolver.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index a54a5e6bf..3e13c404c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -3,7 +3,7 @@ import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' -import { IsNull } from '@dbTools/typeorm' +import { FindOperator, IsNull } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import { Order } from '@enum/Order' @@ -48,14 +48,11 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const user = getUser(context) - const where = filterConfirmed - ? { - userId: user.id, - confirmedBy: IsNull(), - } - : { - userId: user.id, - } + const where: { + userId: number + confirmedBy?: FindOperator | null + } = { userId: user.id } + if (filterConfirmed) where.confirmedBy = IsNull() const contributions = await dbContribution.find({ where, order: { From 70db65044cfd5bf3bb42cce63968257616f1f1ed Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:09:40 +0200 Subject: [PATCH 32/36] Fix linting. --- backend/src/graphql/resolver/ContributionResolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 3e13c404c..41f6c9cd4 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -50,6 +50,7 @@ export class ContributionResolver { const user = getUser(context) const where: { userId: number + // eslint-disable-next-line @typescript-eslint/no-explicit-any confirmedBy?: FindOperator | null } = { userId: user.id } if (filterConfirmed) where.confirmedBy = IsNull() From 6d4d03013602569ce8543227bb324c9610a9220e Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Mon, 11 Jul 2022 15:08:41 +0200 Subject: [PATCH 33/36] exchanged order with other migration --- backend/src/config/index.ts | 2 +- ..._users_creation_date.ts => 0041-move_users_creation_date.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename database/migrations/{0042-move_users_creation_date.ts => 0041-move_users_creation_date.ts} (100%) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 1f355623c..490ac0121 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0042-move_users_creation_date', + DB_VERSION: '0041-move_users_creation_date', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/database/migrations/0042-move_users_creation_date.ts b/database/migrations/0041-move_users_creation_date.ts similarity index 100% rename from database/migrations/0042-move_users_creation_date.ts rename to database/migrations/0041-move_users_creation_date.ts From 339b32a02f76d41eb10d49934c16d7c8cb31a94f Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 17:16:31 +0200 Subject: [PATCH 34/36] Change FindOperator to --- backend/src/graphql/resolver/ContributionResolver.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 41f6c9cd4..4424b40d0 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -50,8 +50,7 @@ export class ContributionResolver { const user = getUser(context) const where: { userId: number - // eslint-disable-next-line @typescript-eslint/no-explicit-any - confirmedBy?: FindOperator | null + confirmedBy?: FindOperator | null } = { userId: user.id } if (filterConfirmed) where.confirmedBy = IsNull() const contributions = await dbContribution.find({ From b6f1b0730a51dcfc6c8a97a84b021cadd0644bbf Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 08:44:36 +0200 Subject: [PATCH 35/36] Change the orders and structure from the tests for listContributions. --- .../resolver/ContributionResolver.test.ts | 75 +++++++++---------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 1e3034b59..b3d6aeb3c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -150,6 +150,10 @@ describe('ContributionResolver', () => { describe('authenticated', () => { beforeAll(async () => { await userFactory(testEnv, bibiBloxberg) + await userFactory(testEnv, peterLustig) + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + await creationFactory(testEnv, bibisCreation!) await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, @@ -163,46 +167,9 @@ describe('ContributionResolver', () => { }, }) }) - - it('returns only unconfirmed creations', async () => { - await expect( - query({ - query: listContributions, - variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: true, - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - data: { - listContributions: expect.arrayContaining([ - expect.objectContaining({ - id: expect.any(Number), - memo: 'Test env contribution', - amount: '100', - }), - ]), - }, - }), - ) - }) - - describe('Adding confirmed creations', () => { - beforeAll(async () => { - await userFactory(testEnv, peterLustig) - const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await creationFactory(testEnv, bibisCreation!) - await query({ - query: login, - variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, - }) - }) - - it('filter confirmed is false', async () => { + + describe('filter confirmed is false', () => { + it('returns creations', async () => { await expect( query({ query: listContributions, @@ -233,6 +200,34 @@ describe('ContributionResolver', () => { ) }) }) + + describe('filter confirmed is true', () => { + it('returns only unconfirmed creations', async () => { + await expect( + query({ + query: listContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: true, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listContributions: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }), + ) + }) + }) }) }) }) From 0e13c7c2e12a66e6cbd41c1e6a167e6f5d32046c Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 08:47:15 +0200 Subject: [PATCH 36/36] Remove spaces. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index b3d6aeb3c..9b0f6a3bc 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -167,7 +167,7 @@ describe('ContributionResolver', () => { }, }) }) - + describe('filter confirmed is false', () => { it('returns creations', async () => { await expect(