From 69bb8b7ea7075a56107a2245d96731fc8426485b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 1 Oct 2021 22:00:37 +0200 Subject: [PATCH] unify pagination to use `currentPage`, `pageSize` and `order` as values --- frontend/src/graphql/queries.js | 4 ++-- frontend/src/views/Layout/DashboardLayout_gdd.spec.js | 8 ++++---- frontend/src/views/Layout/DashboardLayout_gdd.vue | 4 ++-- .../Pages/AccountOverview/GddTransactionList.spec.js | 8 ++++++-- .../views/Pages/AccountOverview/GddTransactionList.vue | 4 ++-- .../src/views/Pages/UserProfileTransactionList.spec.js | 6 +++--- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 009177cc1..0aadb3345 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -32,8 +32,8 @@ export const loginViaEmailVerificationCode = gql` ` export const transactionsQuery = gql` - query($firstPage: Int = 1, $items: Int = 25, $order: String = "DESC") { - transactionList(firstPage: $firstPage, items: $items, order: $order) { + query($currentPage: Int = 1, $pageSize: Int = 25, $order: String = "DESC") { + transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) { gdtSum count balance diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js index 2a789b329..6555d1dda 100644 --- a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js +++ b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js @@ -189,7 +189,7 @@ describe('DashboardLayoutGdd', () => { }) await wrapper .findComponent({ ref: 'router-view' }) - .vm.$emit('update-transactions', { firstPage: 2, items: 5 }) + .vm.$emit('update-transactions', { currentPage: 2, pageSize: 5 }) await flushPromises() }) @@ -197,8 +197,8 @@ describe('DashboardLayoutGdd', () => { expect(apolloMock).toBeCalledWith( expect.objectContaining({ variables: { - firstPage: 2, - items: 5, + currentPage: 2, + pageSize: 5, }, }), ) @@ -233,7 +233,7 @@ describe('DashboardLayoutGdd', () => { }) await wrapper .findComponent({ ref: 'router-view' }) - .vm.$emit('update-transactions', { firstPage: 2, items: 5 }) + .vm.$emit('update-transactions', { currentPage: 2, pageSize: 5 }) await flushPromises() }) diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index 8784b4312..2b63bf417 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -110,8 +110,8 @@ export default { .query({ query: transactionsQuery, variables: { - firstPage: pagination.firstPage, - items: pagination.items, + currentPage: pagination.currentPage, + pageSize: pagination.pageSize, }, fetchPolicy: 'network-only', }) diff --git a/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js b/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js index 5418ff3ba..e8a74253a 100644 --- a/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js @@ -327,7 +327,9 @@ describe('GddTransactionList', () => { 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([{ firstPage: 2, items: 25 }]) + expect(wrapper.emitted('update-transactions')[1]).toEqual([ + { currentPage: 2, pageSize: 25 }, + ]) }) it('shows text "2 / 2" when next button is clicked', async () => { @@ -348,7 +350,9 @@ describe('GddTransactionList', () => { 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([{ firstPage: 1, items: 25 }]) + expect(wrapper.emitted('update-transactions')[2]).toEqual([ + { currentPage: 1, pageSize: 25 }, + ]) expect(scrollToMock).toBeCalled() }) }) diff --git a/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue b/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue index 7348f96de..3b0104068 100644 --- a/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue +++ b/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue @@ -134,8 +134,8 @@ export default { methods: { updateTransactions() { this.$emit('update-transactions', { - firstPage: this.currentPage, - items: this.pageSize, + currentPage: this.currentPage, + pageSize: this.pageSize, }) window.scrollTo(0, 0) }, diff --git a/frontend/src/views/Pages/UserProfileTransactionList.spec.js b/frontend/src/views/Pages/UserProfileTransactionList.spec.js index 057e1dfd5..a9ab48a19 100644 --- a/frontend/src/views/Pages/UserProfileTransactionList.spec.js +++ b/frontend/src/views/Pages/UserProfileTransactionList.spec.js @@ -36,16 +36,16 @@ describe('UserProfileTransactionList', () => { it('emits update-transactions after creation', () => { expect(wrapper.emitted('update-transactions')).toEqual( - expect.arrayContaining([expect.arrayContaining([{ firstPage: 1, items: 25 }])]), + expect.arrayContaining([expect.arrayContaining([{ currentPage: 1, pageSize: 25 }])]), ) }) it('emist update-transactions when update-transactions is called', () => { wrapper .findComponent({ name: 'GddTransactionList' }) - .vm.$emit('update-transactions', { firstPage: 2, items: 25 }) + .vm.$emit('update-transactions', { currentPage: 2, pageSize: 25 }) expect(wrapper.emitted('update-transactions')).toEqual( - expect.arrayContaining([expect.arrayContaining([{ firstPage: 2, items: 25 }])]), + expect.arrayContaining([expect.arrayContaining([{ currentPage: 2, pageSize: 25 }])]), ) })