utils.spec.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {MetricRuleFixture} from 'sentry-fixture/metricRule';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {Dataset, TimeWindow} from 'sentry/views/alerts/rules/metric/types';
  4. import {getAlertRuleExploreUrl} from 'sentry/views/alerts/rules/utils';
  5. describe('getExploreUrl', () => {
  6. it('should return the correct url', () => {
  7. const rule = MetricRuleFixture();
  8. rule.dataset = Dataset.EVENTS_ANALYTICS_PLATFORM;
  9. rule.timeWindow = TimeWindow.THIRTY_MINUTES;
  10. rule.aggregate = 'p75(span.duration)';
  11. rule.query = 'span.op:http.client';
  12. rule.environment = 'prod';
  13. const url = getAlertRuleExploreUrl({
  14. rule,
  15. organization: OrganizationFixture({slug: 'slug'}),
  16. period: '7d',
  17. projectId: '1',
  18. });
  19. expect(url).toBe(
  20. '/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'
  21. );
  22. });
  23. it('should return the correct url for 9998m', () => {
  24. const rule = MetricRuleFixture();
  25. rule.dataset = Dataset.EVENTS_ANALYTICS_PLATFORM;
  26. rule.timeWindow = TimeWindow.THIRTY_MINUTES;
  27. rule.aggregate = 'p75(span.duration)';
  28. rule.query = 'span.op:http.client';
  29. rule.environment = 'prod';
  30. const url = getAlertRuleExploreUrl({
  31. rule,
  32. organization: OrganizationFixture({slug: 'slug'}),
  33. period: '9998m',
  34. projectId: '1',
  35. });
  36. expect(url).toBe(
  37. '/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'
  38. );
  39. });
  40. });