From bae1b85482bc5f895d8f5089f50b0b48b347c7ed Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 25 Mar 2022 09:29:42 +0100 Subject: [PATCH 01/17] add bootstrap pagination on GDD Transaction List, tests adapted --- .../src/components/GddTransactionList.spec.js | 83 ++++--------------- .../src/components/GddTransactionList.vue | 11 ++- 2 files changed, 21 insertions(+), 73 deletions(-) diff --git a/frontend/src/components/GddTransactionList.spec.js b/frontend/src/components/GddTransactionList.spec.js index ba45d93d4..28a052abe 100644 --- a/frontend/src/components/GddTransactionList.spec.js +++ b/frontend/src/components/GddTransactionList.spec.js @@ -405,78 +405,23 @@ describe('GddTransactionList', () => { }) }) - describe('pagination buttons', () => { - const transactions = Array.from({ length: 42 }, (_, idx) => { - return { - amount: '3.14', - balanceDate: '2021-04-29T17:26:40+00:00', - decay: {}, - memo: 'Kreiszahl PI', - linkedUser: { - firstName: 'Bibi', - lastName: 'Bloxberg', - __typename: 'User', - }, - id: idx + 1, - typeId: 'RECEIVE', - } - }) - - let paginationButtons - - beforeEach(async () => { - await wrapper.setProps({ - transactions, - transactionCount: 42, - showPagination: true, - decayStartBlock: new Date(), + describe.only('pagination buttons', () => { + it('shows the pagination buttons if transactionCount > 25', () => { + beforeEach(async () => { + await wrapper.setProps({ + transactionCount: 42, + }) }) - paginationButtons = wrapper.find('div.pagination-buttons') + expect(wrapper.find('div.pagination')).toBeTruthy() }) - it('shows the pagination buttons', () => { - expect(paginationButtons.exists()).toBeTruthy() - }) - - it('has the previous button disabled', () => { - expect(paginationButtons.find('button.previous-page').attributes('disabled')).toBe( - 'disabled', - ) - }) - - it('shows the text "1 / 2"', () => { - expect(paginationButtons.find('p.text-center').text()).toBe('1 math.div 2') - }) - - it('emits update-transactions when next button is clicked', async () => { - await paginationButtons.find('button.next-page').trigger('click') - expect(wrapper.emitted('update-transactions')[1]).toEqual([ - { currentPage: 2, pageSize: 25 }, - ]) - }) - - it('shows text "2 / 2" when next button is clicked', async () => { - await paginationButtons.find('button.next-page').trigger('click') - expect(paginationButtons.find('p.text-center').text()).toBe('2 math.div 2') - }) - - it('has next-button disabled when next button is clicked', async () => { - await paginationButtons.find('button.next-page').trigger('click') - expect(paginationButtons.find('button.next-page').attributes('disabled')).toBe('disabled') - }) - - it('scrolls to top after loading next page', async () => { - await paginationButtons.find('button.next-page').trigger('click') - expect(scrollToMock).toBeCalled() - }) - - it('emits update-transactions when preivous button is clicked after next buton', async () => { - await paginationButtons.find('button.next-page').trigger('click') - await paginationButtons.find('button.previous-page').trigger('click') - expect(wrapper.emitted('update-transactions')[2]).toEqual([ - { currentPage: 1, pageSize: 25 }, - ]) - expect(scrollToMock).toBeCalled() + it('shows no the pagination buttons if transactionCount < 25', () => { + beforeEach(async () => { + await wrapper.setProps({ + transactionCount: 2, + }) + }) + expect(wrapper.find('div.pagination').exists()).toBe(false) }) }) }) diff --git a/frontend/src/components/GddTransactionList.vue b/frontend/src/components/GddTransactionList.vue index 2424907c5..9e5cc8e8d 100644 --- a/frontend/src/components/GddTransactionList.vue +++ b/frontend/src/components/GddTransactionList.vue @@ -56,12 +56,17 @@ - + align="center" + > +
{{ $t('transaction.nullTransactions') }}
@@ -70,7 +75,6 @@ From e942cd206970785ac1ac5c97d91958dfebebab07 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 5 Apr 2022 14:35:35 +0200 Subject: [PATCH 17/17] remove unused locale due to deletion of pagination component --- frontend/src/locales/de.json | 1 - frontend/src/locales/en.json | 1 - 2 files changed, 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 80f7ded25..600b36e65 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -143,7 +143,6 @@ "login": "Anmeldung", "math": { "aprox": "~", - "div": "/", "equal": "=", "exclaim": "!", "pipe": "|" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 500cceaae..ef9a14c0a 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -143,7 +143,6 @@ "login": "Login", "math": { "aprox": "~", - "div": "/", "equal": "=", "exclaim": "!", "pipe": "|"