getMetricRuleDiscoverUrl.spec.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {MetricRule} from 'sentry-fixture/metricRule';
  2. import {Dataset} from 'sentry/views/alerts/rules/metric/types';
  3. import {getMetricRuleDiscoverQuery} from './getMetricRuleDiscoverUrl';
  4. describe('getMetricRuleDiscoverQuery', () => {
  5. it('should use metric aggregate in discover query', () => {
  6. const rule = MetricRule({
  7. aggregate: 'failure_rate()',
  8. dataset: Dataset.TRANSACTIONS,
  9. });
  10. const projects = [TestStubs.Project()];
  11. const query = getMetricRuleDiscoverQuery({
  12. rule,
  13. projects,
  14. timePeriod: {
  15. period: '7d',
  16. usingPeriod: true,
  17. start: new Date().toISOString(),
  18. end: new Date().toISOString(),
  19. },
  20. });
  21. expect(query!.valueOf()).toEqual(
  22. expect.objectContaining({
  23. statsPeriod: '7d',
  24. fields: [
  25. {
  26. field: 'transaction',
  27. width: -1,
  28. },
  29. {
  30. field: 'project',
  31. width: -1,
  32. },
  33. {
  34. field: 'failure_rate()',
  35. width: -1,
  36. },
  37. {
  38. field: 'count_unique(user)',
  39. width: -1,
  40. },
  41. {
  42. field: 'user_misery(300)',
  43. width: -1,
  44. },
  45. ],
  46. })
  47. );
  48. });
  49. });