feat(platform): add batch vehicle overview api

This commit is contained in:
lingniu
2026-07-04 03:05:27 +08:00
parent 1a86e5d38c
commit f996fa0df9
5 changed files with 141 additions and 0 deletions

View File

@@ -105,6 +105,42 @@ test('vehicleServiceOverview sends keyword to the lightweight overview endpoint'
expect(result.serviceStatus?.status).toBe('degraded');
});
test('vehicleServiceOverviews posts keywords to the batch overview endpoint', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
json: async () => ({
data: {
items: [
{ vin: 'VIN001', plate: '粤AG18312', protocols: ['JT808'], coverageStatus: 'online', sourceCount: 1, onlineSourceCount: 1 },
{ vin: 'VIN002', plate: '豫A88888', protocols: ['YUTONG_MQTT'], coverageStatus: 'online', sourceCount: 1, onlineSourceCount: 1 }
],
total: 2,
limit: 200,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response);
const result = await api.vehicleServiceOverviews({
keywords: ['粤AG18312', 'LMRKH9AC2R1004087'],
limit: 200,
offset: 0
});
expect(fetchMock).toHaveBeenCalledWith('/api/vehicle-service/overviews', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
keywords: ['粤AG18312', 'LMRKH9AC2R1004087'],
limit: 200,
offset: 0
})
});
expect(result.total).toBe(2);
});
test('api errors include backend message, detail, and trace id', async () => {
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: false,