From bae1b85482bc5f895d8f5089f50b0b48b347c7ed Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 25 Mar 2022 09:29:42 +0100 Subject: [PATCH 01/19] 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 1b88c23b050a0ff6a02ef1c00f20feac69f97993 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 4 Apr 2022 17:59:57 +0200 Subject: [PATCH 15/19] fixed test for pagination --- .../src/components/GddTransactionList.spec.js | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/GddTransactionList.spec.js b/frontend/src/components/GddTransactionList.spec.js index 7eaa42081..eba3dee2d 100644 --- a/frontend/src/components/GddTransactionList.spec.js +++ b/frontend/src/components/GddTransactionList.spec.js @@ -405,13 +405,13 @@ describe('GddTransactionList', () => { }) }) - describe('change of currentPage', () => { + describe('change of 2 currentPage', () => { beforeEach(async () => { wrapper.setData({ currentPage: 2 }) }) describe('pagination buttons', () => { - describe('updates transaction count < 25', () => { + describe('updates transactionCount > 25', () => { beforeEach(async () => { const decayStartBlock = new Date(2001, 8, 9) await wrapper.setProps({ @@ -419,16 +419,44 @@ describe('GddTransactionList', () => { transactionCount: 26, decayStartBlock, pageSize: 25, + showPagination: true, }) }) it('updates transaction transactionCount', () => { expect(wrapper.vm.transactionCount).toBe(26) }) - it('shows pagination buttons if transactionCount > pageSize', () => { + it('shows pagination buttons if showPagination = true', () => { expect(wrapper.find('ul.pagination').exists()).toBe(true) }) }) }) }) + + describe('change of 1 currentPage', () => { + beforeEach(async () => { + wrapper.setData({ currentPage: 1 }) + }) + + describe('pagination buttons', () => { + describe('updates transactionCount < 25', () => { + beforeEach(async () => { + const decayStartBlock = new Date(2001, 8, 9) + await wrapper.setProps({ + transactions: [], + transactionCount: 2, + decayStartBlock, + pageSize: 25, + showPagination: false, + }) + }) + it('updates transaction transactionCount', () => { + expect(wrapper.vm.transactionCount).toBe(2) + }) + it('shows pagination buttons if showPagination = true', () => { + expect(wrapper.find('ul.pagination').exists()).toBe(false) + }) + }) + }) + }) }) }) From a6b5dddc615e2c6e3d617fc5aee9854b4ce32531 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 5 Apr 2022 13:01:33 +0200 Subject: [PATCH 16/19] email is restored after clicking back from transaction confirmation --- frontend/src/pages/Send.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/pages/Send.spec.js b/frontend/src/pages/Send.spec.js index dd32fdb09..447fdde33 100644 --- a/frontend/src/pages/Send.spec.js +++ b/frontend/src/pages/Send.spec.js @@ -85,10 +85,9 @@ describe('Send', () => { }) it('restores the previous data in the formular', () => { - /* expect(wrapper.find('#input-group-1').find('input').vm.$el.value).toBe( + expect(wrapper.find('#input-group-1').find('input').vm.$el.value).toBe( 'user@example.org', ) - */ expect(wrapper.find('#input-group-2').find('input').vm.$el.value).toBe('23.45') expect(wrapper.find('#input-group-3').find('textarea').vm.$el.value).toBe( 'Make the best of it!', From f8412acb5ead9c3918a74fe57eb8bf96a4b656d5 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 5 Apr 2022 13:27:43 +0200 Subject: [PATCH 17/19] improve tests --- .../src/components/GddTransactionList.spec.js | 87 ++++++++++--------- .../src/components/GdtTransactionList.spec.js | 6 +- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/frontend/src/components/GddTransactionList.spec.js b/frontend/src/components/GddTransactionList.spec.js index eba3dee2d..fbcb10bdd 100644 --- a/frontend/src/components/GddTransactionList.spec.js +++ b/frontend/src/components/GddTransactionList.spec.js @@ -23,6 +23,8 @@ describe('GddTransactionList', () => { return mount(GddTransactionList, { localVue, mocks }) } + const decayStartBlock = new Date(2001, 8, 9) + describe('mount', () => { beforeEach(() => { wrapper = Wrapper() @@ -84,7 +86,6 @@ describe('GddTransactionList', () => { describe('with transactions', () => { beforeEach(async () => { - const decayStartBlock = new Date(2001, 8, 9) await wrapper.setProps({ transactions: [ { @@ -405,57 +406,59 @@ describe('GddTransactionList', () => { }) }) - describe('change of 2 currentPage', () => { + describe('pagination buttons', () => { beforeEach(async () => { - wrapper.setData({ currentPage: 2 }) + await wrapper.setProps({ + 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', + balance: '33.33', + } + }), + transactionCount: 42, + decayStartBlock, + pageSize: 25, + showPagination: true, + }) }) - describe('pagination buttons', () => { - describe('updates transactionCount > 25', () => { - beforeEach(async () => { - const decayStartBlock = new Date(2001, 8, 9) - await wrapper.setProps({ - transactions: [], - transactionCount: 26, - decayStartBlock, - pageSize: 25, - showPagination: true, - }) - }) - it('updates transaction transactionCount', () => { - expect(wrapper.vm.transactionCount).toBe(26) - }) - it('shows pagination buttons if showPagination = true', () => { - expect(wrapper.find('ul.pagination').exists()).toBe(true) - }) + describe('next page button clicked', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2) + }) + + it('emits update transactions', () => { + expect(wrapper.emitted('update-transactions')).toEqual( + expect.arrayContaining([[{ currentPage: 2, pageSize: 25 }]]), + ) }) }) }) - describe('change of 1 currentPage', () => { + describe('show no pagination', () => { beforeEach(async () => { - wrapper.setData({ currentPage: 1 }) + await wrapper.setProps({ + transactions: [], + transactionCount: 2, + decayStartBlock, + pageSize: 25, + showPagination: false, + }) }) - describe('pagination buttons', () => { - describe('updates transactionCount < 25', () => { - beforeEach(async () => { - const decayStartBlock = new Date(2001, 8, 9) - await wrapper.setProps({ - transactions: [], - transactionCount: 2, - decayStartBlock, - pageSize: 25, - showPagination: false, - }) - }) - it('updates transaction transactionCount', () => { - expect(wrapper.vm.transactionCount).toBe(2) - }) - it('shows pagination buttons if showPagination = true', () => { - expect(wrapper.find('ul.pagination').exists()).toBe(false) - }) - }) + it('shows no pagination buttons', () => { + expect(wrapper.find('ul.pagination').exists()).toBe(false) }) }) }) diff --git a/frontend/src/components/GdtTransactionList.spec.js b/frontend/src/components/GdtTransactionList.spec.js index 7871b6750..c1b9a7cc9 100644 --- a/frontend/src/components/GdtTransactionList.spec.js +++ b/frontend/src/components/GdtTransactionList.spec.js @@ -155,8 +155,8 @@ describe('GdtTransactionList ', () => { describe('change of currentPage', () => { it('calls the API after currentPage changes', async () => { jest.clearAllMocks() - wrapper.setData({ currentPage: 2 }) - await wrapper.vm.$nextTick() + await wrapper.setData({ transactionGdtCount: 42 }) + await wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2) expect(apolloMock).toBeCalledWith( expect.objectContaining({ variables: { @@ -180,6 +180,7 @@ describe('GdtTransactionList ', () => { }) wrapper = Wrapper() }) + it('shows the pagination buttons', () => { expect(wrapper.find('ul.pagination').exists()).toBe(true) }) @@ -197,6 +198,7 @@ describe('GdtTransactionList ', () => { }) wrapper = Wrapper() }) + it('shows no pagination buttons', () => { expect(wrapper.find('ul.pagination').exists()).toBe(false) }) From ddeb936634bdbb07eca6c674479ddee8246a3806 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 5 Apr 2022 13:30:06 +0200 Subject: [PATCH 18/19] remove unused pagination component --- .../src/components/PaginationButtons.spec.js | 49 ----------------- frontend/src/components/PaginationButtons.vue | 53 ------------------- 2 files changed, 102 deletions(-) delete mode 100644 frontend/src/components/PaginationButtons.spec.js delete mode 100644 frontend/src/components/PaginationButtons.vue diff --git a/frontend/src/components/PaginationButtons.spec.js b/frontend/src/components/PaginationButtons.spec.js deleted file mode 100644 index f2badd082..000000000 --- a/frontend/src/components/PaginationButtons.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import { mount } from '@vue/test-utils' -import PaginationButtons from './PaginationButtons' - -const localVue = global.localVue - -const propsData = { - totalRows: 42, - perPage: 12, - value: 1, -} - -describe('PaginationButtons', () => { - let wrapper - - const mocks = { - $t: jest.fn((t) => t), - } - - const Wrapper = () => { - return mount(PaginationButtons, { localVue, mocks, propsData }) - } - - describe('mount', () => { - beforeEach(() => { - wrapper = Wrapper() - }) - - it('renders the component', () => { - expect(wrapper.find('div.pagination-buttons').exists()).toBeTruthy() - }) - - describe('with active buttons', () => { - it('emits input next page button is clicked', async () => { - wrapper.find('button.next-page').trigger('click') - await wrapper.vm.$nextTick() - expect(wrapper.emitted().input[0]).toEqual([2]) - }) - - it('emits input when previous page button is clicked', async () => { - wrapper.setProps({ value: 2 }) - wrapper.setData({ currentValue: 2 }) - await wrapper.vm.$nextTick() - wrapper.find('button.previous-page').trigger('click') - await wrapper.vm.$nextTick() - expect(wrapper.emitted().input[0]).toEqual([1]) - }) - }) - }) -}) diff --git a/frontend/src/components/PaginationButtons.vue b/frontend/src/components/PaginationButtons.vue deleted file mode 100644 index e5e465032..000000000 --- a/frontend/src/components/PaginationButtons.vue +++ /dev/null @@ -1,53 +0,0 @@ - - From e942cd206970785ac1ac5c97d91958dfebebab07 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 5 Apr 2022 14:35:35 +0200 Subject: [PATCH 19/19] 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": "|"