isLowConfidenceTimeSeries.spec.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import type {EventsStats, MultiSeriesEventsStats} from 'sentry/types/organization';
  2. import {isLowConfidenceTimeSeries} from 'sentry/views/alerts/rules/metric/utils/isLowConfidenceTimeSeries';
  3. describe('isLowConfidenceTimeSeries', () => {
  4. describe('EventsStats', () => {
  5. it('should return false when no data points have low confidence', () => {
  6. const eventsStats: EventsStats = {
  7. data: [
  8. [1731556800, [{count: 100, confidence: 'HIGH'}]],
  9. [1731560400, [{count: 200, confidence: 'HIGH'}]],
  10. ],
  11. };
  12. expect(isLowConfidenceTimeSeries(eventsStats)).toBe(false);
  13. });
  14. it('should return true when any data points have low confidence', () => {
  15. const eventsStats: EventsStats = {
  16. data: [
  17. [1731556800, [{count: 100, confidence: 'LOW'}]],
  18. [1731560400, [{count: 200, confidence: 'HIGH'}]],
  19. ],
  20. };
  21. expect(isLowConfidenceTimeSeries(eventsStats)).toBe(true);
  22. });
  23. });
  24. describe('MultiSeriesEventsStats', () => {
  25. it('should return false when no data points have low confidence', () => {
  26. const multiSeriesEventsStats: MultiSeriesEventsStats = {
  27. a: {
  28. data: [
  29. [1731556800, [{count: 100, confidence: 'HIGH'}]],
  30. [1731560400, [{count: 200, confidence: 'HIGH'}]],
  31. ],
  32. },
  33. b: {
  34. data: [
  35. [1731556800, [{count: 100, confidence: 'HIGH'}]],
  36. [1731560400, [{count: 200, confidence: 'HIGH'}]],
  37. ],
  38. },
  39. };
  40. expect(isLowConfidenceTimeSeries(multiSeriesEventsStats)).toBe(false);
  41. });
  42. it('should return true when any data points have low confidence', () => {
  43. const multiSeriesEventsStats: MultiSeriesEventsStats = {
  44. a: {
  45. data: [
  46. [1731556800, [{count: 100, confidence: 'LOW'}]],
  47. [1731560400, [{count: 200, confidence: 'HIGH'}]],
  48. ],
  49. },
  50. b: {
  51. data: [
  52. [1731556800, [{count: 100, confidence: 'HIGH'}]],
  53. [1731560400, [{count: 200, confidence: 'HIGH'}]],
  54. ],
  55. },
  56. };
  57. expect(isLowConfidenceTimeSeries(multiSeriesEventsStats)).toBe(true);
  58. });
  59. });
  60. });