feat(platform-web): summarize vehicle list results

This commit is contained in:
lingniu
2026-07-04 03:37:20 +08:00
parent a2ccc4a498
commit 6683ce4df7
3 changed files with 117 additions and 0 deletions

View File

@@ -177,6 +177,74 @@ test('opens vehicle list filtered by service summary KPI', async () => {
expect(window.location.hash).toBe('#/vehicles?coverage=multi');
});
test('shows vehicle service result summary on vehicle list filters', async () => {
window.history.replaceState(null, '', '/#/vehicles?coverage=multi');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/ops/health')) {
return {
ok: true,
json: async () => ({
data: { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/vehicles/coverage')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-MULTI-001',
plate: '粤A服务1',
phone: '13307795425',
oem: 'G7s',
protocols: ['GB32960', 'JT808'],
sourceCount: 2,
onlineSourceCount: 1,
online: true,
lastSeen: '2026-07-03 20:12:10',
bindingStatus: 'bound',
serviceStatus: {
status: 'degraded',
severity: 'warning',
title: '部分来源离线',
detail: '1/2 个来源在线',
sourceCount: 2,
onlineSourceCount: 1
}
}],
total: 181,
limit: 20,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 10, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByText('当前车辆结果')).toBeInTheDocument();
expect(screen.getByText('181')).toBeInTheDocument();
expect(screen.getByText('过滤车辆')).toBeInTheDocument();
expect(screen.getByText('本页在线')).toBeInTheDocument();
expect(screen.getByText('本页多源')).toBeInTheDocument();
expect(screen.getByText('VIN-MULTI-001')).toBeInTheDocument();
});
test('shows resolved vehicle service status after topbar search', async () => {
window.history.replaceState(null, '', '/#/dashboard');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {