fix: unify analytics and report pagination controls
This commit is contained in:
@@ -36,4 +36,61 @@ describe('independent analytics tabs', () => {
|
||||
expect(within(unreported).getByLabelText('统计日期')).toHaveValue('2026-08-25');
|
||||
expect(api.getSignatureRetirementHeatmap).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
['签名通道发送质量', 'getSignatureQuality'],
|
||||
['未报备签名', 'getUnreportedSignatures'],
|
||||
] as const)('keeps %s page size in the footer and resets the page with applied filters', async (tab, method) => {
|
||||
api[method].mockImplementation(async (query) => ({ ...query, total: 120, items: [] }));
|
||||
render(<AdminAnalyticsPage />);
|
||||
fireEvent.click(screen.getByRole('tab', { name: tab }));
|
||||
const panel = screen.getByRole('region', { name: tab });
|
||||
await waitFor(() => expect(within(panel).getByRole('button', { name: '下一页' })).toBeEnabled());
|
||||
fireEvent.change(within(panel).getByLabelText('统计日期'), { target: { value: '2026-08-20' } });
|
||||
fireEvent.click(within(panel).getByRole('button', { name: '查询统计' }));
|
||||
await waitFor(() => expect(api[method]).toHaveBeenLastCalledWith(expect.objectContaining({ date: '2026-08-20' })));
|
||||
fireEvent.click(within(panel).getByRole('button', { name: '下一页' }));
|
||||
await waitFor(() => expect(api[method]).toHaveBeenLastCalledWith(expect.objectContaining({ page: 2 })));
|
||||
// An unsubmitted date must not alter a pagination request.
|
||||
fireEvent.change(within(panel).getByLabelText('统计日期'), { target: { value: '2026-08-21' } });
|
||||
const size = within(panel).getByLabelText(/^每页数量/);
|
||||
expect(size.closest('.ui-pagination')).not.toBeNull();
|
||||
expect(size.closest('.page-actions')).toBeNull();
|
||||
fireEvent.click(size);
|
||||
expect(screen.getAllByRole('option').map((option) => option.textContent)).toEqual([
|
||||
'10 条/页',
|
||||
'25 条/页',
|
||||
'50 条/页',
|
||||
'100 条/页',
|
||||
]);
|
||||
fireEvent.click(screen.getByRole('option', { name: '100 条/页' }));
|
||||
await waitFor(() =>
|
||||
expect(api[method]).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ page: 1, pageSize: 100, date: '2026-08-20' }),
|
||||
),
|
||||
);
|
||||
await waitFor(() => expect(within(panel).getByLabelText('跳转页码')).toHaveValue(1));
|
||||
});
|
||||
|
||||
it.each(['企业签名活跃度', '通道签名活跃度'])(
|
||||
'preserves %s footer size independently even with no rows',
|
||||
async (tab) => {
|
||||
render(<AdminAnalyticsPage />);
|
||||
fireEvent.click(screen.getByRole('tab', { name: tab }));
|
||||
await waitFor(() => expect(api.getSignatureRetirementHeatmap).toHaveBeenCalledTimes(1));
|
||||
const panel = screen.getByRole('region', { name: tab });
|
||||
const size = within(panel).getByLabelText(/^每页数量/);
|
||||
expect(size.closest('.ui-pagination')).not.toBeNull();
|
||||
expect(within(panel).getByRole('button', { name: '下一页' })).toBeDisabled();
|
||||
fireEvent.click(size);
|
||||
fireEvent.click(screen.getByRole('option', { name: '50 条/页' }));
|
||||
fireEvent.click(screen.getByRole('tab', { name: '签名通道发送质量' }));
|
||||
expect(
|
||||
within(screen.getByRole('region', { name: '签名通道发送质量' })).getByLabelText(/^每页数量/),
|
||||
).toHaveTextContent('25 条/页');
|
||||
fireEvent.click(screen.getByRole('tab', { name: tab }));
|
||||
expect(size).toHaveTextContent('50 条/页');
|
||||
expect(api.getSignatureRetirementHeatmap).toHaveBeenCalledTimes(1);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user