feat(platform): show canonical vehicle archive
This commit is contained in:
@@ -5402,3 +5402,80 @@ test('shows actionable vehicle service recommendations on detail', async () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: '补齐 YUTONG_MQTT 来源' }));
|
||||
expect(window.location.hash).toBe('#/vehicles?serviceStatus=degraded&missingProtocol=YUTONG_MQTT');
|
||||
});
|
||||
|
||||
test('shows canonical vehicle archive on detail', async () => {
|
||||
window.history.replaceState(null, '', '/#/detail?keyword=VIN-ARCHIVE-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-ARCHIVE-001',
|
||||
lookupKey: 'VIN-ARCHIVE-001',
|
||||
lookupResolved: true,
|
||||
resolution: {
|
||||
lookupKey: 'VIN-ARCHIVE-001',
|
||||
resolved: true,
|
||||
vin: 'VIN-ARCHIVE-001',
|
||||
plate: '粤A档案1',
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960', 'JT808', 'YUTONG_MQTT'],
|
||||
online: true,
|
||||
lastSeen: '2026-07-03T20:12:10+08:00'
|
||||
},
|
||||
realtimeSummary: {
|
||||
vin: 'VIN-ARCHIVE-001',
|
||||
plate: '粤A档案1',
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960', 'JT808', 'YUTONG_MQTT'],
|
||||
sourceCount: 3,
|
||||
onlineSourceCount: 2,
|
||||
online: true,
|
||||
bindingStatus: 'bound',
|
||||
primaryProtocol: 'GB32960',
|
||||
longitude: 113.2,
|
||||
latitude: 23.1,
|
||||
speedKmh: 32,
|
||||
socPercent: 78,
|
||||
totalMileageKm: 1000.5,
|
||||
lastSeen: '2026-07-03T20:12:10+08:00'
|
||||
},
|
||||
sources: ['GB32960', 'JT808', 'YUTONG_MQTT'],
|
||||
sourceStatus: [],
|
||||
realtime: [],
|
||||
history: { items: [], total: 0, limit: 20, offset: 0 },
|
||||
raw: { items: [], total: 0, limit: 10, offset: 0 },
|
||||
mileage: { items: [], total: 0, 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('车辆主键')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('VIN-ARCHIVE-001').length).toBeGreaterThan(0);
|
||||
expect(screen.getByText('档案完整度')).toBeInTheDocument();
|
||||
expect(screen.getByText('4/4')).toBeInTheDocument();
|
||||
expect(screen.getByText('归并来源数')).toBeInTheDocument();
|
||||
expect(screen.getByText('3')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user