utils.spec.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {MetricRuleFixture} from 'sentry-fixture/metricRule';
  2. import {Dataset, TimeWindow} from 'sentry/views/alerts/rules/metric/types';
  3. import {getAlertRuleExploreUrl} from 'sentry/views/alerts/rules/utils';
  4. describe('getExploreUrl', () => {
  5. it('should return the correct url', () => {
  6. const rule = MetricRuleFixture();
  7. rule.dataset = Dataset.EVENTS_ANALYTICS_PLATFORM;
  8. rule.timeWindow = TimeWindow.THIRTY_MINUTES;
  9. rule.aggregate = 'p75(span.duration)';
  10. rule.query = 'span.op:http.client';
  11. rule.environment = 'prod';
  12. const url = getAlertRuleExploreUrl({
  13. rule,
  14. orgSlug: 'slug',
  15. period: '7d',
  16. projectId: '1',
  17. });
  18. expect(url).toBe(
  19. '/organizations/slug/traces/?dataset=spansRpc&environment=prod&interval=30m&project=1&query=span.op%3Ahttp.client&statsPeriod=7d&visualize=%7B%22chartType%22%3A1%2C%22yAxes%22%3A%5B%22p75%28span.duration%29%22%5D%7D'
  20. );
  21. });
  22. it('should return the correct url for 9998m', () => {
  23. const rule = MetricRuleFixture();
  24. rule.dataset = Dataset.EVENTS_ANALYTICS_PLATFORM;
  25. rule.timeWindow = TimeWindow.THIRTY_MINUTES;
  26. rule.aggregate = 'p75(span.duration)';
  27. rule.query = 'span.op:http.client';
  28. rule.environment = 'prod';
  29. const url = getAlertRuleExploreUrl({
  30. rule,
  31. orgSlug: 'slug',
  32. period: '9998m',
  33. projectId: '1',
  34. });
  35. expect(url).toBe(
  36. '/organizations/slug/traces/?dataset=spansRpc&environment=prod&interval=30m&project=1&query=span.op%3Ahttp.client&statsPeriod=7d&visualize=%7B%22chartType%22%3A1%2C%22yAxes%22%3A%5B%22p75%28span.duration%29%22%5D%7D'
  37. );
  38. });
  39. });