diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index c9d9661c2..091d7a011 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -39,7 +39,7 @@ const mocks = { const defaultData = () => { return { adminListContributions: { - contributionCount: 2, + contributionCount: 30, contributionList: [ { id: 1, @@ -407,6 +407,44 @@ describe('CreationConfirm', () => { statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], }) }) + + describe('change pagination', () => { + it('has pagination buttons', () => { + expect(wrapper.findComponent({ name: 'BPagination' }).exists()).toBe(true) + }) + + describe('next page', () => { + beforeEach(() => { + jest.clearAllMocks() + wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2) + }) + + it('calls the API again', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 2, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], + }) + }) + + describe('click tab "open" again', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.find('a[data-test="open"]').trigger('click') + }) + + it('refetches contributions with proper filter and current page = 1', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 1, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING'], + }) + }) + }) + }) + }) }) }) }) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 3c1a1e67e..53ffbd66e 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -116,6 +116,11 @@ export default { pageSize: 25, } }, + watch: { + tabIndex() { + this.currentPage = 1 + }, + }, methods: { deleteCreation() { this.$apollo