feat(platform): frame realtime sources as evidence

This commit is contained in:
lingniu
2026-07-06 01:49:55 +08:00
parent 442afb8aa5
commit 06904748cc
2 changed files with 74 additions and 9 deletions

View File

@@ -10430,6 +10430,71 @@ test('realtime page prioritizes customer vehicle monitoring command center', asy
expect(screen.getByRole('button', { name: '实时处置优先级 1 粤A实时2 查看告警' })).toBeInTheDocument();
});
test('realtime page treats protocol filters as source evidence for vehicle service', async () => {
window.history.replaceState(null, '', '/#/realtime');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/realtime/vehicles')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-RT-EVIDENCE',
plate: '粤A证据1',
protocols: ['GB32960', 'JT808'],
sourceStatus: [
{ protocol: 'GB32960', online: true, lastSeen: '2026-07-03 20:12:10', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true },
{ protocol: 'JT808', online: true, lastSeen: '2026-07-03 20:12:08', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true }
],
sourceCount: 2,
onlineSourceCount: 2,
online: true,
primaryProtocol: 'GB32960',
longitude: 113.2,
latitude: 23.1,
speedKmh: 30,
socPercent: 78,
totalMileageKm: 119925,
lastSeen: '2026-07-03 20:12:10',
bindingStatus: 'bound',
serviceStatus: {
status: 'healthy',
severity: 'ok',
title: '服务正常',
detail: '2/2 来源在线',
sourceCount: 2,
onlineSourceCount: 2
}
}],
total: 1,
limit: 50,
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.findByRole('heading', { name: '实时监控' })).toBeInTheDocument();
expect(screen.getByText('来源证据筛选')).toBeInTheDocument();
expect(screen.getByText('全部来源证据')).toBeInTheDocument();
expect(screen.getByText('车辆来源证据覆盖')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '筛选来源证据 GB32960' })).toBeInTheDocument();
});
test('frames realtime page as one vehicle service with source evidence', async () => {
window.history.replaceState(null, '', '/#/realtime');
const writeText = vi.fn(() => Promise.resolve());
@@ -11077,10 +11142,10 @@ test('copies realtime operations summary from realtime page', async () => {
expect(screen.getByRole('button', { name: '实时筛选 需要关注 2' })).toBeInTheDocument();
expect(screen.getByText('建议处置')).toBeInTheDocument();
expect(screen.getByText('查看需关注车辆 2')).toBeInTheDocument();
expect(screen.getByText('车辆覆盖概览')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '筛选数据通道 GB32960' })).toHaveTextContent('GB32960');
expect(screen.getByRole('button', { name: '筛选数据通道 JT808' })).toHaveTextContent('2 辆');
expect(screen.getByRole('button', { name: '筛选数据通道 YUTONG_MQTT' })).toHaveTextContent('超时 1');
expect(screen.getByText('车辆来源证据覆盖')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '筛选来源证据 GB32960' })).toHaveTextContent('GB32960');
expect(screen.getByRole('button', { name: '筛选来源证据 JT808' })).toHaveTextContent('2 辆');
expect(screen.getByRole('button', { name: '筛选来源证据 YUTONG_MQTT' })).toHaveTextContent('超时 1');
expect(screen.getByText('实时覆盖判读')).toBeInTheDocument();
expect(screen.getByText('在线率')).toBeInTheDocument();
expect(screen.getAllByText('66.7%').length).toBeGreaterThanOrEqual(3);
@@ -11122,7 +11187,7 @@ test('copies realtime operations summary from realtime page', async () => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史查询http://localhost:3000/api/history/raw-frames?protocol=JT808&vin=VIN-RT-SUMMARY-003&limit=20&includeFields=true'));
fireEvent.click(screen.getByRole('button', { name: '实时筛选 需要关注 2' }));
expect(window.location.hash).toBe('#/realtime?protocol=JT808&serviceStatus=degraded&online=online');
fireEvent.click(screen.getByRole('button', { name: '筛选数据通道 GB32960' }));
fireEvent.click(screen.getByRole('button', { name: '筛选来源证据 GB32960' }));
expect(window.location.hash).toBe('#/realtime?protocol=GB32960&serviceStatus=degraded&online=online');
});