samplingFromOtherProject.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {act, render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ProjectsStore from 'sentry/stores/projectsStore';
  3. import {ServerSideSamplingStore} from 'sentry/stores/serverSideSamplingStore';
  4. import {SamplingFromOtherProject} from './samplingFromOtherProject';
  5. import {getMockData, mockedSamplingDistribution} from './testUtils';
  6. export const samplingBreakdownTitle = 'Transaction Breakdown';
  7. describe('Server-Side Sampling - SamplingFromOtherProject', function () {
  8. afterEach(function () {
  9. act(() => ProjectsStore.reset());
  10. act(() => ServerSideSamplingStore.reset());
  11. });
  12. it('renders the parent projects', function () {
  13. const {organization} = getMockData();
  14. const parentProjectBreakdown = mockedSamplingDistribution.parentProjectBreakdown;
  15. ProjectsStore.loadInitialData(
  16. parentProjectBreakdown!.map(p =>
  17. TestStubs.Project({id: p.projectId, slug: p.project})
  18. )
  19. );
  20. ServerSideSamplingStore.distributionRequestSuccess(mockedSamplingDistribution);
  21. render(<SamplingFromOtherProject orgSlug={organization.slug} projectSlug="abc" />);
  22. expect(screen.getByText('parent-project')).toBeInTheDocument();
  23. expect(
  24. screen.getByText(
  25. 'The following project made sampling decisions for this project. You might want to set up rules there.'
  26. )
  27. ).toBeInTheDocument();
  28. });
  29. it('does not render if there are no parent projects', function () {
  30. const {organization} = getMockData();
  31. const parentProjectBreakdown = mockedSamplingDistribution.parentProjectBreakdown;
  32. ProjectsStore.loadInitialData(
  33. parentProjectBreakdown!.map(p =>
  34. TestStubs.Project({id: p.projectId, slug: p.project})
  35. )
  36. );
  37. ServerSideSamplingStore.distributionRequestSuccess({
  38. ...mockedSamplingDistribution,
  39. parentProjectBreakdown: [],
  40. });
  41. render(<SamplingFromOtherProject orgSlug={organization.slug} projectSlug="abc" />);
  42. expect(screen.queryByText('parent-project')).not.toBeInTheDocument();
  43. expect(
  44. screen.queryByText(
  45. 'The following project made sampling decisions for this project. You might want to set up rules there.'
  46. )
  47. ).not.toBeInTheDocument();
  48. });
  49. });