suspectSpans.spec.tsx 3.8 KB

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