feat(platform): add lightweight vehicle overview api

This commit is contained in:
lingniu
2026-07-04 02:52:56 +08:00
parent 38e1bf422a
commit 6c745bf48b
5 changed files with 111 additions and 0 deletions

View File

@@ -64,6 +64,38 @@ test('vehicleResolve sends keyword to the identity resolution endpoint', async (
expect(result.vin).toBe('LB9A32A24R0LS1426');
});
test('vehicleServiceOverview sends keyword to the lightweight overview endpoint', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
json: async () => ({
data: {
vin: 'LB9A32A24R0LS1426',
plate: '粤AG18312',
phone: '13307795425',
oem: 'G7s',
protocols: ['GB32960', 'JT808'],
primaryProtocol: 'JT808',
coverageStatus: 'partial',
sourceCount: 2,
onlineSourceCount: 1,
lastSeen: '2026-07-03 20:12:10',
realtimeCount: 2,
historyCount: 0,
rawCount: 0,
mileageCount: 0,
qualityIssueCount: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response);
const result = await api.vehicleServiceOverview(new URLSearchParams({ keyword: '粤AG18312' }));
expect(fetchMock).toHaveBeenCalledWith('/api/vehicle-service/overview?keyword=%E7%B2%A4AG18312', undefined);
expect(result.coverageStatus).toBe('partial');
});
test('api errors include backend message, detail, and trace id', async () => {
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: false,