fix(pagination): 统一表格分页与密钥查询交互
统一各中心表格的分页样式与切换行为,保留密钥筛选条件和兑换码搜索分页。 验证:871 项单测、ESLint、Prettier 和本地浏览器验收通过。
This commit is contained in:
@@ -145,7 +145,7 @@ async function modelTestFixture() {
|
||||
),
|
||||
Typography: { Text: 'Text' },
|
||||
},
|
||||
'../../../ui/CenterActionTable': 'Table',
|
||||
'@/components/ui': { Table: 'Table' },
|
||||
'lucide-react': { Search: 'Search' },
|
||||
'./model-test-modal.css': {},
|
||||
'../../../../helpers': {},
|
||||
@@ -180,13 +180,13 @@ async function modelTestFixture() {
|
||||
};
|
||||
}
|
||||
|
||||
test('Model test dialog passes the complete filtered list to native Ant pagination', async () => {
|
||||
test('Model test dialog passes the complete filtered list to local table pagination', async () => {
|
||||
const { table, models } = await modelTestFixture();
|
||||
assert.deepEqual(
|
||||
Array.from(table.dataSource, (row) => row.model),
|
||||
models,
|
||||
);
|
||||
assert.equal(table.pagination.total, 24);
|
||||
assert.equal(table.pagination.total, undefined);
|
||||
assert.equal(table.pagination.current, 2);
|
||||
assert.equal(table.pagination.pageSize, 5);
|
||||
const html = renderToStaticMarkup(React.createElement(AntTable, table));
|
||||
|
||||
@@ -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