onDemandMetricAlert.spec.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {Dataset} from 'sentry/views/alerts/rules/metric/types';
  2. import {isOnDemandMetricAlert} from 'sentry/views/alerts/rules/metric/utils/onDemandMetricAlert';
  3. describe('isOnDemandMetricAlert', () => {
  4. it('should return true for an alert that contains non standard fields', () => {
  5. const dataset = Dataset.GENERIC_METRICS;
  6. expect(
  7. isOnDemandMetricAlert(dataset, 'count()', 'transaction.duration:>1')
  8. ).toBeTruthy();
  9. expect(isOnDemandMetricAlert(dataset, 'count()', 'device.name:foo')).toBeTruthy();
  10. expect(isOnDemandMetricAlert(dataset, 'count()', 'geo.region:>US')).toBeTruthy();
  11. });
  12. it('should return false for an alert that has only standard fields', () => {
  13. const dataset = Dataset.GENERIC_METRICS;
  14. expect(isOnDemandMetricAlert(dataset, 'count()', 'release:1.0')).toBeFalsy();
  15. expect(isOnDemandMetricAlert(dataset, 'count()', 'browser.name:chrome')).toBeFalsy();
  16. });
  17. it('should return false if dataset is not generic_metrics', () => {
  18. const dataset = Dataset.TRANSACTIONS;
  19. expect(
  20. isOnDemandMetricAlert(dataset, 'count()', 'transaction.duration:>1')
  21. ).toBeFalsy();
  22. expect(isOnDemandMetricAlert(dataset, 'count()', 'device.name:foo')).toBeFalsy();
  23. expect(isOnDemandMetricAlert(dataset, 'count()', 'geo.region:>US')).toBeFalsy();
  24. });
  25. it('should return true if aggregate is apdex', () => {
  26. const dataset = Dataset.GENERIC_METRICS;
  27. expect(isOnDemandMetricAlert(dataset, 'apdex(300)', '')).toBeTruthy();
  28. expect(
  29. isOnDemandMetricAlert(dataset, 'apdex(300)', 'transaction.duration:>1')
  30. ).toBeTruthy();
  31. expect(isOnDemandMetricAlert(dataset, 'apdex(300)', 'device.name:foo')).toBeTruthy();
  32. });
  33. });