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

@@ -66,6 +66,21 @@ test('keeps committed track criteria authoritative to same-route navigation and
expect(screen.getByTestId('track-map')).toHaveAttribute('data-point-count', '0');
});
test('distinguishes a failed vehicle lookup from an empty result and retries in place', async () => {
mocks.vehicles.mockRejectedValueOnce(new Error('车辆目录暂时不可用')).mockResolvedValueOnce({ items: [{ vin: 'LTEST000000000001', plate: '粤A12345' }], total: 1, limit: 10, offset: 0 });
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
render(<QueryClientProvider client={client}><MemoryRouter future={ROUTER_FUTURE} initialEntries={['/tracks']}><TrackPage /></MemoryRouter></QueryClientProvider>);
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('renders a map-first replay workspace and connects stop, event, and panel interactions', async () => {
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
const view = render(<QueryClientProvider client={client}><MemoryRouter future={ROUTER_FUTURE} initialEntries={['/tracks?keyword=LTEST000000000001&dateFrom=2026-07-15T00:00&dateTo=2026-07-15T23:59']}><TrackPage /></MemoryRouter></QueryClientProvider>);