create.spec.tsx 2.2 KB

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