projectApdexScoreCard.spec.jsx 1.3 KB

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