Fix: handle page out of range in mgmt lists after delete (#8771)

This commit is contained in:
shamoon
2025-01-16 00:59:27 -08:00
committed by GitHub
parent f68ee628d9
commit 283bcb4c91
3 changed files with 50 additions and 22 deletions

View File

@@ -1,5 +1,9 @@
import { DatePipe } from '@angular/common'
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
import {
HttpErrorResponse,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import {
ComponentFixture,
@@ -243,6 +247,21 @@ describe('ManagementListComponent', () => {
expect(reloadSpy).toHaveBeenCalled()
})
it('should fall back to first page if error is page is out of range', () => {
jest.spyOn(tagService, 'listFiltered').mockReturnValueOnce(
throwError(
() =>
new HttpErrorResponse({
status: 404,
error: { detail: 'Invalid page' },
})
)
)
component.page = 2
component.reloadData()
expect(component.page).toEqual(1)
})
it('should support toggle all items in view', () => {
expect(component.selectedObjects.size).toEqual(0)
const toggleAllSpy = jest.spyOn(component, 'toggleAll')