feat(platform): drill quality issues by source
This commit is contained in:
@@ -139,6 +139,9 @@ export function Quality({
|
||||
}
|
||||
applyFilters({ ...filters, issueType: primaryIssueType });
|
||||
};
|
||||
const drillProtocol = (protocol: string) => {
|
||||
applyFilters({ ...filters, protocol });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="vp-page">
|
||||
@@ -184,6 +187,24 @@ export function Quality({
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<Card bordered title="问题来源分布" loading={loadingSummary} style={{ marginTop: 16 }}>
|
||||
<Table
|
||||
pagination={false}
|
||||
dataSource={summary.protocols}
|
||||
rowKey="name"
|
||||
columns={[
|
||||
{ title: '数据来源', render: (_: unknown, row: { name: string }) => qualityProtocolLabel(row.name) },
|
||||
{ title: '问题数', dataIndex: 'count', width: 120 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 140,
|
||||
render: (_: unknown, row: { name: string }) => (
|
||||
<Button size="small" onClick={() => drillProtocol(row.name)}>查看 {qualityProtocolLabel(row.name)} 质量问题</Button>
|
||||
)
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
<Card bordered title="质量问题" style={{ marginTop: 16 }}>
|
||||
<Form key={JSON.stringify(filters)} initValues={filters} layout="horizontal" onSubmit={(values) => {
|
||||
const nextFilters = values as Record<string, string>;
|
||||
|
||||
@@ -1587,6 +1587,76 @@ test('drills into quality issues by issue type', async () => {
|
||||
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/quality/summary?issueType=NO_SOURCE'), undefined);
|
||||
});
|
||||
|
||||
test('drills into quality issues by protocol bucket', async () => {
|
||||
window.history.replaceState(null, '', '/#/quality');
|
||||
const fetchMock = 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/quality/summary')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
issueVehicleCount: 2,
|
||||
issueRecordCount: 3,
|
||||
errorCount: 1,
|
||||
warningCount: 2,
|
||||
protocols: [
|
||||
{ name: 'JT808', count: 2 },
|
||||
{ name: 'VEHICLE_SERVICE', count: 1 }
|
||||
],
|
||||
issueTypes: [{ name: 'VIN_MISSING', count: 2 }]
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/quality/issues')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [],
|
||||
total: 3,
|
||||
limit: 20,
|
||||
offset: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 20, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
fireEvent.click(await screen.findByRole('button', { name: '查看 JT808 质量问题' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/quality/issues?protocol=JT808&limit=20&offset=0'), undefined);
|
||||
});
|
||||
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/quality/summary?protocol=JT808'), undefined);
|
||||
expect(window.location.hash).toBe('#/quality?protocol=JT808');
|
||||
});
|
||||
|
||||
test('applies shareable quality filters from hash', async () => {
|
||||
window.history.replaceState(null, '', '/#/quality?keyword=%E7%B2%A4A&protocol=VEHICLE_SERVICE&issueType=NO_SOURCE');
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user