From eb404cf8b3e0d106f18a12883a00bccb4e9dfc57 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 13 Jul 2022 14:30:46 +0200 Subject: [PATCH 01/68] add migrations to insert contributions to all transactions with type creation that do not have a contribution yet --- .../0043-insert_missing_contributions.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/migrations/0043-insert_missing_contributions.ts diff --git a/database/migrations/0043-insert_missing_contributions.ts b/database/migrations/0043-insert_missing_contributions.ts new file mode 100644 index 000000000..a14141498 --- /dev/null +++ b/database/migrations/0043-insert_missing_contributions.ts @@ -0,0 +1,34 @@ +/* MIGRATION TO INSERT contributions for all transactions with type creation that do not have a contribution yet */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + `INSERT INTO gradido_community.contributions + (user_id, created_at, contribution_date, memo, amount, moderator_id, confirmed_by, confirmed_at, transaction_id) +SELECT + user_id, + balance_date, + creation_date AS contribution_date, + memo, + amount, + 20 AS moderator_id, + 502 AS confirmed_by, + balance_date AS confirmed_at, + id +FROM + gradido_community.transactions +WHERE + type_id = 1 + AND NOT EXISTS( + SELECT * FROM gradido_community.contributions + WHERE gradido_community.contributions.transaction_id = gradido_community.transactions.id);`, + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'DELETE FROM `contributions` WHERE `contributions`.`moderator_id` = 20 AND `contributions`.`confirmed_by` = 502 AND `contributions`.`created_at` = `contributions`.`confirmed_at`;', + ) +} From bdcbb196b77fc16cd165e898c7d54bf9b5aef6f1 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 13 Jul 2022 14:31:31 +0200 Subject: [PATCH 02/68] update database version --- 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 8b84c059d..208425792 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0042-update_transactions_for_blockchain', + DB_VERSION: '0043-insert_missing_contributions', 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 af9d874fea27cdb1e69bf83a9b635686d6a7f53a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 25 Jul 2022 13:29:45 +0200 Subject: [PATCH 03/68] fix: Update contribution_date when Moved by Seed --- backend/src/seeds/factory/creation.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/seeds/factory/creation.ts b/backend/src/seeds/factory/creation.ts index 75a765fae..d3f0f78ca 100644 --- a/backend/src/seeds/factory/creation.ts +++ b/backend/src/seeds/factory/creation.ts @@ -35,12 +35,17 @@ export const creationFactory = async ( if (creation.confirmed) { await mutate({ mutation: confirmContribution, variables: { id: pendingCreation.id } }) + const confirmedCreation = await Contribution.findOneOrFail({ id: pendingCreation.id }) + if (creation.moveCreationDate) { const transaction = await Transaction.findOneOrFail({ where: { userId: user.id, creationDate: new Date(creation.creationDate) }, order: { balanceDate: 'DESC' }, }) if (transaction.decay.equals(0) && transaction.creationDate) { + confirmedCreation.contributionDate = new Date( + nMonthsBefore(transaction.creationDate, creation.moveCreationDate), + ) transaction.creationDate = new Date( nMonthsBefore(transaction.creationDate, creation.moveCreationDate), ) @@ -48,6 +53,7 @@ export const creationFactory = async ( nMonthsBefore(transaction.balanceDate, creation.moveCreationDate), ) await transaction.save() + await confirmedCreation.save() } } } else { From ae6fdd51e97c448f99efd7ee1d0a6f46c58aa1a1 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 25 Jul 2022 14:00:26 +0200 Subject: [PATCH 04/68] use camel case instead of snake case for edit creation field --- admin/src/components/Tables/OpenCreationsTable.spec.js | 2 +- admin/src/components/Tables/OpenCreationsTable.vue | 2 +- admin/src/pages/CreationConfirm.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 2b41a9b96..05f4506d0 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -66,7 +66,7 @@ const propsData = { }, }, { key: 'moderator', label: 'moderator' }, - { key: 'edit_creation', label: 'edit' }, + { key: 'editCreation', label: 'edit' }, { key: 'confirm', label: 'save' }, ], toggleDetails: false, diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index 1e61f00b0..dd9ee5015 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -11,7 +11,7 @@ -
@@ -145,6 +150,8 @@ export default { .then((result) => { this.$emit('set-tunneled-email', null) this.link = result.data.createTransactionLink.link + this.amount = this.transactionData.amount + this.memo = this.transactionData.memo this.transactionData = { ...EMPTY_TRANSACTION_DATA } this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink this.updateTransactions({}) From 21c9bc22a710febd6d5d61aa5f43a11933981da5 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 27 Jul 2022 10:13:00 +0200 Subject: [PATCH 38/68] adapt existing unit tests for copying a created transaction link --- frontend/src/pages/Send.spec.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/Send.spec.js b/frontend/src/pages/Send.spec.js index 47a30ff65..79ba65133 100644 --- a/frontend/src/pages/Send.spec.js +++ b/frontend/src/pages/Send.spec.js @@ -20,6 +20,9 @@ describe('Send', () => { balance: 123.45, GdtBalance: 1234.56, pending: true, + amount: '15', + link: 'http://localhost/redeem/0123456789', + memo: 'Quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet.', } const mocks = { @@ -28,6 +31,7 @@ describe('Send', () => { $store: { state: { email: 'sender@example.org', + firstName: 'Testy', }, }, $apollo: { @@ -228,21 +232,26 @@ describe('Send', () => { navigator.clipboard = navigatorClipboard }) - describe('copy with success', () => { + describe('copy link with success', () => { beforeEach(async () => { navigatorClipboardMock.mockResolvedValue() - await wrapper.findAll('button').at(0).trigger('click') + await wrapper.findAll('button').at(1).trigger('click') }) + it('should call clipboard.writeText', () => { + expect(navigator.clipboard.writeText).toHaveBeenCalledWith( + 'http://localhost/redeem/0123456789', + ) + }) it('toasts success message', () => { expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-copied') }) }) - describe('copy with error', () => { + describe('copy link with error', () => { beforeEach(async () => { navigatorClipboardMock.mockRejectedValue() - await wrapper.findAll('button').at(0).trigger('click') + await wrapper.findAll('button').at(1).trigger('click') }) it('toasts error message', () => { @@ -253,7 +262,7 @@ describe('Send', () => { describe('close button click', () => { beforeEach(async () => { - await wrapper.findAll('button').at(2).trigger('click') + await wrapper.findAll('button').at(3).trigger('click') }) it('Shows the TransactionForm', () => { From d1cc3115ba642ae9a20ec6c2af92995f4f050438 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 27 Jul 2022 11:07:58 +0200 Subject: [PATCH 39/68] add unit tests for copying a created transaction link with username, amount and memo text --- frontend/src/pages/Send.spec.js | 43 ++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Send.spec.js b/frontend/src/pages/Send.spec.js index 79ba65133..be63027b1 100644 --- a/frontend/src/pages/Send.spec.js +++ b/frontend/src/pages/Send.spec.js @@ -20,9 +20,6 @@ describe('Send', () => { balance: 123.45, GdtBalance: 1234.56, pending: true, - amount: '15', - link: 'http://localhost/redeem/0123456789', - memo: 'Quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet.', } const mocks = { @@ -260,6 +257,46 @@ describe('Send', () => { }) }) + describe('copy link and text with success', () => { + const navigatorClipboard = navigator.clipboard + beforeAll(() => { + delete navigator.clipboard + navigator.clipboard = { writeText: navigatorClipboardMock } + }) + afterAll(() => { + navigator.clipboard = navigatorClipboard + }) + + describe('copy link and text with success', () => { + beforeEach(async () => { + navigatorClipboardMock.mockResolvedValue() + await wrapper.findAll('button').at(0).trigger('click') + }) + + it('should call clipboard.writeText', () => { + expect(navigator.clipboard.writeText).toHaveBeenCalledWith( + 'http://localhost/redeem/0123456789\n' + + 'Testy transaction-link.send_you 56.78 Gradido.\n' + + '"Make the best of the link!"', + ) + }) + it('toasts success message', () => { + expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-and-text-copied') + }) + }) + + describe('copy link and text with error', () => { + beforeEach(async () => { + navigatorClipboardMock.mockRejectedValue() + await wrapper.findAll('button').at(0).trigger('click') + }) + + it('toasts error message', () => { + expect(toastErrorSpy).toBeCalledWith('gdd_per_link.not-copied') + }) + }) + }) + describe('close button click', () => { beforeEach(async () => { await wrapper.findAll('button').at(3).trigger('click') From 3c539a6edf0a2136470c12c530965462aaaee339 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 27 Jul 2022 11:21:47 +0200 Subject: [PATCH 40/68] make the wording more precise wherever a link can be copied --- frontend/src/components/ClipboardCopy.vue | 4 ++-- frontend/src/components/TransactionLinks/TransactionLink.vue | 4 ++-- frontend/src/locales/de.json | 3 ++- frontend/src/locales/en.json | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/ClipboardCopy.vue b/frontend/src/components/ClipboardCopy.vue index 78af3c772..efddf8ab3 100644 --- a/frontend/src/components/ClipboardCopy.vue +++ b/frontend/src/components/ClipboardCopy.vue @@ -4,10 +4,10 @@ - {{ $t('gdd_per_link.copy-with-text') }} + {{ $t('gdd_per_link.copy-link-with-text') }} - {{ $t('gdd_per_link.copy') }} + {{ $t('gdd_per_link.copy-link') }} diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 5618c8696..fe5e44658 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -20,7 +20,7 @@ - {{ $t('gdd_per_link.copy') }} + {{ $t('gdd_per_link.copy-link') }} - {{ $t('gdd_per_link.copy-with-text') }} + {{ $t('gdd_per_link.copy-link-with-text') }} Date: Wed, 27 Jul 2022 12:17:04 +0200 Subject: [PATCH 41/68] fix linting and locales --- frontend/src/locales/de.json | 1 - frontend/src/locales/en.json | 2 -- 2 files changed, 3 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index aebbffab2..91e602990 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -150,7 +150,6 @@ "GDD": "GDD", "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-link": "Link kopieren", "copy-link-with-text": "Link und Text kopieren", "created": "Der Link wurde erstellt!", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 4ace4e10b..fcd604fea 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -12,7 +12,6 @@ "hasAccount": "You already have an account?", "hereLogin": "Log in here", "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": "For each other, for all people, for nature." @@ -151,7 +150,6 @@ "GDD": "GDD", "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-link": "Copy link", "copy-link-with-text": "Copy link and text", "created": "Link was created!", From dff0853bc7c55813b769e4f63431dc5d011240aa Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 27 Jul 2022 14:38:53 +0200 Subject: [PATCH 42/68] remove member area from menu, if user has no elopage account --- frontend/src/components/Menu/Sidebar.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index b54eb541e..a8850ed18 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -27,12 +27,9 @@
- + {{ $t('navigation.members_area') }} - - {{ $t('math.exclaim') }} - From 2c07ec98ab77f3c04adcdf80e3c42d9bc132a633 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 27 Jul 2022 21:06:49 +0200 Subject: [PATCH 43/68] remove the member area entry from the footer and adjust the unit tests accordingly --- frontend/src/components/ContentFooter.spec.js | 24 ++++--------------- frontend/src/components/ContentFooter.vue | 6 ----- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/ContentFooter.spec.js b/frontend/src/components/ContentFooter.spec.js index f67560e44..c578d3fac 100644 --- a/frontend/src/components/ContentFooter.spec.js +++ b/frontend/src/components/ContentFooter.spec.js @@ -97,24 +97,14 @@ describe('ContentFooter', () => { ) }) - it('has a link to the members area', () => { - expect(wrapper.findAll('a.nav-link').at(2).text()).toEqual('navigation.members_area') - }) - - it('links to the elopage', () => { - expect(wrapper.findAll('a.nav-link').at(2).attributes('href')).toEqual( - 'https://elopage.com/s/gradido/sign_in?locale=en', - ) - }) - it('links to the whitepaper', () => { - expect(wrapper.findAll('a.nav-link').at(3).attributes('href')).toEqual( + expect(wrapper.findAll('a.nav-link').at(2).attributes('href')).toEqual( 'https://docs.google.com/document/d/1kcX1guOi6tDgnFHD9tf7fB_MneKTx-0nHJxzdN8ygNs/edit?usp=sharing', ) }) it('links to the support', () => { - expect(wrapper.findAll('a.nav-link').at(4).attributes('href')).toEqual( + expect(wrapper.findAll('a.nav-link').at(3).attributes('href')).toEqual( 'https://gradido.net/en/contact/', ) }) @@ -142,20 +132,14 @@ describe('ContentFooter', () => { ) }) - it('links to the German elopage when locale is de', () => { - expect(wrapper.findAll('a.nav-link').at(2).attributes('href')).toEqual( - 'https://elopage.com/s/gradido/sign_in?locale=de', - ) - }) - it('links to the German whitepaper when locale is de', () => { - expect(wrapper.findAll('a.nav-link').at(3).attributes('href')).toEqual( + expect(wrapper.findAll('a.nav-link').at(2).attributes('href')).toEqual( 'https://docs.google.com/document/d/1jZp-DiiMPI9ZPNXmjsvOQ1BtnfDFfx8BX7CDmA8KKjY/edit?usp=sharing', ) }) it('links to the German support-page when locale is de', () => { - expect(wrapper.findAll('a.nav-link').at(4).attributes('href')).toEqual( + expect(wrapper.findAll('a.nav-link').at(3).attributes('href')).toEqual( 'https://gradido.net/de/contact/', ) }) diff --git a/frontend/src/components/ContentFooter.vue b/frontend/src/components/ContentFooter.vue index bdcb5b1a9..c563cc23d 100755 --- a/frontend/src/components/ContentFooter.vue +++ b/frontend/src/components/ContentFooter.vue @@ -34,12 +34,6 @@ {{ $t('footer.privacy_policy') }} - - {{ $t('navigation.members_area') }} - { expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.profile') }) - + }) + describe('navigation Navbar (user has an elopage account)', () => { it('has a link to the members area', () => { expect(wrapper.findAll('.nav-item').at(7).text()).toContain('navigation.members_area') expect(wrapper.findAll('.nav-item').at(7).find('a').attributes('href')).toBe( @@ -81,6 +82,18 @@ describe('Navbar', () => { expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.logout') }) }) + describe('navigation Navbar (user has no elopage account)', () => { + beforeAll(() => { + mocks.$store.state.hasElopage = false + wrapper = Wrapper() + }) + it('has first nav-item "navigation.admin_area" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.admin_area') + }) + it('has first nav-item "navigation.logout" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.logout') + }) + }) }) describe('check watch visible true', () => { beforeEach(async () => { diff --git a/frontend/src/components/Menu/Navbar.vue b/frontend/src/components/Menu/Navbar.vue index 2f26f381e..d8fc942fe 100644 --- a/frontend/src/components/Menu/Navbar.vue +++ b/frontend/src/components/Menu/Navbar.vue @@ -57,12 +57,9 @@ {{ $t('navigation.profile') }}
- + {{ $t('navigation.members_area') }} - - {{ $t('math.exclaim') }} - From 7fdba919ca93655d06844c96f9578ee324c2efac Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 27 Jul 2022 22:16:17 +0200 Subject: [PATCH 45/68] fix removal of exclamation mark in navbar --- frontend/src/components/Menu/Navbar.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/src/components/Menu/Navbar.vue b/frontend/src/components/Menu/Navbar.vue index d8fc942fe..1c49a1aa3 100644 --- a/frontend/src/components/Menu/Navbar.vue +++ b/frontend/src/components/Menu/Navbar.vue @@ -60,6 +60,9 @@ {{ $t('navigation.members_area') }} + + {{ $t('math.exclaim') }} + From 67453c8a27ec60ee677e724c6a671aef09d76246 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 27 Jul 2022 22:16:53 +0200 Subject: [PATCH 46/68] remove the member area entry from sidebar menu and adjust the unit tests accordingly --- frontend/src/components/Menu/Sidebar.spec.js | 28 +++++++++++++++----- frontend/src/components/Menu/Sidebar.vue | 10 ++++++- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/Menu/Sidebar.spec.js b/frontend/src/components/Menu/Sidebar.spec.js index f6051c733..dd9511562 100644 --- a/frontend/src/components/Menu/Sidebar.spec.js +++ b/frontend/src/components/Menu/Sidebar.spec.js @@ -31,11 +31,7 @@ describe('Sidebar', () => { expect(wrapper.find('div#component-sidebar').exists()).toBeTruthy() }) - describe('navigation Navbar', () => { - it('has seven b-nav-item in the navbar', () => { - expect(wrapper.findAll('.nav-item')).toHaveLength(8) - }) - + describe('navigation Navbar (general elements)', () => { it('has first nav-item "navigation.overview" in navbar', () => { expect(wrapper.findAll('.nav-item').at(0).text()).toEqual('navigation.overview') }) @@ -55,7 +51,12 @@ describe('Sidebar', () => { it('has first nav-item "navigation.profile" in navbar', () => { expect(wrapper.findAll('.nav-item').at(4).text()).toEqual('navigation.profile') }) - + }) + // ---- + describe('navigation Navbar (user has an elopage account)', () => { + it('has seven b-nav-item in the navbar', () => { + expect(wrapper.findAll('.nav-item')).toHaveLength(8) + }) it('has a link to the members area', () => { expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.members_area') expect(wrapper.findAll('.nav-item').at(5).find('a').attributes('href')).toBe('#') @@ -69,5 +70,20 @@ describe('Sidebar', () => { expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.logout') }) }) + describe('navigation Navbar (user has no elopage account)', () => { + beforeAll(() => { + mocks.$store.state.hasElopage = false + wrapper = Wrapper() + }) + it('has six b-nav-item in the navbar', () => { + expect(wrapper.findAll('.nav-item')).toHaveLength(7) + }) + it('has first nav-item "navigation.admin_area" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.admin_area') + }) + it('has first nav-item "navigation.logout" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.logout') + }) + }) }) }) diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index a8850ed18..0cdab31c3 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -27,9 +27,17 @@

- + {{ $t('navigation.members_area') }} + + {{ $t('math.exclaim') }} + From bb120b8b82f9c25f5caa39cdd81064c1a36e4dc9 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 28 Jul 2022 08:39:31 +0200 Subject: [PATCH 47/68] improve unit test structure for better readability --- frontend/src/components/Menu/Navbar.spec.js | 11 +++++++++++ frontend/src/components/Menu/Sidebar.spec.js | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Menu/Navbar.spec.js b/frontend/src/components/Menu/Navbar.spec.js index ef39fdc0e..109190e39 100644 --- a/frontend/src/components/Menu/Navbar.spec.js +++ b/frontend/src/components/Menu/Navbar.spec.js @@ -43,9 +43,11 @@ describe('Navbar', () => { it('has .navbar-brand in the navbar', () => { expect(wrapper.find('.navbar-brand').exists()).toBeTruthy() }) + it('has b-navbar-toggle in the navbar', () => { expect(wrapper.find('.navbar-toggler').exists()).toBeTruthy() }) + it('has ten b-nav-item in the navbar', () => { expect(wrapper.findAll('.nav-item')).toHaveLength(10) }) @@ -57,16 +59,20 @@ describe('Navbar', () => { it('has first nav-item "navigation.overview" in navbar', () => { expect(wrapper.findAll('.nav-item').at(3).text()).toEqual('navigation.overview') }) + it('has first nav-item "navigation.send" in navbar', () => { expect(wrapper.findAll('.nav-item').at(4).text()).toEqual('navigation.send') }) + it('has first nav-item "navigation.transactions" in navbar', () => { expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.transactions') }) + it('has first nav-item "navigation.profile" in navbar', () => { expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.profile') }) }) + describe('navigation Navbar (user has an elopage account)', () => { it('has a link to the members area', () => { expect(wrapper.findAll('.nav-item').at(7).text()).toContain('navigation.members_area') @@ -78,23 +84,28 @@ describe('Navbar', () => { it('has first nav-item "navigation.admin_area" in navbar', () => { expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.admin_area') }) + it('has first nav-item "navigation.logout" in navbar', () => { expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.logout') }) }) + describe('navigation Navbar (user has no elopage account)', () => { beforeAll(() => { mocks.$store.state.hasElopage = false wrapper = Wrapper() }) + it('has first nav-item "navigation.admin_area" in navbar', () => { expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.admin_area') }) + it('has first nav-item "navigation.logout" in navbar', () => { expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.logout') }) }) }) + describe('check watch visible true', () => { beforeEach(async () => { await wrapper.setProps({ visible: true }) diff --git a/frontend/src/components/Menu/Sidebar.spec.js b/frontend/src/components/Menu/Sidebar.spec.js index dd9511562..7be68363b 100644 --- a/frontend/src/components/Menu/Sidebar.spec.js +++ b/frontend/src/components/Menu/Sidebar.spec.js @@ -27,6 +27,7 @@ describe('Sidebar', () => { beforeEach(() => { wrapper = Wrapper() }) + it('renders the component', () => { expect(wrapper.find('div#component-sidebar').exists()).toBeTruthy() }) @@ -52,11 +53,12 @@ describe('Sidebar', () => { expect(wrapper.findAll('.nav-item').at(4).text()).toEqual('navigation.profile') }) }) - // ---- + describe('navigation Navbar (user has an elopage account)', () => { it('has seven b-nav-item in the navbar', () => { expect(wrapper.findAll('.nav-item')).toHaveLength(8) }) + it('has a link to the members area', () => { expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.members_area') expect(wrapper.findAll('.nav-item').at(5).find('a').attributes('href')).toBe('#') @@ -70,17 +72,21 @@ describe('Sidebar', () => { expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.logout') }) }) + describe('navigation Navbar (user has no elopage account)', () => { beforeAll(() => { mocks.$store.state.hasElopage = false wrapper = Wrapper() }) + it('has six b-nav-item in the navbar', () => { expect(wrapper.findAll('.nav-item')).toHaveLength(7) }) + it('has first nav-item "navigation.admin_area" in navbar', () => { expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.admin_area') }) + it('has first nav-item "navigation.logout" in navbar', () => { expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.logout') }) From a41385141902b7611c7fbde289d68cc3d2fe4c6b Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 28 Jul 2022 08:50:26 +0200 Subject: [PATCH 48/68] specify the wording of the unit tests regarding the number of nav items --- frontend/src/components/Menu/Sidebar.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Menu/Sidebar.spec.js b/frontend/src/components/Menu/Sidebar.spec.js index 7be68363b..1593a79a8 100644 --- a/frontend/src/components/Menu/Sidebar.spec.js +++ b/frontend/src/components/Menu/Sidebar.spec.js @@ -55,7 +55,7 @@ describe('Sidebar', () => { }) describe('navigation Navbar (user has an elopage account)', () => { - it('has seven b-nav-item in the navbar', () => { + it('has eight b-nav-item in the navbar', () => { expect(wrapper.findAll('.nav-item')).toHaveLength(8) }) @@ -79,7 +79,7 @@ describe('Sidebar', () => { wrapper = Wrapper() }) - it('has six b-nav-item in the navbar', () => { + it('has seven b-nav-item in the navbar', () => { expect(wrapper.findAll('.nav-item')).toHaveLength(7) }) From 6f081c4cc941ea6a242d17b2986d8cd98f6513da Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 28 Jul 2022 11:12:17 +0200 Subject: [PATCH 49/68] fix: Use Inner Join for Contribution and User --- .../graphql/resolver/ContributionResolver.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index a22715fb4..3307252e4 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, Int, Mutation, Query, Resolver } from 'type-graphql' -import { FindOperator, IsNull } from '@dbTools/typeorm' +import { FindOperator, IsNull, getConnection } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import { Order } from '@enum/Order' @@ -106,14 +106,15 @@ export class ContributionResolver { @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, ): Promise { - const [dbContributions, count] = await dbContribution.findAndCount({ - relations: ['user'], - order: { - createdAt: order, - }, - skip: (currentPage - 1) * pageSize, - take: pageSize, - }) + const [dbContributions, count] = await getConnection() + .createQueryBuilder() + .select('c') + .from(dbContribution, 'c') + .innerJoinAndSelect('c.user', 'u') + .orderBy('c.createdAt', order) + .limit(pageSize) + .offset((currentPage - 1) * pageSize) + .getManyAndCount() return new ContributionListResult( count, dbContributions.map( From 2d80c7029eae75fbda6c925cc8b0e5b54ef41e17 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 28 Jul 2022 13:06:42 +0200 Subject: [PATCH 50/68] including validation date infos to link copying after transaction link creation - adapt transaction link creation mutation to get the validation date - add validation date and text to link copy - utilize mixins to avoid code doubling --- frontend/src/components/ClipboardCopy.vue | 42 ++----------------- .../GddSend/TransactionResultLink.vue | 4 +- frontend/src/graphql/mutations.js | 3 ++ frontend/src/pages/Send.vue | 13 ++++-- 4 files changed, 19 insertions(+), 43 deletions(-) diff --git a/frontend/src/components/ClipboardCopy.vue b/frontend/src/components/ClipboardCopy.vue index efddf8ab3..66e47a264 100644 --- a/frontend/src/components/ClipboardCopy.vue +++ b/frontend/src/components/ClipboardCopy.vue @@ -6,7 +6,7 @@ {{ $t('gdd_per_link.copy-link-with-text') }} - + {{ $t('gdd_per_link.copy-link') }} @@ -21,46 +21,10 @@