index.spec.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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', () => {
  6. const {organization, project, router, 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. project: undefined,
  17. projects: undefined,
  18. router: undefined,
  19. });
  20. render(
  21. <AlertWizard
  22. organization={organization}
  23. route={{}}
  24. router={router}
  25. routes={router.routes}
  26. routeParams={router.params}
  27. location={router.location}
  28. params={{orgId: organization.slug, projectId: project.slug}}
  29. projectId={project.slug}
  30. />,
  31. {context: routerContext, organization}
  32. );
  33. userEvent.click(screen.getByText('Crash Free Session Rate'));
  34. userEvent.click(screen.getByText('Set Conditions'));
  35. expect(routerContext.context.router.push).toHaveBeenCalledWith({
  36. pathname: '/organizations/org-slug/alerts/new/metric/',
  37. query: {
  38. aggregate:
  39. 'percentage(sessions_crashed, sessions) AS _crash_rate_alert_aggregate',
  40. dataset: 'metrics',
  41. eventTypes: 'session',
  42. project: 'project-slug',
  43. referrer: undefined,
  44. },
  45. });
  46. });
  47. });