fix(platform): load vehicle context by source

This commit is contained in:
lingniu
2026-07-04 06:41:55 +08:00
parent c70af50cec
commit 2feaf246be
2 changed files with 21 additions and 13 deletions

View File

@@ -2195,7 +2195,7 @@ test('opens current vehicle service from history header with current source evid
test('opens vehicle service from realtime vehicles with primary source evidence', async () => {
window.history.replaceState(null, '', '/#/realtime');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/realtime/vehicles')) {
return {
@@ -2228,20 +2228,22 @@ test('opens vehicle service from realtime vehicles with primary source evidence'
})
} as Response;
}
if (path.includes('/api/vehicles/resolve')) {
if (path.includes('/api/vehicle-service/overview')) {
return {
ok: true,
json: async () => ({
data: {
lookupKey: 'VIN-MQTT-001',
resolved: true,
vin: 'VIN-MQTT-001',
plate: '川AHTWO1',
phone: '',
oem: '宇通',
protocols: ['GB32960', 'YUTONG_MQTT'],
online: true,
lastSeen: '2026-07-03 20:12:10'
sourceCount: 2,
onlineSourceCount: 1,
coverageStatus: 'online',
primaryProtocol: 'YUTONG_MQTT',
lastSeen: '2026-07-03 20:12:10',
historyCount: 0,
rawCount: 0,
mileageCount: 0,
qualityIssueCount: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
@@ -2266,6 +2268,7 @@ test('opens vehicle service from realtime vehicles with primary source evidence'
await waitFor(() => {
expect(window.location.hash).toBe('#/detail?keyword=VIN-MQTT-001&protocol=YUTONG_MQTT');
});
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/vehicle-service/overview?keyword=VIN-MQTT-001&protocol=YUTONG_MQTT'), undefined);
});
test('shows canonical service status in realtime vehicles', async () => {