suspectSpans.spec.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {ProjectFixture} from 'sentry-fixture/project';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {generateSuspectSpansResponse} from 'sentry-test/performance/initializePerformanceData';
  5. import {
  6. act,
  7. render,
  8. screen,
  9. // waitForElementToBeRemoved,
  10. } from 'sentry-test/reactTestingLibrary';
  11. import ProjectsStore from 'sentry/stores/projectsStore';
  12. import EventView from 'sentry/utils/discover/eventView';
  13. import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  14. import {OrganizationContext} from 'sentry/views/organizationContext';
  15. import SuspectSpans from 'sentry/views/performance/transactionSummary/transactionOverview/suspectSpans';
  16. function initializeData({query} = {query: {}}) {
  17. const features = ['performance-view'];
  18. const organization = OrganizationFixture({
  19. features,
  20. projects: [ProjectFixture()],
  21. });
  22. const initialData = initializeOrg({
  23. organization,
  24. router: {
  25. location: {
  26. query: {
  27. transaction: 'Test Transaction',
  28. project: '1',
  29. ...query,
  30. },
  31. },
  32. },
  33. projects: [],
  34. });
  35. act(() => void ProjectsStore.loadInitialData(initialData.organization.projects));
  36. return {
  37. ...initialData,
  38. eventView: EventView.fromLocation(initialData.router.location),
  39. };
  40. }
  41. describe('SuspectSpans', function () {
  42. describe('With Span Data', function () {
  43. beforeEach(function () {
  44. MockApiClient.addMockResponse({
  45. url: '/organizations/org-slug/events-spans-performance/',
  46. body: generateSuspectSpansResponse({
  47. examples: 1,
  48. }),
  49. });
  50. });
  51. afterEach(function () {
  52. jest.resetAllMocks();
  53. });
  54. it('renders basic UI elements', async function () {
  55. const initialData = initializeData();
  56. render(
  57. <OrganizationContext.Provider value={initialData.organization}>
  58. <MEPSettingProvider>
  59. <SuspectSpans
  60. organization={initialData.organization}
  61. location={initialData.router.location}
  62. eventView={initialData.eventView}
  63. projectId="1"
  64. transactionName="Test Transaction"
  65. totals={{'count()': 1}}
  66. />
  67. </MEPSettingProvider>
  68. </OrganizationContext.Provider>
  69. );
  70. expect(await screen.findByText('Suspect Spans')).toBeInTheDocument();
  71. expect(await screen.findByText('View All Spans')).toBeInTheDocument();
  72. expect(await screen.findByText('Span Operation')).toBeInTheDocument();
  73. expect(await screen.findByText('Span Name')).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. });