spansWidgetQueries.spec.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {PageFiltersFixture} from 'sentry-fixture/pageFilters';
  3. import {WidgetFixture} from 'sentry-fixture/widget';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import SpansWidgetQueries from './spansWidgetQueries';
  6. describe('spansWidgetQueries', () => {
  7. const api = new MockApiClient();
  8. const organization = OrganizationFixture();
  9. let widget = WidgetFixture();
  10. const selection = PageFiltersFixture();
  11. beforeEach(() => {
  12. MockApiClient.clearMockResponses();
  13. widget = WidgetFixture();
  14. });
  15. it('calculates the confidence for a single series', async () => {
  16. MockApiClient.addMockResponse({
  17. url: '/organizations/org-slug/events-stats/',
  18. body: {
  19. confidence: [
  20. [1, [{count: 'low'}]],
  21. [2, [{count: 'low'}]],
  22. [3, [{count: 'low'}]],
  23. ],
  24. data: [],
  25. },
  26. });
  27. render(
  28. <SpansWidgetQueries
  29. api={api}
  30. organization={organization}
  31. widget={widget}
  32. selection={selection}
  33. dashboardFilters={{}}
  34. >
  35. {({confidence}) => <div>{confidence}</div>}
  36. </SpansWidgetQueries>
  37. );
  38. expect(await screen.findByText('low')).toBeInTheDocument();
  39. });
  40. it('calculates the confidence for a multi series', async () => {
  41. widget = WidgetFixture({
  42. queries: [
  43. {
  44. name: '',
  45. aggregates: ['a', 'b'],
  46. fields: ['a', 'b'],
  47. columns: [],
  48. conditions: '',
  49. orderby: '',
  50. },
  51. ],
  52. });
  53. MockApiClient.addMockResponse({
  54. url: '/organizations/org-slug/events-stats/',
  55. body: {
  56. a: {
  57. confidence: [
  58. [1, [{count: 'high'}]],
  59. [2, [{count: 'high'}]],
  60. [3, [{count: 'high'}]],
  61. ],
  62. data: [],
  63. },
  64. b: {
  65. confidence: [
  66. [1, [{count: 'high'}]],
  67. [2, [{count: 'high'}]],
  68. [3, [{count: 'high'}]],
  69. ],
  70. data: [],
  71. },
  72. },
  73. });
  74. render(
  75. <SpansWidgetQueries
  76. api={api}
  77. organization={organization}
  78. widget={widget}
  79. selection={selection}
  80. dashboardFilters={{}}
  81. >
  82. {({confidence}) => <div>{confidence}</div>}
  83. </SpansWidgetQueries>
  84. );
  85. expect(await screen.findByText('high')).toBeInTheDocument();
  86. });
  87. });