index.spec.tsx 1.7 KB

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