index.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {Organization} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import ProjectsStore from 'sentry/stores/projectsStore';
  4. import TeamInsightsContainer from 'sentry/views/organizationStats/teamInsights';
  5. describe('TeamInsightsContainer', () => {
  6. afterEach(() => {
  7. ProjectsStore.reset();
  8. });
  9. it('blocks access if org is missing flag', () => {
  10. const organization = Organization();
  11. const context = TestStubs.routerContext([{organization}]);
  12. render(
  13. <TeamInsightsContainer organization={organization}>
  14. <div>test</div>
  15. </TeamInsightsContainer>,
  16. {context}
  17. );
  18. expect(screen.queryByText('test')).not.toBeInTheDocument();
  19. });
  20. it('allows access for orgs with flag', () => {
  21. ProjectsStore.loadInitialData([TestStubs.Project()]);
  22. const organization = Organization({features: ['team-insights']});
  23. const context = TestStubs.routerContext([{organization}]);
  24. render(
  25. <TeamInsightsContainer organization={organization}>
  26. <div>test</div>
  27. </TeamInsightsContainer>,
  28. {context}
  29. );
  30. expect(screen.getByText('test')).toBeInTheDocument();
  31. });
  32. it('shows message for users with no teams', () => {
  33. ProjectsStore.loadInitialData([]);
  34. const organization = Organization({features: ['team-insights']});
  35. const context = TestStubs.routerContext([{organization}]);
  36. render(<TeamInsightsContainer organization={organization} />, {context});
  37. expect(
  38. screen.getByText('You need at least one project to use this view')
  39. ).toBeInTheDocument();
  40. });
  41. });