getAlertsUrl.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {PageFiltersFixture} from 'sentry-fixture/pageFilters';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {Dataset} from 'sentry/views/alerts/rules/metric/types';
  4. import {getAlertsUrl} from 'sentry/views/insights/common/utils/getAlertsUrl';
  5. describe('getAlertsUrl', function () {
  6. const {project} = initializeOrg();
  7. const pageFilters = PageFiltersFixture();
  8. it('should return a url to the alert rule page prepopulated with DB params', function () {
  9. const aggregate = 'avg(d:spans/duration@millisecond)';
  10. const query = 'span.module:db';
  11. const orgSlug = 'orgSlug';
  12. const url = getAlertsUrl({
  13. project,
  14. aggregate,
  15. query,
  16. orgSlug,
  17. pageFilters,
  18. });
  19. expect(url).toEqual(
  20. '/organizations/orgSlug/alerts/new/metric/?aggregate=avg%28d%3Aspans%2Fduration%40millisecond%29&dataset=generic_metrics&eventTypes=transaction&project=project-slug&query=span.module%3Adb&statsPeriod=7d'
  21. );
  22. });
  23. it('should return a url to an EAP alert rule', function () {
  24. const aggregate = 'count(span.duration)';
  25. const query = 'span.op:http.client';
  26. const orgSlug = 'orgSlug';
  27. const url = getAlertsUrl({
  28. project,
  29. aggregate,
  30. query,
  31. orgSlug,
  32. pageFilters,
  33. dataset: Dataset.EVENTS_ANALYTICS_PLATFORM,
  34. });
  35. expect(url).toEqual(
  36. '/organizations/orgSlug/alerts/new/metric/?aggregate=count%28span.duration%29&dataset=events_analytics_platform&eventTypes=transaction&project=project-slug&query=span.op%3Ahttp.client&statsPeriod=7d'
  37. );
  38. });
  39. });