index.spec.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import AlertWizard from 'sentry/views/alerts/wizard/index';
  4. describe('AlertWizard', () => {
  5. it('sets crash free dataset to metrics', async () => {
  6. const {organization, project, routerProps, routerContext} = initializeOrg({
  7. organization: {
  8. features: [
  9. 'alert-crash-free-metrics',
  10. 'incidents',
  11. 'performance-view',
  12. 'crash-rate-alerts',
  13. ],
  14. access: ['org:write', 'alerts:write'],
  15. },
  16. });
  17. render(
  18. <AlertWizard
  19. organization={organization}
  20. projectId={project.slug}
  21. {...routerProps}
  22. />,
  23. {context: routerContext, organization}
  24. );
  25. await userEvent.click(screen.getByText('Crash Free Session Rate'));
  26. await userEvent.click(screen.getByText('Set Conditions'));
  27. expect(routerContext.context.router.push).toHaveBeenCalledWith({
  28. pathname: '/organizations/org-slug/alerts/new/metric/',
  29. query: {
  30. aggregate:
  31. 'percentage(sessions_crashed, sessions) AS _crash_rate_alert_aggregate',
  32. dataset: 'metrics',
  33. eventTypes: 'session',
  34. project: 'project-slug',
  35. referrer: undefined,
  36. },
  37. });
  38. });
  39. });