refine Semi UI vehicle discovery workspace
This commit is contained in:
@@ -137,7 +137,7 @@ test('shows deduplicated Semi vehicle candidates and opens the selected VIN', as
|
||||
const vehicles = vi.spyOn(api, 'vehicles').mockResolvedValue({
|
||||
items: [candidate, { ...candidate }],
|
||||
total: 2,
|
||||
limit: 8,
|
||||
limit: 12,
|
||||
offset: 0
|
||||
});
|
||||
vi.spyOn(api, 'vehicleDetail').mockResolvedValue(detail);
|
||||
@@ -147,15 +147,16 @@ test('shows deduplicated Semi vehicle candidates and opens the selected VIN', as
|
||||
|
||||
const view = render(<QueryClientProvider client={client}><MemoryRouter initialEntries={['/vehicles']} future={ROUTER_FUTURE}><Routes><Route path="/vehicles" element={<VehiclePage />} /><Route path="/vehicles/:vin" element={<VehiclePage />} /></Routes></MemoryRouter></QueryClientProvider>);
|
||||
|
||||
const capabilitySummary = screen.getByLabelText('可查询的数据范围');
|
||||
expect(capabilitySummary).toHaveTextContent('统一身份');
|
||||
expect(capabilitySummary).toHaveTextContent('实时状态');
|
||||
expect(capabilitySummary).toHaveTextContent('来源证据');
|
||||
expect(screen.getByRole('heading', { name: '车辆查询', level: 2 })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: '车辆定位', level: 5 }).closest('.semi-card')).toHaveClass('v2-vehicle-query-panel', 'v2-workspace-filter-panel');
|
||||
const input = screen.getByRole('textbox', { name: '搜索车辆' });
|
||||
expect(input).toHaveAttribute('aria-expanded', 'false');
|
||||
expect(input).toHaveAttribute('aria-controls', 'v2-vehicle-search-options');
|
||||
expect(view.container.querySelector('.v2-vehicle-search-options')).not.toBeInTheDocument();
|
||||
await waitFor(() => expect(vehicles).toHaveBeenCalledTimes(1));
|
||||
const initialQuery = vehicles.mock.calls[0]?.[0];
|
||||
expect(initialQuery).toBeDefined();
|
||||
expect(initialQuery!.get('limit')).toBe('12');
|
||||
expect(screen.getByRole('heading', { name: '最近上报车辆', level: 5 })).toBeInTheDocument();
|
||||
expect(await screen.findByText('当前显示 1 辆')).toBeInTheDocument();
|
||||
expect(screen.getAllByRole('listitem', { name: `打开 ${initialRealtime.plate} 车辆档案` })).toHaveLength(1);
|
||||
@@ -180,6 +181,34 @@ test('shows deduplicated Semi vehicle candidates and opens the selected VIN', as
|
||||
workspace.remove();
|
||||
});
|
||||
|
||||
test('defaults to a compact mobile vehicle directory and keeps eight recent vehicles', async () => {
|
||||
layout.mobile = true;
|
||||
const items = Array.from({ length: 10 }, (_, index) => ({
|
||||
vin: `LTEST${String(index).padStart(12, '0')}`,
|
||||
plate: `粤A${String(index).padStart(5, '0')}`,
|
||||
phone: '',
|
||||
oem: '测试品牌',
|
||||
protocol: index % 2 ? 'JT808' : 'GB32960',
|
||||
online: index < 6,
|
||||
lastSeen: `2026-07-16 10:00:${String(index).padStart(2, '0')}`,
|
||||
locationText: '广东省广州市',
|
||||
bindingScore: 100
|
||||
}));
|
||||
vi.spyOn(api, 'vehicles').mockResolvedValue({ items, total: 10, limit: 12, offset: 0 });
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
|
||||
const view = render(<QueryClientProvider client={client}><MemoryRouter initialEntries={['/vehicles']} future={ROUTER_FUTURE}><Routes><Route path="/vehicles" element={<VehiclePage />} /></Routes></MemoryRouter></QueryClientProvider>);
|
||||
|
||||
expect(await screen.findByText('当前显示 8 辆')).toBeInTheDocument();
|
||||
expect(screen.getAllByRole('listitem', { name: /打开 .* 车辆档案/ })).toHaveLength(8);
|
||||
expect(view.container.querySelector('.v2-vehicle-query-panel')).toHaveClass('is-mobile-collapsed');
|
||||
const toggle = screen.getByRole('button', { name: '修改车辆定位:10 辆授权车辆' });
|
||||
expect(toggle).toHaveAttribute('aria-expanded', 'false');
|
||||
fireEvent.click(toggle);
|
||||
expect(view.container.querySelector('.v2-vehicle-query-panel')).not.toHaveClass('is-mobile-collapsed');
|
||||
expect(screen.getByRole('textbox', { name: '搜索车辆' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('keeps the monitor return on the vehicle page and its nested investigation actions', async () => {
|
||||
vi.spyOn(api, 'vehicleDetail').mockResolvedValue(detail);
|
||||
vi.spyOn(api, 'vehicleRealtime').mockResolvedValue({ items: [initialRealtime], total: 1, limit: 1, offset: 0 });
|
||||
|
||||
Reference in New Issue
Block a user