suspectSpans.spec.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {generateSuspectSpansResponse} from 'sentry-test/performance/initializePerformanceData';
  4. import {
  5. act,
  6. render,
  7. screen,
  8. // waitForElementToBeRemoved,
  9. } from 'sentry-test/reactTestingLibrary';
  10. import ProjectsStore from 'sentry/stores/projectsStore';
  11. import EventView from 'sentry/utils/discover/eventView';
  12. import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  13. import {OrganizationContext} from 'sentry/views/organizationContext';
  14. import SuspectSpans from 'sentry/views/performance/transactionSummary/transactionOverview/suspectSpans';
  15. function initializeData({query} = {query: {}}) {
  16. const features = ['performance-view'];
  17. const organization = OrganizationFixture({features});
  18. const initialData = initializeOrg({
  19. organization,
  20. router: {
  21. location: {
  22. query: {
  23. transaction: 'Test Transaction',
  24. project: '1',
  25. ...query,
  26. },
  27. },
  28. },
  29. projects: [],
  30. });
  31. act(() => void ProjectsStore.loadInitialData(initialData.projects));
  32. return {
  33. ...initialData,
  34. eventView: EventView.fromLocation(initialData.router.location),
  35. };
  36. }
  37. describe('SuspectSpans', function () {
  38. describe('With Span Data', function () {
  39. beforeEach(function () {
  40. MockApiClient.addMockResponse({
  41. url: '/organizations/org-slug/events-spans-performance/',
  42. body: generateSuspectSpansResponse({
  43. examples: 1,
  44. }),
  45. });
  46. });
  47. afterEach(function () {
  48. jest.resetAllMocks();
  49. });
  50. it('renders basic UI elements', async function () {
  51. const initialData = initializeData();
  52. render(
  53. <OrganizationContext.Provider value={initialData.organization}>
  54. <MEPSettingProvider>
  55. <SuspectSpans
  56. organization={initialData.organization}
  57. location={initialData.router.location}
  58. eventView={initialData.eventView}
  59. projectId="1"
  60. transactionName="Test Transaction"
  61. totals={{'count()': 1}}
  62. />
  63. </MEPSettingProvider>
  64. </OrganizationContext.Provider>
  65. );
  66. expect(await screen.findByText('Suspect Spans')).toBeInTheDocument();
  67. expect(await screen.findByText('View All Spans')).toBeInTheDocument();
  68. expect(await screen.findByText('Span Operation')).toBeInTheDocument();
  69. expect(await screen.findByText('Span Name')).toBeInTheDocument();
  70. expect(await screen.findByText('Frequency')).toBeInTheDocument();
  71. expect(await screen.findByText('P75 Self Time')).toBeInTheDocument();
  72. expect(await screen.findByText('Total Self Time')).toBeInTheDocument();
  73. });
  74. // Due to the createHref being stubbed out (see link below),
  75. // the anchors all have an empty href so we can't actually
  76. // test this.
  77. //
  78. // https://github.com/getsentry/sentry/blob/28a2337ae902785d4d3e914c0ba484fa883cc17a/tests/js/setup.ts#L162
  79. //
  80. // it('allows sorting by some columns', async function () {
  81. // const initialData = initializeData();
  82. // render(
  83. // <SuspectSpans
  84. // organization={initialData.organization}
  85. // location={initialData.router.location}
  86. // eventView={initialData.eventView}
  87. // projectId="1"
  88. // transactionName="Test Transaction"
  89. // />,
  90. // );
  91. // await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  92. // expect(screen.getByText('P75 Self Time')).toHaveAttribute('href', null);
  93. // expect(screen.getByText('Total Occurrences')).toHaveAttribute('href', null);
  94. // expect(screen.getByText('Total Self Time')).toHaveAttribute('href', null);
  95. // });
  96. });
  97. });