suspectSpans.spec.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import {Organization} 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 = Organization({
  18. features,
  19. projects: [TestStubs.Project()],
  20. });
  21. const initialData = initializeOrg({
  22. organization,
  23. router: {
  24. location: {
  25. query: {
  26. transaction: 'Test Transaction',
  27. project: '1',
  28. ...query,
  29. },
  30. },
  31. },
  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('Frequency')).toBeInTheDocument();
  74. expect(await screen.findByText('P75 Self Time')).toBeInTheDocument();
  75. expect(await screen.findByText('Total Self Time')).toBeInTheDocument();
  76. });
  77. // Due to the createHref being stubbed out (see link below),
  78. // the anchors all have an empty href so we can't actually
  79. // test this.
  80. //
  81. // https://github.com/getsentry/sentry/blob/28a2337ae902785d4d3e914c0ba484fa883cc17a/tests/js/setup.ts#L162
  82. //
  83. // it('allows sorting by some columns', async function () {
  84. // const initialData = initializeData();
  85. // render(
  86. // <SuspectSpans
  87. // organization={initialData.organization}
  88. // location={initialData.router.location}
  89. // eventView={initialData.eventView}
  90. // projectId="1"
  91. // transactionName="Test Transaction"
  92. // />,
  93. // );
  94. // await waitForElementToBeRemoved(() => screen.getByTestId('loading-indicator'));
  95. // expect(screen.getByText('P75 Self Time')).toHaveAttribute('href', null);
  96. // expect(screen.getByText('Total Occurrences')).toHaveAttribute('href', null);
  97. // expect(screen.getByText('Total Self Time')).toHaveAttribute('href', null);
  98. // });
  99. });
  100. });