Fix task pagination

This commit is contained in:
kolaente 2021-02-20 17:10:56 +01:00
parent d441751c5b
commit 2bf5ffa1a1
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 28 additions and 0 deletions

View file

@ -117,6 +117,29 @@ describe('Lists', () => {
cy.get('.tasks-container .tasks .color-bubble') cy.get('.tasks-container .tasks .color-bubble')
.should('not.exist') .should('not.exist')
}) })
it('Should paginate for > 50 tasks', () => {
const tasks = TaskFactory.create(100, {
id: '{increment}',
title: i => `task${i}`,
list_id: 1,
})
cy.visit('/lists/1/list')
cy.get('.tasks-container .tasks')
.should('contain', tasks[99].title)
cy.get('.card-content .pagination .pagination-link')
.contains('2')
.click()
cy.url()
.should('contain', '?page=2')
cy.get('.tasks-container .tasks')
.should('contain', tasks[1].title)
cy.get('.tasks-container .tasks')
.should('not.contain', tasks[99].title)
})
}) })
describe('Table View', () => { describe('Table View', () => {

View file

@ -27,6 +27,10 @@ export class Factory {
for (let i = 1; i <= count; i++) { for (let i = 1; i <= count; i++) {
const entry = merge(this.factory(), override) const entry = merge(this.factory(), override)
for (const e in entry) { for (const e in entry) {
if(typeof entry[e] === 'function') {
entry[e] = entry[e](i)
continue
}
if (entry[e] === '{increment}') { if (entry[e] === '{increment}') {
entry[e] = i entry[e] = i
} }

View file

@ -70,6 +70,7 @@ export default {
id: list.listId, id: list.listId,
params: params, params: params,
search: search, search: search,
page: page,
} }
if (JSON.stringify(currentList) === JSON.stringify(this.loadedList)) { if (JSON.stringify(currentList) === JSON.stringify(this.loadedList)) {
return return