feat(platform): highlight unified vehicle service posture

This commit is contained in:
lingniu
2026-07-04 09:01:34 +08:00
parent f651e48434
commit ad932565ed
2 changed files with 81 additions and 0 deletions

View File

@@ -135,6 +135,68 @@ test('dashboard renders vehicle service summary metrics', async () => {
expect(fetchMock).toHaveBeenCalledWith('/api/vehicle-service/summary', undefined);
});
test('dashboard presents one vehicle service operating posture', async () => {
window.history.replaceState(null, '', '/#/dashboard');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/dashboard/summary')) {
return {
ok: true,
json: async () => ({
data: {
onlineVehicles: 3,
activeToday: 4,
frameToday: 1286320,
issueVehicles: 7,
kafkaLag: 0,
protocols: [],
serviceStatuses: [],
linkHealth: []
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/vehicle-service/summary')) {
return {
ok: true,
json: async () => ({
data: {
totalVehicles: 1033,
boundVehicles: 1024,
onlineVehicles: 208,
singleSourceVehicles: 391,
multiSourceVehicles: 181,
noDataVehicles: 461,
identityRequiredVehicles: 9,
serviceStatuses: [],
protocols: [],
missingSources: []
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 8, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByText('统一车辆服务')).toBeInTheDocument();
expect(screen.getByText('208 / 1,033 在线')).toBeInTheDocument();
expect(screen.getByText('181 多源覆盖')).toBeInTheDocument();
expect(screen.getByText('7 质量关注')).toBeInTheDocument();
});
test('dashboard keeps core vehicle service metrics when preview requests fail', async () => {
window.history.replaceState(null, '', '/#/dashboard');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {