fix: infinite loading bug
Signed-off-by: Raul Kele <raulkeleblk@gmail.com>
This commit is contained in:
parent
23416883c7
commit
514475a33f
@ -101,4 +101,11 @@ describe('Dependencies tab', () => {
|
||||
render(<RouterDependsWrapper />);
|
||||
await waitFor(() => expect(error).toBeCalledTimes(1));
|
||||
});
|
||||
|
||||
it('should stop loading if the api response contains an error', async () => {
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 500, data: { errors: ['test error'] } });
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
render(<RouterDependsWrapper />);
|
||||
expect(await screen.findByText(/Nothing found/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -101,4 +101,11 @@ describe('Dependents tab', () => {
|
||||
render(<RouterDependsWrapper />);
|
||||
await waitFor(() => expect(error).toBeCalledTimes(1));
|
||||
});
|
||||
|
||||
it('should stop loading if the api response contains an error', async () => {
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 500, data: { errors: ['test error'] } });
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
render(<RouterDependsWrapper />);
|
||||
expect(await screen.findByText(/Nothing found/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -230,8 +230,9 @@ afterEach(() => {
|
||||
|
||||
describe('Tags details', () => {
|
||||
it('should show tabs and allow nagivation between them', async () => {
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } });
|
||||
jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: mockImage } });
|
||||
render(<TagDetailsThemeWrapper />);
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 500, data: { data: { errors: ['test error'] } } });
|
||||
const dependenciesTab = await screen.findByTestId('dependencies-tab');
|
||||
fireEvent.click(dependenciesTab);
|
||||
expect(await screen.findByTestId('depends-on-container')).toBeInTheDocument();
|
||||
|
@ -89,7 +89,6 @@ function DependsOn(props) {
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.data && response.data.data) {
|
||||
if (!isEmpty(response.data.data.BaseImageList?.Results)) {
|
||||
let imagesData = response.data.data.BaseImageList?.Results?.map((img) => mapToImage(img));
|
||||
const newImageList = [...images, ...imagesData];
|
||||
setImages(newImageList);
|
||||
@ -97,7 +96,8 @@ function DependsOn(props) {
|
||||
response.data.data.BaseImageList.Page?.ItemCount < EXPLORE_PAGE_SIZE ||
|
||||
newImageList.length >= response.data.data.BaseImageList?.Page?.TotalCount
|
||||
);
|
||||
}
|
||||
} else if (response.data.errors) {
|
||||
setIsEndOfList(true);
|
||||
}
|
||||
setIsLoading(false);
|
||||
})
|
||||
|
@ -96,6 +96,8 @@ function IsDependentOn(props) {
|
||||
response.data.data.DerivedImageList?.Page?.ItemCount < EXPLORE_PAGE_SIZE ||
|
||||
newImageList.length >= response.data.data.DerivedImageList?.Page?.TotalCount
|
||||
);
|
||||
} else if (response.data.errors) {
|
||||
setIsEndOfList(true);
|
||||
}
|
||||
setIsLoading(false);
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user