eventVitals.spec.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {EventFixture} from 'sentry-fixture/event';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import EventVitals from 'sentry/components/events/eventVitals';
  4. describe('EventVitals', function () {
  5. it('should not render anything', function () {
  6. const event = EventFixture();
  7. const {container} = render(<EventVitals event={event} />);
  8. expect(container).toBeEmptyDOMElement();
  9. });
  10. it('should not render non web vitals', function () {
  11. const event = EventFixture({
  12. measurements: {
  13. 'mark.stuff': {value: 123},
  14. 'op.more.stuff': {value: 123},
  15. },
  16. });
  17. const {container} = render(<EventVitals event={event} />);
  18. expect(container).toBeEmptyDOMElement();
  19. });
  20. it('should render some web vitals with a header', function () {
  21. const event = EventFixture({
  22. measurements: {
  23. fp: {value: 1},
  24. fcp: {value: 2},
  25. lcp: {value: 3},
  26. fid: {value: 4},
  27. cls: {value: 0.1},
  28. ttfb: {value: 5},
  29. 'ttfb.requesttime': {value: 6},
  30. },
  31. });
  32. render(<EventVitals event={event} />);
  33. expect(screen.getByText('Web Vitals')).toBeInTheDocument();
  34. [
  35. 'Cumulative Layout Shift',
  36. 'First Contentful Paint',
  37. 'First Input Delay',
  38. 'First Paint',
  39. 'Largest Contentful Paint',
  40. 'Time to First Byte',
  41. 'Request Time',
  42. ].forEach(vital => expect(screen.getByText(vital)).toBeInTheDocument());
  43. });
  44. it('should render some web vitals with a heading and a sdk warning', function () {
  45. const event = EventFixture({
  46. measurements: {
  47. fp: {value: 1},
  48. },
  49. sdk: {version: '5.26.0'},
  50. });
  51. render(<EventVitals event={event} />);
  52. [
  53. 'Cumulative Layout Shift',
  54. 'First Contentful Paint',
  55. 'First Input Delay',
  56. 'Largest Contentful Paint',
  57. 'Time to First Byte',
  58. 'Request Time',
  59. ].forEach(vital => expect(screen.queryByText(vital)).not.toBeInTheDocument());
  60. expect(screen.getByTestId('outdated-sdk-warning')).toBeInTheDocument();
  61. });
  62. it('should show fire icon if vital failed threshold', function () {
  63. const event = EventFixture({
  64. measurements: {
  65. fp: {value: 5000},
  66. fcp: {value: 5000},
  67. lcp: {value: 5000},
  68. fid: {value: 4},
  69. cls: {value: 0.1},
  70. ttfb: {value: 5},
  71. 'ttfb.requesttime': {value: 6},
  72. },
  73. });
  74. render(<EventVitals event={event} />);
  75. expect(screen.getAllByTestId('threshold-failed-warning')[0]).toBeInTheDocument();
  76. });
  77. });