fix(pagination): 统一表格分页与密钥查询交互
统一各中心表格的分页样式和切换行为,保留密钥筛选条件与兑换码搜索分页。
This commit is contained in:
@@ -185,6 +185,19 @@ for (const cfg of [
|
||||
fn: 'fetchInvoices',
|
||||
expectedPath: '/api/invoice/list',
|
||||
},
|
||||
{
|
||||
file: 'src/pages/UserCenter/Invoice.jsx',
|
||||
fn: 'fetchInvoices',
|
||||
expectedPath: '/api/user/invoice/self',
|
||||
values: { invoicesPage: 3, invoicesPageSize: 50 },
|
||||
},
|
||||
{
|
||||
file: 'src/hooks/redemptions/useRedemptionsData.jsx',
|
||||
fn: 'loadSearchResults',
|
||||
expectedPath: '/api/redemption/search',
|
||||
args: ['pagination-fixture', 3, 50],
|
||||
values: { setRedemptionFormat: () => {} },
|
||||
},
|
||||
{
|
||||
file: 'src/pages/AdminOrganizations/index.jsx',
|
||||
fn: 'fetchOrgs',
|
||||
@@ -354,10 +367,16 @@ test('Resizing emits one size callback and never a stale page request', () => {
|
||||
events.onChange(3, 50);
|
||||
assert.deepEqual(calls, [['size', 50]]);
|
||||
events.onChange(2, 10);
|
||||
assert.deepEqual(calls.slice(1), [
|
||||
['page', 2],
|
||||
['change', 2, 10],
|
||||
]);
|
||||
assert.deepEqual(calls.slice(1), [['page', 2]]);
|
||||
});
|
||||
test('Combined change handlers receive page one with the new size', () => {
|
||||
const calls = [];
|
||||
const events = pagination.centerPaginationEvents({
|
||||
pageSize: 20,
|
||||
onChange: (page, size) => calls.push([page, size]),
|
||||
});
|
||||
events.onChange(3, 50);
|
||||
assert.deepEqual(calls, [[1, 50]]);
|
||||
});
|
||||
test('Legacy Ant resize handlers receive page one exactly once', () => {
|
||||
const calls = [];
|
||||
@@ -424,6 +443,36 @@ test('Tables with pagination false or omitted never gain a paginator', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('Supplied page rows pass through, while complete datasets are sliced locally', () => {
|
||||
const dataSource = Array.from({ length: 25 }, (_, index) => ({
|
||||
id: index + 1,
|
||||
name: `pagination-row-${index + 1}-end`,
|
||||
}));
|
||||
const render = (config) =>
|
||||
renderToStaticMarkup(
|
||||
Table({
|
||||
rowKey: 'id',
|
||||
columns: [{ dataIndex: 'name' }],
|
||||
dataSource,
|
||||
pagination: { currentPage: 2, pageSize: 10, ...config },
|
||||
}),
|
||||
);
|
||||
|
||||
const local = render({});
|
||||
assert.match(local, /pagination-row-11-end/);
|
||||
assert.doesNotMatch(local, /pagination-row-(1|21)-end/);
|
||||
assert.match(local, /ant-pagination-options-size-changer/);
|
||||
|
||||
const supplied = render({ total: 75, onPageSizeChange() {} });
|
||||
assert.match(supplied, /pagination-row-1-end/);
|
||||
assert.match(supplied, /pagination-row-25-end/);
|
||||
assert.match(supplied, /ant-pagination-options-size-changer/);
|
||||
assert.doesNotMatch(
|
||||
render({ total: 75 }),
|
||||
/ant-pagination-options-size-changer/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Existing unpaginated tables keep pagination disabled after other UI edits', async () => {
|
||||
const expected = JSON.parse(
|
||||
await fs.readFile(
|
||||
|
||||
Reference in New Issue
Block a user