fix(web): recover vehicle option lookups

This commit is contained in:
lingniu
2026-07-16 07:38:39 +08:00
parent 25e8427882
commit e9b7c0d31f
5 changed files with 37 additions and 2 deletions

View File

@@ -117,6 +117,21 @@ test('supports searching and selecting license plates before querying exact VINs
expect(screen.getByTitle('LTEST000000000001')).toHaveTextContent('粤A12345');
});
test('shows and recovers from a failed license plate candidate query', async () => {
prepareData();
mocks.vehicles.mockRejectedValueOnce(new Error('车辆目录查询超时')).mockResolvedValueOnce({ items: [{ vin: 'LTEST000000000001', plate: '粤A12345' }], total: 1, limit: 12, offset: 0 });
renderPage();
fireEvent.focus(screen.getByRole('textbox', { name: '搜索车牌' }));
expect(await screen.findByRole('alert')).toHaveTextContent('车辆目录查询超时');
expect(screen.queryByText('没有匹配的车牌')).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '重试' }));
expect(await screen.findByRole('option', { name: /粤A12345/ })).toBeInTheDocument();
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
expect(mocks.vehicles).toHaveBeenCalledTimes(2);
});
test('lets users disable mileage sources and persists the source priority', async () => {
prepareData();
renderPage('/statistics?vins=LTEST000000000001&dateFrom=2026-07-13&dateTo=2026-07-14');