getWidgetExploreUrl.spec.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {PageFiltersFixture} from 'sentry-fixture/pageFilters';
  3. import {WidgetFixture} from 'sentry-fixture/widget';
  4. import {DisplayType} from 'sentry/views/dashboards/types';
  5. import {getWidgetExploreUrl} from 'sentry/views/dashboards/utils/getWidgetExploreUrl';
  6. describe('getWidgetExploreUrl', () => {
  7. const organization = OrganizationFixture();
  8. const selection = PageFiltersFixture();
  9. it('returns the correct url for table widgets', () => {
  10. const widget = WidgetFixture({
  11. displayType: DisplayType.TABLE,
  12. queries: [
  13. {
  14. fields: ['span.description', 'avg(span.duration)'],
  15. aggregates: ['avg(span.duration)'],
  16. columns: ['span.description'],
  17. conditions: '',
  18. orderby: '',
  19. name: '',
  20. },
  21. ],
  22. });
  23. const url = getWidgetExploreUrl(widget, selection, organization);
  24. // Note: for table widgets the mode is set to samples and the fields are propagated
  25. expect(url).toBe(
  26. '/traces/?field=span.description&field=avg%28span.duration%29&groupBy=span.description&interval=30m&mode=samples&query=&statsPeriod=14d&visualize=%7B%22yAxes%22%3A%5B%22avg%28span.duration%29%22%5D%7D'
  27. );
  28. });
  29. it('returns the correct url for timeseries widgets', () => {
  30. const widget = WidgetFixture({
  31. displayType: DisplayType.AREA,
  32. queries: [
  33. {
  34. fields: ['span.description', 'avg(span.duration)'],
  35. aggregates: ['avg(span.duration)'],
  36. columns: ['span.description'],
  37. conditions: '',
  38. orderby: '',
  39. name: '',
  40. },
  41. ],
  42. });
  43. const url = getWidgetExploreUrl(widget, selection, organization);
  44. // Note: for line widgets the mode is set to aggregate
  45. // The chart type is set to 1 for area charts
  46. expect(url).toBe(
  47. '/traces/?field=span.description&field=avg%28span.duration%29&groupBy=span.description&interval=30m&mode=aggregate&query=&statsPeriod=14d&visualize=%7B%22yAxes%22%3A%5B%22avg%28span.duration%29%22%5D%2C%22chartType%22%3A%222%22%7D'
  48. );
  49. });
  50. });