samplingBreakdown.spec.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProjectsStore from 'sentry/stores/projectsStore';
  3. import {ServerSideSamplingStore} from 'sentry/stores/serverSideSamplingStore';
  4. import {SamplingBreakdown} from 'sentry/views/settings/project/server-side-sampling/samplingBreakdown';
  5. import {getMockData, mockedSamplingDistribution} from './testUtils';
  6. export const samplingBreakdownTitle = 'Transaction Breakdown';
  7. describe('Server-Side Sampling - SamplingBreakdown', function () {
  8. beforeEach(function () {
  9. ServerSideSamplingStore.reset();
  10. });
  11. it('renders empty', function () {
  12. const {organization} = getMockData();
  13. render(<SamplingBreakdown orgSlug={organization.slug} />);
  14. expect(
  15. screen.getByText(
  16. 'There were no traces initiated from this project in the last 30 days.'
  17. )
  18. ).toBeInTheDocument();
  19. });
  20. it('renders project breakdown', function () {
  21. const {organization} = getMockData();
  22. const projectBreakdown = mockedSamplingDistribution.project_breakdown;
  23. ProjectsStore.loadInitialData(
  24. projectBreakdown!.map(p => TestStubs.Project({id: p.project_id, slug: p.project}))
  25. );
  26. ServerSideSamplingStore.fetchDistributionSuccess(mockedSamplingDistribution);
  27. render(<SamplingBreakdown orgSlug={organization.slug} />);
  28. expect(screen.getByText(samplingBreakdownTitle)).toBeInTheDocument();
  29. expect(screen.getByText('javascript')).toBeInTheDocument();
  30. expect(screen.getByText('89.88%')).toBeInTheDocument();
  31. expect(screen.getByText('sentry')).toBeInTheDocument();
  32. expect(screen.getByText('10.12%')).toBeInTheDocument();
  33. });
  34. });