suspectSpans.spec.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. project: 1,
  32. projects: [],
  33. });
  34. act(() => void ProjectsStore.loadInitialData(initialData.organization.projects));
  35. return {
  36. ...initialData,
  37. eventView: EventView.fromLocation(initialData.router.location),
  38. };
  39. }
  40. describe('SuspectSpans', function () {
  41. describe('With Span Data', function () {
  42. beforeEach(function () {
  43. MockApiClient.addMockResponse({
  44. url: '/organizations/org-slug/events-spans-performance/',
  45. body: generateSuspectSpansResponse({
  46. examples: 1,
  47. }),
  48. });
  49. });
  50. afterEach(function () {
  51. jest.resetAllMocks();
  52. });
  53. it('renders basic UI elements', async function () {
  54. const initialData = initializeData();
  55. render(
  56. <OrganizationContext.Provider value={initialData.organization}>
  57. <MEPSettingProvider>
  58. <SuspectSpans
  59. organization={initialData.organization}
  60. location={initialData.router.location}
  61. eventView={initialData.eventView}
  62. projectId="1"
  63. transactionName="Test Transaction"
  64. totals={{'count()': 1}}
  65. />
  66. </MEPSettingProvider>
  67. </OrganizationContext.Provider>
  68. );
  69. expect(await screen.findByText('Suspect Spans')).toBeInTheDocument();
  70. expect(await screen.findByText('View All Spans')).toBeInTheDocument();
  71. expect(await screen.findByText('Span Operation')).toBeInTheDocument();
  72. expect(await screen.findByText('Span Name')).toBeInTheDocument();
  73. expect(await screen.findByText('Total Count')).toBeInTheDocument();
  74. expect(await screen.findByText('Frequency')).toBeInTheDocument();
  75. expect(await screen.findByText('P75 Self Time')).toBeInTheDocument();
  76. expect(await screen.findByText('Total Self Time')).toBeInTheDocument();
  77. });
  78. // Due to the createHref being stubbed out (see link below),
  79. // the anchors all have an empty href so we can't actually
  80. // test this.
  81. //
  82. // https://github.com/getsentry/sentry/blob/28a2337ae902785d4d3e914c0ba484fa883cc17a/tests/js/setup.ts#L162
  83. //
  84. // it('allows sorting by some columns', async function () {
  85. // const initialData = initializeData();
  86. // render(
  87. // <SuspectSpans
  88. // organization={initialData.organization}
  89. // location={initialData.router.location}
  90. // eventView={initialData.eventView}
  91. // projectId="1"
  92. // transactionName="Test Transaction"
  93. // />,
  94. // );
  95. // await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  96. // expect(screen.getByText('P75 Self Time')).toHaveAttribute('href', null);
  97. // expect(screen.getByText('Total Occurrences')).toHaveAttribute('href', null);
  98. // expect(screen.getByText('Total Self Time')).toHaveAttribute('href', null);
  99. // });
  100. });
  101. });