feat(platform): promote alert events surface

This commit is contained in:
lingniu
2026-07-04 17:58:33 +08:00
parent eb8f15ca18
commit 1235e76c32
11 changed files with 135 additions and 70 deletions

View File

@@ -198,6 +198,37 @@ test('qualityNotificationPlan reads alert rules and priority issues from backend
expect(result.priorityIssues[0].notificationText).toContain('告警通知');
});
test('alertEvents reads the vehicle alert event endpoint', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN001',
plate: '粤A001',
phone: '13307795425',
sourceEndpoint: '115.29.187.205:808',
protocol: 'JT808',
issueType: 'LINK_GAP',
severity: 'warning',
lastSeen: '2026-07-03 20:12:10',
detail: '来源间断'
}],
total: 1,
limit: 20,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response);
const result = await api.alertEvents(new URLSearchParams({ protocol: 'JT808', limit: '20' }));
expect(fetchMock).toHaveBeenCalledWith('/api/alert-events?protocol=JT808&limit=20', undefined);
expect(result.items[0].issueType).toBe('LINK_GAP');
});
test('onlineVehicleStatuses reads paged online vehicle status rows', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,