feat(platform): copy quality alert notification

This commit is contained in:
lingniu
2026-07-04 12:56:46 +08:00
parent 89ddb82f46
commit 783c8eba5e
2 changed files with 100 additions and 0 deletions

View File

@@ -2413,6 +2413,91 @@ test('shows actionable priority queue on quality page', async () => {
});
});
test('copies notification text from quality priority queue', 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: 1,
issueRecordCount: 1,
errorCount: 1,
warningCount: 0,
protocols: [{ name: 'JT808', count: 1 }],
issueTypes: [{ 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: '',
plate: '粤A通知1',
phone: '13307795425',
sourceEndpoint: '115.231.168.135:43625',
protocol: 'JT808',
issueType: 'VIN_MISSING',
severity: 'error',
lastSeen: '2026-07-03 20:12:10',
detail: '手机号未映射 VIN需要维护 binding'
}],
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 />);
expect(await screen.findByText('处置优先队列')).toBeInTheDocument();
fireEvent.click(await screen.findByRole('button', { name: '复制通知' }));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【P0 告警通知】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆粤A通知1 / 13307795425'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('问题VIN 缺失'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('SLA2 小时修复'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('最后时间2026-07-03 20:12:10'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('详情:手机号未映射 VIN需要维护 binding'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('/#/quality'));
});
test('opens realtime map context from quality priority queue', async () => {
window.history.replaceState(null, '', '/#/quality');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {