projectApdexScoreCard.spec.tsx 1.4 KB

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