feat(platform): add ops quality workspace

This commit is contained in:
lingniu
2026-07-04 16:31:51 +08:00
parent c060317fb0
commit 318beccaaf
7 changed files with 221 additions and 8 deletions

View File

@@ -3259,6 +3259,65 @@ test('renders notification rules as a standalone operations page', async () => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('无来源规则 / P0 / 平台接入'));
});
test('renders ops quality as a standalone runtime health page', async () => {
window.history.replaceState(null, '', '/#/ops-quality');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/ops/health')) {
return {
ok: true,
json: async () => ({
data: {
linkHealth: [
{ name: 'gb32960-gateway', status: 'ok', detail: 'listening :32960' },
{ name: 'kafka', status: 'warning', detail: 'lag 42' }
],
kafkaLag: 42,
activeConnections: 1234,
capacityFindings: ['Kafka lag 42', 'Redis online key below expected'],
redisOnlineKeys: 368,
tdengineWritable: true,
mysqlWritable: false,
runtime: {
requestTimeoutMs: 5000,
platformRelease: 'platform-ops-test',
amapWebJsConfigured: true,
amapSecurityProxyEnabled: true,
amapSecurityCodeExposed: false,
amapSecurityServiceHost: '/_AMapService'
}
},
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.findByRole('heading', { name: '运维质量' })).toBeInTheDocument();
expect(screen.getByText('platform-ops-test')).toBeInTheDocument();
expect(screen.getByText('42')).toBeInTheDocument();
expect(screen.getByText('1,234')).toBeInTheDocument();
expect(screen.getByText('368')).toBeInTheDocument();
expect(screen.getByText('TDengine 写入')).toBeInTheDocument();
expect(screen.getByText('MySQL 写入')).toBeInTheDocument();
expect(screen.getByText('/_AMapService')).toBeInTheDocument();
expect(screen.getByText('安全码未暴露')).toBeInTheDocument();
expect(screen.getByText('gb32960-gateway')).toBeInTheDocument();
expect(screen.getByText('Kafka lag 42')).toBeInTheDocument();
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/ops/health'), undefined);
});
test('copies notification text from quality priority queue', async () => {
window.history.replaceState(null, '', '/#/quality');
const writeText = vi.fn(() => Promise.resolve());