index.spec.tsx 1.6 KB

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