fix(platform): align topbar missing source status
This commit is contained in:
@@ -417,6 +417,7 @@ function normalizeHistoryFilterValues(filters: Record<string, unknown> = {}): Re
|
||||
function serviceStatusFromOverview(overview: VehicleServiceOverview): VehicleServiceStatus {
|
||||
const sourceCount = overview.sourceCount;
|
||||
const onlineSourceCount = overview.onlineSourceCount;
|
||||
const missingProtocols = overview.sourceConsistency?.missingProtocols ?? [];
|
||||
if (!overview.vin) {
|
||||
return {
|
||||
status: 'identity_required',
|
||||
@@ -447,6 +448,16 @@ function serviceStatusFromOverview(overview: VehicleServiceOverview): VehicleSer
|
||||
onlineSourceCount
|
||||
};
|
||||
}
|
||||
if (missingProtocols.length > 0) {
|
||||
return {
|
||||
status: 'degraded',
|
||||
severity: 'warning',
|
||||
title: '来源不完整',
|
||||
detail: `${onlineSourceCount}/${sourceCount} 个来源在线,车辆服务可用但缺少 ${missingProtocols.join('、')} 来源。`,
|
||||
sourceCount,
|
||||
onlineSourceCount
|
||||
};
|
||||
}
|
||||
if (onlineSourceCount < sourceCount) {
|
||||
return {
|
||||
status: 'degraded',
|
||||
|
||||
@@ -619,25 +619,18 @@ test('shows resolved vehicle service status after topbar search', async () => {
|
||||
rawCount: 0,
|
||||
mileageCount: 0,
|
||||
qualityIssueCount: 0,
|
||||
serviceStatus: {
|
||||
status: 'degraded',
|
||||
severity: 'warning',
|
||||
title: '后端判定部分离线',
|
||||
detail: '后端统一车辆服务状态',
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 1
|
||||
},
|
||||
sourceConsistency: {
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 1,
|
||||
locatedSourceCount: 2,
|
||||
missingProtocols: ['YUTONG_MQTT'],
|
||||
mileageDeltaKm: 0,
|
||||
sourceTimeDeltaSeconds: 0,
|
||||
scope: 'all_sources',
|
||||
status: 'degraded',
|
||||
severity: 'warning',
|
||||
title: '部分来源离线',
|
||||
detail: '1/2 个来源在线,车辆服务可用但需要关注离线来源。'
|
||||
title: '来源不完整',
|
||||
detail: '1/2 个来源在线,车辆服务可用但缺少 YUTONG_MQTT 来源。'
|
||||
}
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
@@ -681,9 +674,9 @@ test('shows resolved vehicle service status after topbar search', async () => {
|
||||
fireEvent.change(screen.getByPlaceholderText('搜索 VIN / 车牌 / 手机号'), { target: { value: '粤AG18312' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: '查询车辆' }));
|
||||
|
||||
expect(await screen.findByText('当前车辆:后端判定部分离线')).toBeInTheDocument();
|
||||
expect(await screen.findByText('当前车辆:来源不完整')).toBeInTheDocument();
|
||||
expect(screen.getByText('粤AG18312 / LB9A32A24R0LS1426')).toBeInTheDocument();
|
||||
expect(screen.getByText('一致性:部分来源离线')).toBeInTheDocument();
|
||||
expect(screen.getByText('一致性:来源不完整')).toBeInTheDocument();
|
||||
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/vehicle-service/overview?keyword=%E7%B2%A4AG18312'), undefined);
|
||||
expect(fetchMock).not.toHaveBeenCalledWith(expect.stringContaining('/api/vehicles/resolve'), undefined);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user