⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.72
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
alerting
/
View File Name :
TestRuleResult.test.tsx
import { render, screen } from '@testing-library/react'; import React from 'react'; import { PanelModel } from '../dashboard/state'; import { createDashboardModelFixture, createPanelSaveModel } from '../dashboard/state/__fixtures__/dashboardFixtures'; import { TestRuleResult } from './TestRuleResult'; const backendSrv = { post: jest.fn(), }; jest.mock('@grafana/runtime', () => { const original = jest.requireActual('@grafana/runtime'); return { ...original, getBackendSrv: () => backendSrv, }; }); const props: React.ComponentProps
= { panel: new PanelModel({ id: 1 }), dashboard: createDashboardModelFixture({ panels: [createPanelSaveModel({ id: 1 })], }), }; describe('TestRuleResult', () => { it('should render without error', async () => { render(
); await screen.findByRole('button', { name: 'Copy to Clipboard' }); }); it('should call testRule when mounting', async () => { jest.spyOn(backendSrv, 'post'); render(
); await screen.findByRole('button', { name: 'Copy to Clipboard' }); expect(backendSrv.post).toHaveBeenCalledWith( '/api/alerts/test', expect.objectContaining({ panelId: 1, }) ); }); });