fix(mileage): bound daily date ranges

This commit is contained in:
lingniu
2026-07-16 08:44:00 +08:00
parent 91b5d76657
commit 99d9dcca1b
5 changed files with 72 additions and 13 deletions

View File

@@ -56,6 +56,17 @@ test('renders only the desktop matrix with dates as columns and a period total',
expect(mocks.dailyMileage.mock.calls[0][0].get('protocols')).toBe('GB32960,JT808,YUTONG_MQTT');
});
test('rejects overlong mileage ranges before querying or rendering a huge matrix', async () => {
prepareData();
const view = renderPage('/statistics?vins=LTEST000000000001&dateFrom=2025-01-01&dateTo=2026-07-14');
expect(await screen.findByRole('alert')).toHaveTextContent('单次最多查询 366 个自然日');
expect(mocks.mileageStatistics).not.toHaveBeenCalled();
expect(mocks.dailyMileage).not.toHaveBeenCalled();
expect(view.container.querySelectorAll('.v2-mileage-table th.is-date')).toHaveLength(0);
expect(screen.getByRole('button', { name: '导出 Excel' })).toBeDisabled();
});
test('removes the previous mileage scope while a new date range is loading', async () => {
prepareData();
renderPage('/statistics?vins=LTEST000000000001&dateFrom=2026-07-13&dateTo=2026-07-14');