projectApdex.spec.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import ProjectApdexScoreCard from 'sentry/views/projectDetail/projectScoreCards/projectApdexScoreCard';
  4. describe('ProjectDetail > ProjectApdex', function () {
  5. let endpointMock;
  6. const {organization} = initializeOrg({
  7. organization: {
  8. apdexThreshold: 500,
  9. },
  10. });
  11. const selection = {
  12. projects: [1],
  13. environments: [],
  14. datetime: {
  15. period: '14d',
  16. },
  17. };
  18. beforeEach(function () {
  19. endpointMock = MockApiClient.addMockResponse({
  20. url: `/organizations/${organization.slug}/events/`,
  21. body: {
  22. data: [],
  23. },
  24. status: 200,
  25. });
  26. });
  27. afterEach(function () {
  28. MockApiClient.clearMockResponses();
  29. });
  30. it('calls api with apdex', function () {
  31. organization.features = ['discover-basic', 'performance-view'];
  32. mountWithTheme(
  33. <ProjectApdexScoreCard
  34. organization={organization}
  35. selection={selection}
  36. isProjectStabilized
  37. hasTransactions
  38. />
  39. );
  40. expect(endpointMock).toHaveBeenNthCalledWith(
  41. 1,
  42. `/organizations/${organization.slug}/events/`,
  43. expect.objectContaining({
  44. query: {
  45. environment: [],
  46. field: ['apdex()'],
  47. project: ['1'],
  48. query: 'event.type:transaction count():>0',
  49. statsPeriod: '14d',
  50. },
  51. })
  52. );
  53. });
  54. });