suspectSpansTable.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {
  2. initializeData as _initializeData,
  3. makeSuspectSpan,
  4. SAMPLE_SPANS,
  5. } from 'sentry-test/performance/initializePerformanceData';
  6. import {act, render, screen, within} from 'sentry-test/reactTestingLibrary';
  7. import ProjectsStore from 'sentry/stores/projectsStore';
  8. import SuspectSpansTable from 'sentry/views/performance/transactionSummary/transactionSpans/suspectSpansTable';
  9. import {SpanSortOthers} from 'sentry/views/performance/transactionSummary/transactionSpans/types';
  10. const initializeData = () => {
  11. const data = _initializeData({
  12. features: ['performance-view'],
  13. });
  14. act(() => ProjectsStore.loadInitialData(data.organization.projects));
  15. return data;
  16. };
  17. describe('SuspectSpansTable', () => {
  18. it('should not calculate frequency percentages above 100%', async () => {
  19. const initialData = initializeData();
  20. const suspectSpan = makeSuspectSpan(SAMPLE_SPANS[0]);
  21. suspectSpan.frequency = 120;
  22. render(
  23. <SuspectSpansTable
  24. location={initialData.router.location}
  25. organization={initialData.organization}
  26. transactionName="Test Transaction"
  27. isLoading={false}
  28. suspectSpans={[suspectSpan]}
  29. totals={{'count()': 100}}
  30. sort={SpanSortOthers.SUM_EXCLUSIVE_TIME}
  31. />,
  32. {context: initialData.routerContext}
  33. );
  34. const frequencyHeader = await screen.findByTestId('grid-editable');
  35. expect(await within(frequencyHeader).findByText('100%')).toBeInTheDocument();
  36. });
  37. });