samplingBreakdown.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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(screen.getByText(/This project made no/)).toBeInTheDocument();
  15. });
  16. it('renders project breakdown', function () {
  17. const {organization} = getMockData();
  18. const projectBreakdown = mockedSamplingDistribution.projectBreakdown;
  19. ProjectsStore.loadInitialData(
  20. projectBreakdown!.map(p => TestStubs.Project({id: p.projectId, slug: p.project}))
  21. );
  22. ServerSideSamplingStore.distributionRequestSuccess(mockedSamplingDistribution);
  23. render(<SamplingBreakdown orgSlug={organization.slug} />);
  24. expect(screen.getByText(samplingBreakdownTitle)).toBeInTheDocument();
  25. expect(screen.getByText('javascript')).toBeInTheDocument();
  26. expect(screen.getByText('89.88%')).toBeInTheDocument();
  27. expect(screen.getByText('sentry')).toBeInTheDocument();
  28. expect(screen.getByText('10.12%')).toBeInTheDocument();
  29. });
  30. });