index.spec.tsx 1.4 KB

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