feat(platform): filter quality issues by type

This commit is contained in:
lingniu
2026-07-04 04:42:12 +08:00
parent 7ed5d7620b
commit b53cfbabfe
7 changed files with 164 additions and 12 deletions

View File

@@ -729,6 +729,72 @@ test('renders quality issues as vehicle-service governance labels', async () =>
expect(screen.getAllByText('车辆服务').length).toBeGreaterThanOrEqual(1);
});
test('drills into quality issues by issue type', 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: 1,
issueRecordCount: 1,
errorCount: 0,
warningCount: 1,
protocols: [{ name: 'VEHICLE_SERVICE', count: 1 }],
issueTypes: [{ name: 'NO_SOURCE', count: 1 }]
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/issues')) {
return {
ok: true,
json: async () => ({
data: {
items: [],
total: 1,
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: /主要问题 暂无数据来源 1/ }));
await waitFor(() => {
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/quality/issues?issueType=NO_SOURCE&limit=20&offset=0'), undefined);
});
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/quality/summary?issueType=NO_SOURCE'), undefined);
});
test('opens vehicle detail from shareable hash', async () => {
window.history.replaceState(null, '', '/#/detail?keyword=%E7%B2%A4AG18312');
vi.spyOn(globalThis, 'fetch').mockResolvedValue({