create.spec.jsx 1.7 KB

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