mirror of
https://github.com/inventree/InvenTree.git
synced 2025-09-13 06:01:35 +00:00
Table pagination fix (#10236)
* Correct pagination offset calculation * Add playwright tests * Enhanced playwright test * Add comment * Fix typo
This commit is contained in:
@@ -355,7 +355,7 @@ export function InvenTreeTable<T extends Record<string, any>>({
|
||||
useEffect(() => {
|
||||
if (
|
||||
tableState.page > 1 &&
|
||||
pageSize * tableState.page > tableState.recordCount
|
||||
pageSize * (tableState.page - 1) > tableState.recordCount
|
||||
) {
|
||||
tableState.setPage(1);
|
||||
} else if (tableState.page < 1) {
|
||||
|
@@ -33,7 +33,7 @@ export const clickButtonIfVisible = async (page, name, timeout = 500) => {
|
||||
*/
|
||||
export const clearTableFilters = async (page) => {
|
||||
await openFilterDrawer(page);
|
||||
await clickButtonIfVisible(page, 'Clear Filters');
|
||||
await clickButtonIfVisible(page, 'Clear Filters', 250);
|
||||
await closeFilterDrawer(page);
|
||||
await page.waitForLoadState('networkidle');
|
||||
};
|
||||
|
@@ -39,6 +39,38 @@ test('Tables - Filters', async ({ browser }) => {
|
||||
await clearTableFilters(page);
|
||||
});
|
||||
|
||||
test('Tables - Pagination', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
url: 'manufacturing/index/buildorders',
|
||||
username: 'steven',
|
||||
password: 'wizardstaff'
|
||||
});
|
||||
|
||||
await clearTableFilters(page);
|
||||
|
||||
// Expected pagination size is 25
|
||||
// Note: Due to other tests, there may be more than 25 items in the list
|
||||
await page.getByText(/1 - 25 \/ 2[2|8]/).waitFor();
|
||||
await page.getByRole('button', { name: 'Next page' }).click();
|
||||
await page.getByText(/26 - 2[7|8] \/ 2[7|8]/).waitFor();
|
||||
|
||||
// Set page size to 10
|
||||
await page.getByRole('button', { name: '25' }).click();
|
||||
await page.getByRole('menuitem', { name: '10', exact: true }).click();
|
||||
|
||||
await page.getByText(/1 - 10 \/ 2[7|8]/).waitFor();
|
||||
await page.getByRole('button', { name: '3' }).click();
|
||||
await page.getByText(/21 - 2[7|8] \/ 2[7|8]/).waitFor();
|
||||
await page.getByRole('button', { name: 'Previous page' }).click();
|
||||
await page.getByText(/11 - 20 \/ 2[7|8]/).waitFor();
|
||||
|
||||
// Set page size back to 25
|
||||
await page.getByRole('button', { name: '10' }).click();
|
||||
await page.getByRole('menuitem', { name: '25', exact: true }).click();
|
||||
|
||||
await page.getByText(/1 - 25 \/ 2[7|8]/).waitFor();
|
||||
});
|
||||
|
||||
test('Tables - Columns', async ({ browser }) => {
|
||||
// Go to the "stock list" page
|
||||
const page = await doCachedLogin(browser, {
|
||||
|
Reference in New Issue
Block a user