perf(monitor): synchronize map follow frames

This commit is contained in:
lingniu
2026-07-16 10:32:31 +08:00
parent 77f12be63e
commit cf9e2a9803
2 changed files with 11 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ const markerSetMap = vi.fn();
const markerSetPosition = vi.fn();
const labelSetPosition = vi.fn();
const setZoomAndCenter = vi.fn();
const setCenter = vi.fn();
const panTo = vi.fn();
const mapOff = vi.fn();
const mapDestroy = vi.fn();
@@ -45,6 +46,7 @@ class TestMap {
getZoom = getZoom;
getBounds = getBounds;
setZoomAndCenter = setZoomAndCenter;
setCenter = setCenter;
panTo = panTo;
}
@@ -231,6 +233,7 @@ afterEach(() => {
markerSetPosition.mockReset();
labelSetPosition.mockReset();
setZoomAndCenter.mockReset();
setCenter.mockReset();
panTo.mockReset();
mapOff.mockReset();
mapDestroy.mockReset();
@@ -467,7 +470,8 @@ test('renders one selected plate and smoothly follows it until the map is dragge
/>
);
await waitFor(() => expect(markerSetPosition).toHaveBeenLastCalledWith(wgs84ToGcj02(113.27, 23.14)), { timeout: 1_800 });
expect(panTo).toHaveBeenLastCalledWith(wgs84ToGcj02(113.27, 23.14), 10_000);
expect(setCenter).toHaveBeenLastCalledWith(wgs84ToGcj02(113.27, 23.14));
expect(panTo).not.toHaveBeenCalled();
expect(setZoomAndCenter).toHaveBeenCalledTimes(1);
const follow = screen.getByRole('button', { name: '跟随车辆' });