feat(platform): copy alert priority digest
This commit is contained in:
@@ -2536,6 +2536,104 @@ test('copies notification text from quality priority queue', async () => {
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('告警筛选:http://localhost:3000/#/quality'));
|
||||
});
|
||||
|
||||
test('copies priority queue notification digest on quality page', async () => {
|
||||
window.history.replaceState(null, '', '/#/quality');
|
||||
const writeText = vi.fn(() => Promise.resolve());
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: { writeText }
|
||||
});
|
||||
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, activeConnections: 120000, capacityFindings: [], redisOnlineKeys: 368, 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: 2,
|
||||
errorCount: 1,
|
||||
warningCount: 1,
|
||||
protocols: [{ name: 'VEHICLE_SERVICE', count: 1 }, { name: 'JT808', count: 1 }],
|
||||
issueTypes: [{ name: 'NO_SOURCE', count: 1 }, { name: 'VIN_MISSING', count: 1 }]
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/quality/issues')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
vin: 'VIN-DIGEST-001',
|
||||
plate: '粤A汇总1',
|
||||
phone: '13307795425',
|
||||
sourceEndpoint: '115.231.168.135:43625',
|
||||
protocol: 'VEHICLE_SERVICE',
|
||||
issueType: 'NO_SOURCE',
|
||||
severity: 'error',
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
detail: '车辆无任何来源'
|
||||
},
|
||||
{
|
||||
vin: '',
|
||||
plate: '粤A汇总2',
|
||||
phone: '13307795426',
|
||||
sourceEndpoint: '115.231.168.135:43626',
|
||||
protocol: 'JT808',
|
||||
issueType: 'VIN_MISSING',
|
||||
severity: 'warning',
|
||||
lastSeen: '2026-07-03 20:10:10',
|
||||
detail: '手机号未映射 VIN'
|
||||
}
|
||||
],
|
||||
total: 2,
|
||||
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 />);
|
||||
|
||||
expect(await screen.findByText('处置优先队列')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '复制优先队列通知汇总' }));
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【告警优先队列汇总】'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('P0:1 条,P1:1 条'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('1. [P0] 粤A汇总1 / VIN-DIGEST-001'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('确认平台转发'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('2. [P1] 粤A汇总2 / 13307795426'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('维护身份绑定'));
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('告警筛选:http://localhost:3000/#/quality'));
|
||||
});
|
||||
|
||||
test('opens realtime map context from quality priority queue', async () => {
|
||||
window.history.replaceState(null, '', '/#/quality');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user