12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import {IncidentFixture} from 'sentry-fixture/incident';
- import {initializeOrg} from 'sentry-test/initializeOrg';
- import {render, waitFor} from 'sentry-test/reactTestingLibrary';
- import {trackAnalytics} from 'sentry/utils/analytics';
- import {browserHistory} from 'sentry/utils/browserHistory';
- import IncidentRedirect from './incidentRedirect';
- jest.mock('sentry/utils/analytics');
- describe('IncidentRedirect', () => {
- const params = {alertId: '123'};
- const {organization, project, router, routerProps} = initializeOrg({
- router: {
- params,
- },
- });
- const mockIncident = IncidentFixture({projects: [project.slug]});
- beforeEach(() => {
- MockApiClient.addMockResponse({
- url: '/organizations/org-slug/incidents/123/',
- body: mockIncident,
- });
- });
- afterEach(() => {
- MockApiClient.clearMockResponses();
- jest.clearAllMocks();
- });
- it('redirects to alert details page', async () => {
- render(<IncidentRedirect organization={organization} {...routerProps} />, {
- router,
- });
- expect(trackAnalytics).toHaveBeenCalledWith(
- 'alert_details.viewed',
- expect.objectContaining({
- alert_id: 123,
- })
- );
- await waitFor(() => {
- expect(browserHistory.replace).toHaveBeenCalledWith({
- pathname: '/organizations/org-slug/alerts/rules/details/4/',
- query: {
- alert: '123',
- },
- });
- });
- });
- });
|