CreateImageWizardV2: fix pagination when search is empty
This commit is contained in:
parent
3cb9fe0670
commit
d0f52bb1d6
2 changed files with 67 additions and 2 deletions
|
|
@ -1351,8 +1351,15 @@ const Packages = () => {
|
||||||
</ToolbarItem>
|
</ToolbarItem>
|
||||||
<ToolbarItem variant="pagination">
|
<ToolbarItem variant="pagination">
|
||||||
<Pagination
|
<Pagination
|
||||||
|
data-testid="packages-pagination-top"
|
||||||
itemCount={
|
itemCount={
|
||||||
transformedPackages.length + transformedGroups.length
|
searchTerm === '' && toggleSelected === 'toggle-available'
|
||||||
|
? 0
|
||||||
|
: showPackages && showGroups
|
||||||
|
? transformedPackages.length + transformedGroups.length
|
||||||
|
: showPackages
|
||||||
|
? transformedPackages.length
|
||||||
|
: transformedGroups.length
|
||||||
}
|
}
|
||||||
perPage={perPage}
|
perPage={perPage}
|
||||||
page={page}
|
page={page}
|
||||||
|
|
@ -1389,7 +1396,16 @@ const Packages = () => {
|
||||||
<Tbody>{bodyContent}</Tbody>
|
<Tbody>{bodyContent}</Tbody>
|
||||||
</Table>
|
</Table>
|
||||||
<Pagination
|
<Pagination
|
||||||
itemCount={transformedPackages.length + transformedGroups.length}
|
data-testid="packages-pagination-bottom"
|
||||||
|
itemCount={
|
||||||
|
searchTerm === '' && toggleSelected === 'toggle-available'
|
||||||
|
? 0
|
||||||
|
: showPackages && showGroups
|
||||||
|
? transformedPackages.length + transformedGroups.length
|
||||||
|
: showPackages
|
||||||
|
? transformedPackages.length
|
||||||
|
: transformedGroups.length
|
||||||
|
}
|
||||||
perPage={perPage}
|
perPage={perPage}
|
||||||
page={page}
|
page={page}
|
||||||
onSetPage={handleSetPage}
|
onSetPage={handleSetPage}
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,13 @@ const searchForGroup = async () => {
|
||||||
await userEvent.type(searchBox, '@grouper');
|
await userEvent.type(searchBox, '@grouper');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearSearchInput = async () => {
|
||||||
|
const clearSearchBtn = await screen.findByRole('button', {
|
||||||
|
name: /clear-package-search/i,
|
||||||
|
});
|
||||||
|
await userEvent.click(clearSearchBtn);
|
||||||
|
};
|
||||||
|
|
||||||
const selectFirstPackage = async () => {
|
const selectFirstPackage = async () => {
|
||||||
await userEvent.click(
|
await userEvent.click(
|
||||||
await screen.findByRole('checkbox', { name: /select row 0/i })
|
await screen.findByRole('checkbox', { name: /select row 0/i })
|
||||||
|
|
@ -262,3 +269,45 @@ describe('Packages edit mode', () => {
|
||||||
expect(receivedRequest).toEqual(expectedRequest);
|
expect(receivedRequest).toEqual(expectedRequest);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('pagination on packages step', () => {
|
||||||
|
test('itemcount correct after search', async () => {
|
||||||
|
await renderCreateMode();
|
||||||
|
await goToPackagesStep();
|
||||||
|
await searchForPackage();
|
||||||
|
await selectFirstPackage();
|
||||||
|
// the pagination in the top right
|
||||||
|
const top = await screen.findByTestId('packages-pagination-top');
|
||||||
|
await expect(top).toHaveTextContent('of 6');
|
||||||
|
const bottom = await screen.findByTestId('packages-pagination-bottom');
|
||||||
|
await expect(bottom).toHaveTextContent('of 6');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('itemcount correct after toggling selected', async () => {
|
||||||
|
await renderCreateMode();
|
||||||
|
await goToPackagesStep();
|
||||||
|
await searchForPackage();
|
||||||
|
await selectFirstPackage();
|
||||||
|
await switchToSelected();
|
||||||
|
|
||||||
|
// the pagination in the top right
|
||||||
|
const top = await screen.findByTestId('packages-pagination-top');
|
||||||
|
await expect(top).toHaveTextContent('of 1');
|
||||||
|
const bottom = await screen.findByTestId('packages-pagination-bottom');
|
||||||
|
await expect(bottom).toHaveTextContent('of 1');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('itemcount correct after clearing search input', async () => {
|
||||||
|
await renderCreateMode();
|
||||||
|
await goToPackagesStep();
|
||||||
|
await searchForPackage();
|
||||||
|
await selectFirstPackage();
|
||||||
|
await clearSearchInput();
|
||||||
|
|
||||||
|
// the pagination in the top right
|
||||||
|
const top = await screen.findByTestId('packages-pagination-top');
|
||||||
|
await expect(top).toHaveTextContent('of 0');
|
||||||
|
const bottom = await screen.findByTestId('packages-pagination-bottom');
|
||||||
|
await expect(bottom).toHaveTextContent('of 0');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue