getMetricRuleDiscoverUrl.spec.tsx 1.2 KB

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