feat(platform): surface global alert pressure

This commit is contained in:
lingniu
2026-07-04 17:37:44 +08:00
parent 2d4b397acd
commit d266396c47
4 changed files with 131 additions and 16 deletions

View File

@@ -98,6 +98,62 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
expect(window.location.hash).toBe('#/quality');
});
test('shows global alert pressure from notification plan in topbar', async () => {
window.history.replaceState(null, '', '/#/dashboard');
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, platformRelease: 'platform-20260704180000' }
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/notification-plan')) {
return {
ok: true,
json: async () => ({
data: {
summary: { issueVehicleCount: 5, issueRecordCount: 8, errorCount: 2, warningCount: 6, protocols: [], issueTypes: [] },
rules: [],
policies: [],
priorityIssues: [],
activeRuleCount: 4,
p0RuleCount: 2
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 8, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
const alertButton = await screen.findByRole('button', { name: '顶部告警事件 P0 2 / 活跃 4' });
expect(alertButton).toHaveTextContent('告警事件 P0 2 / 活跃 4');
fireEvent.click(alertButton);
expect(window.location.hash).toBe('#/quality');
});
test('shows vehicle service status distribution on dashboard', async () => {
window.history.replaceState(null, '', '/#/dashboard');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {