perf(monitor): aggregate realtime workspace

This commit is contained in:
lingniu
2026-07-16 03:26:14 +08:00
parent 01150844df
commit cad39d6326
12 changed files with 147 additions and 28 deletions

View File

@@ -91,6 +91,13 @@ test('monitor viewport requests forward AbortSignal so obsolete pans can be canc
expect(fetchMock).toHaveBeenCalledWith('/api/v2/monitor/map?zoom=13&bounds=113%2C22%2C114%2C23', { signal: controller.signal });
});
test('monitor workspace aggregates the map screen behind one abortable request', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({ ok: true, json: async () => ({ data: { summary: {}, vehicles: { items: [] }, map: { points: [], clusters: [] } } }) } as Response);
const controller = new AbortController();
await api.monitorWorkspace(new URLSearchParams({ zoom: '13', railLimit: '200' }), controller.signal);
expect(fetchMock).toHaveBeenCalledWith('/api/v2/monitor/workspace?zoom=13&railLimit=200', { signal: controller.signal });
});
test('high-volume history, track, and mileage requests forward AbortSignal', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({ ok: true, json: async () => ({ data: {} }) } as Response);
const controller = new AbortController();