feat(platform): open quality governance from vehicle detail

This commit is contained in:
lingniu
2026-07-04 08:07:47 +08:00
parent 5fa7858662
commit 7a3f007340
3 changed files with 98 additions and 3 deletions

View File

@@ -3537,6 +3537,74 @@ test('shows unified service overview on vehicle detail', async () => {
expect(screen.getByText('历史 12 / RAW 34 / 里程 7')).toBeInTheDocument();
});
test('opens quality governance from vehicle detail overview', async () => {
window.history.replaceState(null, '', '/#/detail?keyword=VIN001');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/vehicle-service')) {
return {
ok: true,
json: async () => ({
data: {
vin: 'VIN001',
lookupKey: 'VIN001',
lookupResolved: true,
serviceOverview: {
vin: 'VIN001',
plate: '粤AG18312',
phone: '13307795425',
oem: 'G7s',
protocols: ['GB32960', 'JT808'],
primaryProtocol: 'GB32960',
coverageStatus: 'partial',
sourceCount: 2,
onlineSourceCount: 1,
lastSeen: '2026-07-03 20:12:10',
realtimeCount: 2,
historyCount: 12,
rawCount: 34,
mileageCount: 7,
qualityIssueCount: 3
},
sources: ['GB32960', 'JT808'],
sourceStatus: [],
realtime: [],
history: { items: [], total: 12, limit: 20, offset: 0 },
raw: { items: [], total: 34, limit: 10, offset: 0 },
mileage: { items: [], total: 7, limit: 20, offset: 0 },
quality: { items: [], total: 3, limit: 20, offset: 0 }
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: path.includes('/api/ops/health')
? { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } }
: path.includes('/api/quality/summary')
? { issueVehicleCount: 1, issueRecordCount: 3, errorCount: 0, warningCount: 3, protocols: [], issueTypes: [] }
: { items: [], total: 3, limit: 20, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByText('车辆服务概览')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '查看质量问题 3 项' }));
await waitFor(() => {
expect(window.location.hash).toBe('#/quality?keyword=VIN001');
});
expect(await screen.findByRole('heading', { name: '质量治理' })).toBeInTheDocument();
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/quality/issues?keyword=VIN001&limit=20&offset=0'), undefined);
});
test('shows vehicle service evidence chain before source details', async () => {
window.history.replaceState(null, '', '/#/detail?keyword=VIN001');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {