create.spec.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render} from 'sentry-test/reactTestingLibrary';
  3. import EventView from 'sentry/utils/discover/eventView';
  4. import MetricRulesCreate from 'sentry/views/alerts/rules/metric/create';
  5. describe('Incident Rules Create', function () {
  6. let eventStatsMock;
  7. beforeEach(function () {
  8. MockApiClient.clearMockResponses();
  9. MockApiClient.addMockResponse({
  10. url: '/organizations/org-slug/tags/',
  11. body: [],
  12. });
  13. MockApiClient.addMockResponse({
  14. url: '/organizations/org-slug/users/',
  15. body: [],
  16. });
  17. MockApiClient.addMockResponse({
  18. url: '/projects/org-slug/project-slug/environments/',
  19. body: [],
  20. });
  21. eventStatsMock = MockApiClient.addMockResponse({
  22. url: '/organizations/org-slug/events-stats/',
  23. body: TestStubs.EventsStats(),
  24. });
  25. MockApiClient.addMockResponse({
  26. url: '/organizations/org-slug/alert-rules/available-actions/',
  27. body: [
  28. {
  29. allowedTargetTypes: ['user', 'team'],
  30. integrationName: null,
  31. type: 'email',
  32. integrationId: null,
  33. },
  34. ],
  35. });
  36. });
  37. it('renders', function () {
  38. const {organization, project} = initializeOrg();
  39. MockApiClient.addMockResponse({
  40. url: `/organizations/${organization.slug}/events-meta/`,
  41. body: {count: 0},
  42. });
  43. render(
  44. <MetricRulesCreate
  45. {...TestStubs.routeComponentProps()}
  46. eventView={EventView.fromLocation(TestStubs.location())}
  47. params={{projectId: project.slug}}
  48. organization={organization}
  49. project={project}
  50. userTeamIds={[]}
  51. />
  52. );
  53. expect(eventStatsMock).toHaveBeenCalledWith(
  54. expect.anything(),
  55. expect.objectContaining({
  56. query: {
  57. interval: '60m',
  58. project: [2],
  59. query: 'event.type:error',
  60. statsPeriod: '10000m',
  61. yAxis: 'count()',
  62. referrer: 'api.organization-event-stats',
  63. useOnDemandMetrics: false,
  64. },
  65. })
  66. );
  67. });
  68. });