feat(platform): add quality notification plan
This commit is contained in:
@@ -172,6 +172,30 @@ test('vehicleServiceSummary reads the vehicle service summary endpoint', async (
|
||||
expect(result.serviceStatuses.find((item) => item.status === 'no_data')?.count).toBe(461);
|
||||
});
|
||||
|
||||
test('qualityNotificationPlan reads alert rules and priority issues from backend', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
summary: { issueVehicleCount: 1, issueRecordCount: 1, errorCount: 1, warningCount: 0, protocols: [], issueTypes: [] },
|
||||
rules: [{ issueType: 'NO_SOURCE', title: '无数据来源', level: 'P0', owner: '平台接入', trigger: '无来源', notify: '立即通知', sla: '30 分钟确认', count: 1 }],
|
||||
policies: [{ name: 'P0 实时中断', target: '接入运维', channel: '邮件', condition: '无来源' }],
|
||||
priorityIssues: [{ vin: 'VIN001', plate: '粤A001', phone: '', sourceEndpoint: '', protocol: 'VEHICLE_SERVICE', issueType: 'NO_SOURCE', severity: 'error', lastSeen: '', detail: '无来源', priority: 'P0', actionLabel: '确认平台转发', actionDetail: '确认平台转发', sla: '30 分钟确认', vehicleLabel: '粤A001 / VIN001', realtimeHash: '#/realtime?keyword=VIN001', historyHash: '#/history?keyword=VIN001', rawHash: '#/history?keyword=VIN001&tab=raw', vehicleHash: '#/detail?keyword=VIN001', notificationText: '【P0 告警通知】无数据来源' }],
|
||||
activeRuleCount: 1,
|
||||
p0RuleCount: 1
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response);
|
||||
|
||||
const result = await api.qualityNotificationPlan(new URLSearchParams({ issueType: 'NO_SOURCE' }));
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith('/api/quality/notification-plan?issueType=NO_SOURCE', undefined);
|
||||
expect(result.rules[0].level).toBe('P0');
|
||||
expect(result.priorityIssues[0].notificationText).toContain('告警通知');
|
||||
});
|
||||
|
||||
test('api errors include backend message, detail, and trace id', async () => {
|
||||
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: false,
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
HistoryLocationRow,
|
||||
MileageSummary,
|
||||
OpsHealth,
|
||||
QualityNotificationPlan,
|
||||
Page,
|
||||
QualitySummary,
|
||||
QualityIssueRow,
|
||||
@@ -106,5 +107,6 @@ export const api = {
|
||||
dailyMileage: (params = new URLSearchParams()) => request<Page<DailyMileageRow>>(`/api/mileage/daily?${params.toString()}`),
|
||||
qualitySummary: (params = new URLSearchParams()) => request<QualitySummary>(`/api/quality/summary?${params.toString()}`),
|
||||
qualityIssues: (params = new URLSearchParams()) => request<Page<QualityIssueRow>>(`/api/quality/issues?${params.toString()}`),
|
||||
qualityNotificationPlan: (params = new URLSearchParams()) => request<QualityNotificationPlan>(`/api/quality/notification-plan?${params.toString()}`),
|
||||
opsHealth: () => request<OpsHealth>('/api/ops/health')
|
||||
};
|
||||
|
||||
@@ -281,6 +281,46 @@ export interface QualityBucketStat {
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface QualityNotificationPlan {
|
||||
summary: QualitySummary;
|
||||
rules: QualityAlertRule[];
|
||||
policies: QualityNotificationPolicy[];
|
||||
priorityIssues: QualityPriorityIssue[];
|
||||
activeRuleCount: number;
|
||||
p0RuleCount: number;
|
||||
}
|
||||
|
||||
export interface QualityAlertRule {
|
||||
issueType: string;
|
||||
title: string;
|
||||
level: string;
|
||||
owner: string;
|
||||
trigger: string;
|
||||
notify: string;
|
||||
sla: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface QualityNotificationPolicy {
|
||||
name: string;
|
||||
target: string;
|
||||
channel: string;
|
||||
condition: string;
|
||||
}
|
||||
|
||||
export interface QualityPriorityIssue extends QualityIssueRow {
|
||||
priority: 'P0' | 'P1';
|
||||
actionLabel: string;
|
||||
actionDetail: string;
|
||||
sla: string;
|
||||
vehicleLabel: string;
|
||||
realtimeHash: string;
|
||||
historyHash: string;
|
||||
rawHash: string;
|
||||
vehicleHash: string;
|
||||
notificationText: string;
|
||||
}
|
||||
|
||||
export interface OpsHealth {
|
||||
linkHealth: LinkHealth[];
|
||||
kafkaLag: number | null;
|
||||
|
||||
Reference in New Issue
Block a user