[MNT-22924] Fix slow search results loading, limit number of pages (#7609)

* [MNT-22924] Fix slow search results loading, limit number of pages

* Add unit test

* Changed some of the values
This commit is contained in:
Thomas Hunter
2022-05-11 09:53:05 +01:00
committed by GitHub
parent fd0626391c
commit e844faff79
3 changed files with 36 additions and 3 deletions

View File

@@ -373,4 +373,23 @@ describe('PaginationComponent', () => {
expect(component.pages).toEqual([1]);
});
});
describe('many pages', () => {
it('should all the pages be available if equal or less than 100', () => {
component.pagination = new FakePaginationInput(100, 30, 5);
expect(component.limitedPages.length).toBe(100);
expect(component.pages).toEqual(component.limitedPages);
});
it('should only some pages be available if over 100', () => {
component.pagination = new FakePaginationInput(101, 30, 5);
const expectedPages = [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 101];
console.log(component.pagination.totalItems, component.pagination.skipCount);
expect(component.limitedPages).toEqual(expectedPages);
expect(component.limitedPages).not.toEqual(component.pages);
});
});
});