feat(platform): add trajectory autoplay controls
This commit is contained in:
@@ -5683,6 +5683,57 @@ test('controls trajectory playback current point from history locations', async
|
||||
});
|
||||
});
|
||||
|
||||
test('auto plays trajectory playback points with selectable speed', async () => {
|
||||
window.history.replaceState(null, '', '/#/history?keyword=VIN-TRACK-AUTO&protocol=JT808');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/history/locations')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [
|
||||
{ vin: 'VIN-TRACK-AUTO', plate: '粤A自动1', protocol: 'JT808', longitude: 113.2, latitude: 23.1, speedKmh: 10, socPercent: 0, totalMileageKm: 100, lastSeen: '2026-07-03 10:00:00', deviceTime: '2026-07-03 10:00:00', serverTime: '2026-07-03 10:00:01' },
|
||||
{ vin: 'VIN-TRACK-AUTO', plate: '粤A自动1', protocol: 'JT808', longitude: 113.3, latitude: 23.2, speedKmh: 42, socPercent: 0, totalMileageKm: 112.4, lastSeen: '2026-07-03 10:10:00', deviceTime: '2026-07-03 10:10:00', serverTime: '2026-07-03 10:10:01' },
|
||||
{ vin: 'VIN-TRACK-AUTO', plate: '粤A自动1', protocol: 'JT808', longitude: 113.4, latitude: 23.3, speedKmh: 28, socPercent: 0, totalMileageKm: 119.9, lastSeen: '2026-07-03 10:20:00', deviceTime: '2026-07-03 10:20:00', serverTime: '2026-07-03 10:20:01' }
|
||||
],
|
||||
total: 3,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 10, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('播放速度')).toBeInTheDocument();
|
||||
vi.useFakeTimers();
|
||||
expect(screen.getByText('点 1 / 3')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '播放轨迹' }));
|
||||
expect(screen.getByRole('button', { name: '暂停轨迹' })).toBeInTheDocument();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(1200);
|
||||
expect(screen.getByText('点 2 / 3')).toBeInTheDocument();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(2400);
|
||||
expect(screen.getByText('点 3 / 3')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '播放轨迹' })).toBeInTheDocument();
|
||||
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test('exports current history location page as csv', async () => {
|
||||
window.history.replaceState(null, '', '/#/history?keyword=VIN-EXPORT-LOC&protocol=JT808');
|
||||
const createObjectURL = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:history-location');
|
||||
|
||||
Reference in New Issue
Block a user