create.spec.tsx 2.0 KB

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