feat(platform): add batch vehicle overview api
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user