eventCustomPerformanceMetrics.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import EventCustomPerformanceMetrics from 'sentry/components/events/eventCustomPerformanceMetrics';
  4. import {Event} from 'sentry/types/event';
  5. describe('EventCustomPerformanceMetrics', function () {
  6. it('should not render anything', function () {
  7. const {router, organization} = initializeOrg();
  8. render(
  9. <EventCustomPerformanceMetrics
  10. location={router.location}
  11. organization={organization}
  12. event={{} as Event}
  13. />
  14. );
  15. expect(screen.queryByText('Custom Performance Metrics')).not.toBeInTheDocument();
  16. });
  17. it('should not render non custom performance metrics', function () {
  18. const {router, organization} = initializeOrg();
  19. const event = TestStubs.Event({
  20. measurements: {lcp: {value: 10, unit: 'millisecond'}},
  21. });
  22. render(
  23. <EventCustomPerformanceMetrics
  24. location={router.location}
  25. organization={organization}
  26. event={event}
  27. />
  28. );
  29. expect(screen.queryByText('Custom Performance Metrics')).not.toBeInTheDocument();
  30. expect(screen.queryByText('Largest Contentful Paint')).not.toBeInTheDocument();
  31. });
  32. it('should render custom performance metrics', function () {
  33. const {router, organization} = initializeOrg();
  34. const event = TestStubs.Event({
  35. measurements: {
  36. 'custom.count': {unit: 'none', value: 10},
  37. 'custom.duration': {unit: 'millisecond', value: 123},
  38. 'custom.size': {unit: 'kibibyte', value: 456},
  39. 'custom.percentage': {unit: 'ratio', value: 0.3},
  40. lcp: {value: 10, unit: 'millisecond'},
  41. },
  42. });
  43. render(
  44. <EventCustomPerformanceMetrics
  45. location={router.location}
  46. organization={organization}
  47. event={event}
  48. />
  49. );
  50. screen.getByText('Custom Performance Metrics');
  51. screen.getByText('custom.count');
  52. screen.getByText('custom.duration');
  53. screen.getByText('custom.size');
  54. screen.getByText('custom.percentage');
  55. screen.getByText('10');
  56. screen.getByText('123.00ms');
  57. screen.getByText('456.0 KiB');
  58. screen.getByText('30%');
  59. expect(screen.queryByText('Largest Contentful Paint')).not.toBeInTheDocument();
  60. });
  61. });