feat(monitor): preserve investigation context

This commit is contained in:
lingniu
2026-07-16 17:08:54 +08:00
parent 38b056f5f1
commit 1cfc9c2bdd
17 changed files with 426 additions and 37 deletions

View File

@@ -296,6 +296,29 @@ test('recovers in place after a transient AMap failure and renders data that arr
expect(screen.queryByText(/地图加载失败/)).not.toBeInTheDocument();
});
test('restores the saved monitor viewport without forcing the selected vehicle zoom', async () => {
window.__LINGNIU_APP_CONFIG__ = { amapWebJsKey: 'amap-web-key' };
window.AMapLoader = { load: vi.fn(async () => amapMock()) };
const bounds = '113.100000,23.000000,113.400000,23.300000';
render(<FleetMap
vehicles={[]}
monitorMap={pointMap}
selectedVin="LTEST000000000001"
initialViewport={{ zoom: 13, bounds }}
onSelect={() => undefined}
/>);
await waitFor(() => expect(mapOptions).toHaveLength(1));
expect(mapOptions[0]).toEqual(expect.objectContaining({
zoom: 13,
center: wgs84ToGcj02(113.25, 23.15)
}));
await waitFor(() => expect(markerSetMap).toHaveBeenCalled());
expect(setZoomAndCenter).not.toHaveBeenCalled();
expect(panTo).not.toHaveBeenCalled();
});
test('detaches AMap listeners and destroys the map on unmount', async () => {
window.__LINGNIU_APP_CONFIG__ = { amapWebJsKey: 'amap-web-key' };
window.AMapLoader = { load: vi.fn(async () => amapMock()) };