feat(platform): add online vehicle statistics detail

This commit is contained in:
lingniu
2026-07-04 17:47:38 +08:00
parent d266396c47
commit 3b817ef874
9 changed files with 253 additions and 2 deletions

View File

@@ -198,6 +198,39 @@ test('qualityNotificationPlan reads alert rules and priority issues from backend
expect(result.priorityIssues[0].notificationText).toContain('告警通知');
});
test('onlineVehicleStatuses reads paged online vehicle status rows', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
json: async () => ({
data: {
items: [{
vin: 'LB9A32A24R0LS1426',
plate: '粤AG18312',
phone: '13307795425',
oem: 'G7s',
protocols: ['JT808', 'GB32960'],
online: false,
lastSeen: '2026-07-03 20:12:10',
offlineDurationMinutes: 18,
sourceCount: 2,
onlineSourceCount: 0,
bindingStatus: 'bound'
}],
total: 1,
limit: 10,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response);
const result = await api.onlineVehicleStatuses(new URLSearchParams({ keyword: '粤AG18312', limit: '10' }));
expect(fetchMock).toHaveBeenCalledWith('/api/statistics/online-vehicles?keyword=%E7%B2%A4AG18312&limit=10', undefined);
expect(result.items[0].offlineDurationMinutes).toBe(18);
});
test('api errors include backend message, detail, and trace id', async () => {
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: false,