projectApdexScoreCard.spec.tsx 1.4 KB

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