feat(platform): show vehicle location posture
This commit is contained in:
@@ -7952,8 +7952,8 @@ test('switches vehicle detail to a source from the source matrix', async () => {
|
||||
expect(screen.getByText('暂无来源')).toBeInTheDocument();
|
||||
expect(screen.getByText('最新位置')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('113.2, 23.1').length).toBeGreaterThan(0);
|
||||
expect(screen.getByText(/100\s*km/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/30\s*km\/h/)).toBeInTheDocument();
|
||||
expect(screen.getAllByText(/100\s*km/).length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText(/30\s*km\/h/).length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('YUTONG_MQTT').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('无上报').length).toBeGreaterThan(0);
|
||||
fireEvent.click(screen.getByRole('button', { name: '仅看 JT808' }));
|
||||
@@ -8268,6 +8268,84 @@ test('shows vehicle service evidence chain before source details', async () => {
|
||||
expect(screen.getAllByText('MQTT 离线,32960 与 808 仍可支撑车辆服务').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('shows unified latest location posture on vehicle detail', async () => {
|
||||
window.history.replaceState(null, '', '/#/detail?keyword=VIN-MAP-001');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/vehicle-service')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
vin: 'VIN-MAP-001',
|
||||
lookupKey: 'VIN-MAP-001',
|
||||
lookupResolved: true,
|
||||
serviceOverview: {
|
||||
vin: 'VIN-MAP-001',
|
||||
plate: '粤A地图1',
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960', 'JT808', 'YUTONG_MQTT'],
|
||||
primaryProtocol: 'GB32960',
|
||||
coverageStatus: 'partial',
|
||||
sourceCount: 3,
|
||||
onlineSourceCount: 2,
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
realtimeCount: 3,
|
||||
historyCount: 12,
|
||||
rawCount: 34,
|
||||
mileageCount: 7,
|
||||
qualityIssueCount: 0
|
||||
},
|
||||
serviceStatus: {
|
||||
status: 'degraded',
|
||||
severity: 'warning',
|
||||
title: '来源不完整',
|
||||
detail: '2/3 个来源在线',
|
||||
sourceCount: 3,
|
||||
onlineSourceCount: 2
|
||||
},
|
||||
sources: ['GB32960', 'JT808', 'YUTONG_MQTT'],
|
||||
sourceStatus: [
|
||||
{ protocol: 'GB32960', online: true, lastSeen: '2026-07-03 20:12:10', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true },
|
||||
{ protocol: 'JT808', online: true, lastSeen: '2026-07-03 20:12:08', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true },
|
||||
{ protocol: 'YUTONG_MQTT', online: false, lastSeen: '2026-07-03 20:10:05', hasRealtime: false, hasHistory: false, hasRaw: true, hasMileage: false }
|
||||
],
|
||||
realtime: [
|
||||
{ vin: 'VIN-MAP-001', plate: '粤A地图1', protocol: 'GB32960', longitude: 113.2, latitude: 23.1, speedKmh: 36, socPercent: 76, totalMileageKm: 1200.5, lastSeen: '2026-07-03 20:12:10' },
|
||||
{ vin: 'VIN-MAP-001', plate: '粤A地图1', protocol: 'JT808', longitude: 113.21, latitude: 23.11, speedKmh: 35, socPercent: 0, totalMileageKm: 1200.2, lastSeen: '2026-07-03 20:12:08' }
|
||||
],
|
||||
history: { items: [], total: 12, limit: 20, offset: 0 },
|
||||
raw: { items: [], total: 34, limit: 10, offset: 0 },
|
||||
mileage: { items: [], total: 7, limit: 20, offset: 0 },
|
||||
quality: { items: [], total: 0, limit: 20, offset: 0 }
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: path.includes('/api/ops/health')
|
||||
? { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } }
|
||||
: { items: [], total: 0, limit: 10, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('车辆位置态势')).toBeInTheDocument();
|
||||
expect(screen.getByText('2 个来源有最新位置')).toBeInTheDocument();
|
||||
expect(screen.getByText('GB32960 / 36 km/h')).toBeInTheDocument();
|
||||
expect(screen.getByText('JT808 / 35 km/h')).toBeInTheDocument();
|
||||
expect(screen.getByText('高德地图未配置,显示车辆服务坐标预览')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('copies shareable vehicle service detail link', async () => {
|
||||
window.history.replaceState(null, '', '/#/detail?keyword=VIN001&protocol=JT808');
|
||||
const writeText = vi.fn(() => Promise.resolve());
|
||||
|
||||
Reference in New Issue
Block a user