samplesTables.spec.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {useReleaseSelection} from 'sentry/views/insights/common/queries/useReleases';
  3. import {SamplesTables} from 'sentry/views/insights/mobile/common/components/tables/samplesTables';
  4. jest.mock('sentry/views/insights/common/queries/useReleases');
  5. jest.mocked(useReleaseSelection).mockReturnValue({
  6. primaryRelease: 'com.example.vu.android@2.10.5-alpha.1+42',
  7. isLoading: false,
  8. secondaryRelease: 'com.example.vu.android@2.10.3+42',
  9. });
  10. describe('SamplesTables', () => {
  11. it('accepts components for event samples and span operation table', async () => {
  12. render(
  13. <SamplesTables
  14. EventSamples={({release}) => (
  15. <div>{`This is a custom Event Samples table for release: ${release}`}</div>
  16. )}
  17. SpanOperationTable={_props => <div>This is a custom Span Operation table</div>}
  18. transactionName={''}
  19. />
  20. );
  21. // The span operation table is rendered first
  22. expect(
  23. await screen.findByText('This is a custom Span Operation table')
  24. ).toBeInTheDocument();
  25. await userEvent.click(screen.getByRole('radio', {name: 'By Event'}));
  26. expect(
  27. await screen.findByText(
  28. 'This is a custom Event Samples table for release: com.example.vu.android@2.10.5-alpha.1+42'
  29. )
  30. ).toBeInTheDocument();
  31. expect(
  32. screen.getByText(
  33. 'This is a custom Event Samples table for release: com.example.vu.android@2.10.3+42'
  34. )
  35. ).toBeInTheDocument();
  36. });
  37. });