Merge pull request #2902 from gradido/2818-pagination-is-not-reset-when-switching-tabs

fix(admin): pagination set currentPage by switch tabs
This commit is contained in:
Alexander Friedland 2023-04-11 12:59:34 +02:00 committed by GitHub
commit 38759981f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View File

@ -39,7 +39,7 @@ const mocks = {
const defaultData = () => { const defaultData = () => {
return { return {
adminListContributions: { adminListContributions: {
contributionCount: 2, contributionCount: 30,
contributionList: [ contributionList: [
{ {
id: 1, id: 1,
@ -407,6 +407,44 @@ describe('CreationConfirm', () => {
statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], 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'],
})
})
})
})
})
}) })
}) })
}) })

View File

@ -116,6 +116,11 @@ export default {
pageSize: 25, pageSize: 25,
} }
}, },
watch: {
tabIndex() {
this.currentPage = 1
},
},
methods: { methods: {
deleteCreation() { deleteCreation() {
this.$apollo this.$apollo