feat(platform): copy trajectory playback summary
This commit is contained in:
@@ -3380,6 +3380,99 @@ test('opens same-day raw evidence from quality issue row', async () => {
|
||||
expect(await screen.findByRole('heading', { name: '轨迹回放' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('copies trajectory playback summary from history page', async () => {
|
||||
window.history.replaceState(null, '', '/#/history?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04');
|
||||
const writeText = vi.fn(() => Promise.resolve());
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: { writeText }
|
||||
});
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/ops/health')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { linkHealth: [], kafkaLag: 0, activeConnections: 0, capacityFindings: [], redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/history/locations')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
vin: 'VIN-HISTORY-SUMMARY',
|
||||
plate: '粤A轨迹1',
|
||||
protocol: 'JT808',
|
||||
longitude: 113.201,
|
||||
latitude: 23.122,
|
||||
speedKmh: 12.5,
|
||||
totalMileageKm: 1000,
|
||||
deviceTime: '2026-07-03 10:00:00',
|
||||
serverTime: '2026-07-03 10:00:02'
|
||||
},
|
||||
{
|
||||
vin: 'VIN-HISTORY-SUMMARY',
|
||||
plate: '粤A轨迹1',
|
||||
protocol: 'JT808',
|
||||
longitude: 113.301,
|
||||
latitude: 23.222,
|
||||
speedKmh: 58.8,
|
||||
totalMileageKm: 1022.6,
|
||||
deviceTime: '2026-07-03 11:00:00',
|
||||
serverTime: '2026-07-03 11:00:02'
|
||||
}
|
||||
],
|
||||
total: 2,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/history/raw-frames/query')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 10, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 20, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect((await screen.findAllByText('VIN-HISTORY-SUMMARY')).length).toBeGreaterThan(0);
|
||||
fireEvent.click(screen.getByRole('button', { name: /复制轨迹摘要/ }));
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【轨迹回放摘要】'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆:VIN-HISTORY-SUMMARY'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('数据来源:JT808'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('查询范围:2026-07-03 至 2026-07-04'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹点:2,有效定位:2'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('区间里程:22.6 km'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('最高速度:58.8 km/h'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('起点:2026-07-03 10:00:00'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('终点:2026-07-03 11:00:00'));
|
||||
});
|
||||
|
||||
test('opens same-day mileage statistics from quality issue row', async () => {
|
||||
window.history.replaceState(null, '', '/#/quality');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user