create.spec.jsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. MockApiClient.addMockResponse({
  39. url: `/organizations/${organization.slug}/events-meta/`,
  40. body: {count: 0},
  41. });
  42. render(
  43. <MetricRulesCreate
  44. params={{orgId: organization.slug, projectId: project.slug}}
  45. organization={organization}
  46. project={project}
  47. userTeamIds={[]}
  48. />
  49. );
  50. expect(eventStatsMock).toHaveBeenCalledWith(
  51. expect.anything(),
  52. expect.objectContaining({
  53. query: {
  54. interval: '60m',
  55. project: [2],
  56. query: 'event.type:error',
  57. statsPeriod: '10000m',
  58. yAxis: 'count()',
  59. referrer: 'api.organization-event-stats',
  60. },
  61. })
  62. );
  63. });
  64. });