Frontend better handle slow backend requests

This commit is contained in:
shamoon
2023-08-22 22:11:53 -07:00
parent 46a39190a4
commit faed7683be
13 changed files with 133 additions and 56 deletions

View File

@@ -103,6 +103,7 @@ describe('DocumentListViewService', () => {
})
afterEach(() => {
documentListViewService.cancelPending()
httpTestingController.verify()
sessionStorage.clear()
})
@@ -425,4 +426,13 @@ describe('DocumentListViewService', () => {
})
expect(documentListViewService.selected.size).toEqual(3)
})
it('should cancel on reload the list', () => {
const cancelSpy = jest.spyOn(documentListViewService, 'cancelPending')
documentListViewService.reload()
httpTestingController.expectOne(
`${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&tags__id__all=9`
)
expect(cancelSpy).toHaveBeenCalled()
})
})