feat(platform-web): surface vehicle service summary
This commit is contained in:
@@ -141,6 +141,33 @@ test('vehicleServiceOverviews posts keywords to the batch overview endpoint', as
|
||||
expect(result.total).toBe(2);
|
||||
});
|
||||
|
||||
test('vehicleServiceSummary reads the vehicle service summary endpoint', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
totalVehicles: 1033,
|
||||
boundVehicles: 1024,
|
||||
onlineVehicles: 208,
|
||||
singleSourceVehicles: 391,
|
||||
multiSourceVehicles: 181,
|
||||
noDataVehicles: 461,
|
||||
identityRequiredVehicles: 9,
|
||||
serviceStatuses: [{ status: 'healthy', title: '服务正常', count: 161 }],
|
||||
protocols: [{ protocol: 'JT808', online: 157, total: 388 }]
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response);
|
||||
|
||||
const result = await api.vehicleServiceSummary();
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith('/api/vehicle-service/summary', undefined);
|
||||
expect(result.totalVehicles).toBe(1033);
|
||||
expect(result.multiSourceVehicles).toBe(181);
|
||||
});
|
||||
|
||||
test('api errors include backend message, detail, and trace id', async () => {
|
||||
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: false,
|
||||
|
||||
@@ -15,6 +15,7 @@ import type {
|
||||
VehicleDetail,
|
||||
VehicleIdentityResolution,
|
||||
VehicleServiceOverview,
|
||||
VehicleServiceSummary,
|
||||
VehicleRow
|
||||
} from './types';
|
||||
|
||||
@@ -83,6 +84,7 @@ export const api = {
|
||||
vehicleResolve: (params = new URLSearchParams()) => request<VehicleIdentityResolution>(`/api/vehicles/resolve?${params.toString()}`),
|
||||
vehicleCoverage: (params = new URLSearchParams()) => request<Page<VehicleCoverageRow>>(`/api/vehicles/coverage?${params.toString()}`),
|
||||
vehicleDetail: (params = new URLSearchParams()) => request<VehicleDetail>(`/api/vehicle-service?${params.toString()}`),
|
||||
vehicleServiceSummary: () => request<VehicleServiceSummary>('/api/vehicle-service/summary'),
|
||||
vehicleServiceOverview: (params = new URLSearchParams()) => request<VehicleServiceOverview>(`/api/vehicle-service/overview?${params.toString()}`),
|
||||
vehicleServiceOverviews: (query: VehicleOverviewBatchQuery) => request<Page<VehicleServiceOverview>>('/api/vehicle-service/overviews', {
|
||||
method: 'POST',
|
||||
|
||||
@@ -110,6 +110,18 @@ export interface VehicleServiceOverview {
|
||||
serviceStatus?: VehicleServiceStatus;
|
||||
}
|
||||
|
||||
export interface VehicleServiceSummary {
|
||||
totalVehicles: number;
|
||||
boundVehicles: number;
|
||||
onlineVehicles: number;
|
||||
singleSourceVehicles: number;
|
||||
multiSourceVehicles: number;
|
||||
noDataVehicles: number;
|
||||
identityRequiredVehicles: number;
|
||||
serviceStatuses: ServiceStatusStat[];
|
||||
protocols: ProtocolStat[];
|
||||
}
|
||||
|
||||
export interface VehicleServiceStatus {
|
||||
status: string;
|
||||
severity: string;
|
||||
|
||||
Reference in New Issue
Block a user